@tinypoly/gpu-renderer 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +31 -3
- package/README.md +11 -3
- package/dist/denoise.d.ts +10 -1
- package/dist/denoise.d.ts.map +1 -1
- package/dist/denoise.js +4 -0
- package/dist/denoise.js.map +1 -1
- package/dist/device.d.ts.map +1 -1
- package/dist/device.js +8 -0
- package/dist/device.js.map +1 -1
- package/dist/frameLayout.d.ts.map +1 -1
- package/dist/frameLayout.js +4 -1
- package/dist/frameLayout.js.map +1 -1
- package/dist/imageResolve.d.ts +2 -1
- package/dist/imageResolve.d.ts.map +1 -1
- package/dist/imageResolve.js +1 -0
- package/dist/imageResolve.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lensPass.d.ts +4 -0
- package/dist/lensPass.d.ts.map +1 -1
- package/dist/lensPass.js +14 -1
- package/dist/lensPass.js.map +1 -1
- package/dist/lights.d.ts +18 -0
- package/dist/lights.d.ts.map +1 -1
- package/dist/lights.js +45 -0
- package/dist/lights.js.map +1 -1
- package/dist/oidnPass.d.ts +48 -0
- package/dist/oidnPass.d.ts.map +1 -0
- package/dist/oidnPass.js +255 -0
- package/dist/oidnPass.js.map +1 -0
- package/dist/pathTracePass.d.ts +2 -2
- package/dist/pathTracePass.d.ts.map +1 -1
- package/dist/pathTracePass.js +9 -9
- package/dist/pathTracePass.js.map +1 -1
- package/dist/presentPass.d.ts +2 -0
- package/dist/presentPass.d.ts.map +1 -1
- package/dist/presentPass.js +1 -0
- package/dist/presentPass.js.map +1 -1
- package/dist/renderer.d.ts +12 -0
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +100 -14
- package/dist/renderer.js.map +1 -1
- package/dist/sceneUpload.d.ts +4 -0
- package/dist/sceneUpload.d.ts.map +1 -1
- package/dist/sceneUpload.js +3 -0
- package/dist/sceneUpload.js.map +1 -1
- package/dist/settings.d.ts +23 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +13 -4
- package/dist/settings.js.map +1 -1
- package/dist/wgsl/lens.wgsl.d.ts +1 -1
- package/dist/wgsl/lens.wgsl.d.ts.map +1 -1
- package/dist/wgsl/lens.wgsl.js +108 -1
- package/dist/wgsl/lens.wgsl.js.map +1 -1
- package/dist/wgsl/lights.wgsl.d.ts +1 -1
- package/dist/wgsl/lights.wgsl.d.ts.map +1 -1
- package/dist/wgsl/lights.wgsl.js +147 -17
- package/dist/wgsl/lights.wgsl.js.map +1 -1
- package/dist/wgsl/pathTrace.wgsl.d.ts +1 -1
- package/dist/wgsl/pathTrace.wgsl.d.ts.map +1 -1
- package/dist/wgsl/pathTrace.wgsl.js +123 -91
- package/dist/wgsl/pathTrace.wgsl.js.map +1 -1
- package/dist/wgsl/present.wgsl.d.ts +1 -1
- package/dist/wgsl/present.wgsl.d.ts.map +1 -1
- package/dist/wgsl/present.wgsl.js +11 -1
- package/dist/wgsl/present.wgsl.js.map +1 -1
- package/package.json +4 -2
- package/src/denoise.ts +15 -1
- package/src/device.ts +9 -0
- package/src/frameLayout.ts +4 -1
- package/src/imageResolve.ts +2 -0
- package/src/index.ts +2 -1
- package/src/lensPass.ts +17 -1
- package/src/lights.ts +60 -0
- package/src/oidnPass.ts +284 -0
- package/src/oidnWebgpu.d.ts +5 -0
- package/src/pathTracePass.ts +11 -9
- package/src/presentPass.ts +3 -0
- package/src/renderer.ts +118 -15
- package/src/sceneUpload.ts +7 -0
- package/src/settings.ts +32 -4
- package/src/wgsl/lens.wgsl.ts +108 -1
- package/src/wgsl/lights.wgsl.ts +147 -17
- package/src/wgsl/pathTrace.wgsl.ts +123 -91
- package/src/wgsl/present.wgsl.ts +11 -1
- package/weights/LICENSE.txt +202 -0
- package/weights/rt_hdr_alb_nrm.tza +0 -0
|
@@ -42,7 +42,9 @@ fn backgroundRadiance(direction: vec3<f32>) -> vec3<f32> {
|
|
|
42
42
|
return frame.background.rgb;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// A procedural sky paints the background
|
|
45
|
+
// A procedural sky paints the background with the strength it lights with, and its foreground over it. The CPU
|
|
46
|
+
// renderer leaves that strength out of what the camera sees, which a renderer exposing for the light cannot: the sky
|
|
47
|
+
// that lights a wall five times brighter than itself would show as a dark band behind it.
|
|
46
48
|
if (frame.skyProgram != NO_PROGRAM || frame.skyIntensity > 0.0) {
|
|
47
49
|
if (frame.skyBackground == 0u) {
|
|
48
50
|
return vec3<f32>(0.0);
|
|
@@ -54,10 +56,10 @@ fn backgroundRadiance(direction: vec3<f32>) -> vec3<f32> {
|
|
|
54
56
|
input.direction = direction;
|
|
55
57
|
input.diffuseColor = vec4<f32>(1.0);
|
|
56
58
|
|
|
57
|
-
return runProgram(frame.skyProgram, input).color.rgb;
|
|
59
|
+
return runProgram(frame.skyProgram, input).color.rgb * frame.skyIntensity;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
return environmentRadiance(direction)
|
|
62
|
+
return environmentRadiance(direction);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
return environmentRadiance(direction);
|
|
@@ -67,7 +69,7 @@ fn backgroundRadiance(direction: vec3<f32>) -> vec3<f32> {
|
|
|
67
69
|
* How much of the sky a bounce ray that escaped keeps. Direct sampling aims at the bright parts of an image too, so the
|
|
68
70
|
* two share it; when direct sampling took all of it, as it does from a toon surface, the bounce keeps none.
|
|
69
71
|
*/
|
|
70
|
-
fn escapeWeight(direction: vec3<f32>, bsdfPdf: f32, lightsOwnDirect: bool) -> f32 {
|
|
72
|
+
fn escapeWeight(direction: vec3<f32>, bsdfPdf: f32, lightsOwnDirect: bool, scatteredAt: vec3<f32>) -> f32 {
|
|
71
73
|
if (frame.environmentPick <= 0.0) {
|
|
72
74
|
return 1.0;
|
|
73
75
|
}
|
|
@@ -80,7 +82,8 @@ fn escapeWeight(direction: vec3<f32>, bsdfPdf: f32, lightsOwnDirect: bool) -> f3
|
|
|
80
82
|
return 1.0;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
// The sky was aimed at from the vertex the bounce left, through its windows as well when that vertex is inside.
|
|
86
|
+
return misWeight(bsdfPdf, frame.environmentPick * skyPdf(scatteredAt, direction, portalChance(scatteredAt)));
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
/** Scales a contribution down to the luminance ceiling, which trades a little bias for the fireflies it removes. */
|
|
@@ -548,7 +551,7 @@ fn traceRadiance(
|
|
|
548
551
|
if (escapeMap != NO_TEXTURE) {
|
|
549
552
|
sky = sky + sampleEquirect(escapeMap, direction).rgb * escapeIntensity;
|
|
550
553
|
} else {
|
|
551
|
-
sky = sky + environmentRadiance(direction) * escapeWeight(direction, bsdfPdf, lightsOwnDirect);
|
|
554
|
+
sky = sky + environmentRadiance(direction) * escapeWeight(direction, bsdfPdf, lightsOwnDirect, lastPosition);
|
|
552
555
|
}
|
|
553
556
|
|
|
554
557
|
let contribution = throughput * sky;
|
|
@@ -703,8 +706,14 @@ fn traceRadiance(
|
|
|
703
706
|
depth = length(point - rayOrigin);
|
|
704
707
|
}
|
|
705
708
|
|
|
709
|
+
// A window the camera ray goes straight through is not what the camera sees: what lies behind it is, so the
|
|
710
|
+
// denoiser takes its guides there, and the air its distance. Glass has next to no diffuse colour and one flat
|
|
711
|
+
// normal, which would leave everything seen through it unfiltered. The window's own guides stand until then, for
|
|
712
|
+
// the paths that reflect off it instead.
|
|
713
|
+
let window = surface.transmission > 0.0 && surface.thickness <= 0.0;
|
|
714
|
+
|
|
706
715
|
if (straight && !guided) {
|
|
707
|
-
guided =
|
|
716
|
+
guided = !window;
|
|
708
717
|
diffuseAlbedo = diffuseGuide(surface);
|
|
709
718
|
specularAlbedoGuide = select(specularAlbedo(surface, -direction), vec3<f32>(1.0), (surface.flags & MATERIAL_LIT) == 0u);
|
|
710
719
|
guideNormal = surface.normal;
|
|
@@ -745,7 +754,7 @@ fn traceRadiance(
|
|
|
745
754
|
}
|
|
746
755
|
}
|
|
747
756
|
|
|
748
|
-
if (!hazed && frame.atmosphereColor.w > 0.0) {
|
|
757
|
+
if (!hazed && !window && frame.atmosphereColor.w > 0.0) {
|
|
749
758
|
hazed = true;
|
|
750
759
|
// From the eye, where the camera ray only starts on the near plane; an orthographic view has no eye.
|
|
751
760
|
hazeDistance = length(point - select(frame.cameraToWorld[3].xyz, rayOrigin, frame.cameraKind == 1u));
|
|
@@ -765,7 +774,11 @@ fn traceRadiance(
|
|
|
765
774
|
}
|
|
766
775
|
|
|
767
776
|
// Three does not light a basic, points, line or sprite material, so nothing carries on from one.
|
|
768
|
-
|
|
777
|
+
// Past the last bounce a path still crosses a window straight on, which scatters nothing, to find the sky behind
|
|
778
|
+
// it: cut there, the daylight a room gets through its glazing would go missing from every last bounce.
|
|
779
|
+
let spent = bounce >= frame.bounces;
|
|
780
|
+
|
|
781
|
+
if ((surface.flags & MATERIAL_LIT) == 0u || (spent && !window)) {
|
|
769
782
|
break;
|
|
770
783
|
}
|
|
771
784
|
|
|
@@ -788,8 +801,105 @@ fn traceRadiance(
|
|
|
788
801
|
var nextOrigin = point + direction * RAY_EPSILON;
|
|
789
802
|
|
|
790
803
|
// Transmission replaces part of the diffuse layer, so that share of the time the surface is a dielectric instead.
|
|
791
|
-
// Choosing it in proportion to its weight leaves both halves unweighted
|
|
792
|
-
|
|
804
|
+
// Choosing it in proportion to its weight leaves both halves unweighted. The opaque half aims at a light; on a
|
|
805
|
+
// window that lets only part of the light through, it does so on every path, weighed by its share, rather than on
|
|
806
|
+
// the paths that chose it: a sunlit pane seen against a dim room would otherwise be lit on one path in five and
|
|
807
|
+
// dark on the rest, which is the grain glass shows.
|
|
808
|
+
let dielectric = surface.transmission > 0.0 && lobe.y < surface.transmission;
|
|
809
|
+
let windowLight = window && !spent && surface.transmission < 1.0 && surface.subsurface <= 0.0;
|
|
810
|
+
|
|
811
|
+
if (!dielectric || windowLight) {
|
|
812
|
+
var chance = 0.0;
|
|
813
|
+
|
|
814
|
+
if (!dielectric) {
|
|
815
|
+
// Light that enters the material: a random walk inside it from here, in place of the share of the diffuse
|
|
816
|
+
// layer that scatters inside. Chosen by chance, so neither branch is weighted against the other.
|
|
817
|
+
// The window's opaque share is a surface like any other, which a spent path stops at.
|
|
818
|
+
if (spent) {
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (SUBSURFACE_WALK) {
|
|
823
|
+
chance = subsurfaceChance(surface, view);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
if (SUBSURFACE_WALK && lobe.x < chance) {
|
|
827
|
+
let medium = materials[surface.material].subsurface;
|
|
828
|
+
|
|
829
|
+
throughput = throughput
|
|
830
|
+
* ((1.0 - surface.metalness) * surface.subsurface * coatTransmittance(surface, view) / chance);
|
|
831
|
+
sigma = vec3<f32>(1.0) / max(medium.rgb, vec3<f32>(1e-6));
|
|
832
|
+
walkAlbedo = subsurfaceAlbedo(surface.albedo);
|
|
833
|
+
walkG = materials[surface.material].subsurfaceAnisotropy;
|
|
834
|
+
walkSteps = 0u;
|
|
835
|
+
|
|
836
|
+
// Light that scattered inside is diffuse light, which is the signal it feeds.
|
|
837
|
+
if (!split) {
|
|
838
|
+
split = true;
|
|
839
|
+
splitBase = radiance;
|
|
840
|
+
splitDiffuse = true;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
inMedium = true;
|
|
844
|
+
primary = false;
|
|
845
|
+
straight = false;
|
|
846
|
+
bsdfPdf = 0.0;
|
|
847
|
+
lightsOwnDirect = false;
|
|
848
|
+
escapeMap = NO_TEXTURE;
|
|
849
|
+
bounce = bounce + 1u;
|
|
850
|
+
direction = cosineDirection(-surface.facing, bounceSample);
|
|
851
|
+
origin = point - surface.facing * RAY_EPSILON;
|
|
852
|
+
limit = walkDistance(throughput, sigma, pick, &walkOdds);
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
throughput = throughput / (1.0 - chance);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
let position = point + surface.normal * RAY_EPSILON;
|
|
860
|
+
var directDiffuse: vec3<f32>;
|
|
861
|
+
let lit = select(throughput, throughput * (1.0 - surface.transmission), windowLight);
|
|
862
|
+
let direct = lit * directLight(surface, position, view, pick.x, lightSample, rng, &directDiffuse,
|
|
863
|
+
select(0.0, volumeDensity, inVolume));
|
|
864
|
+
let added = select(direct, clampIndirect(direct), bounce > 0u);
|
|
865
|
+
let before = radiance;
|
|
866
|
+
|
|
867
|
+
radiance = radiance + added;
|
|
868
|
+
|
|
869
|
+
if (!dielectric) {
|
|
870
|
+
let scattered = sampleBsdf(surface, view, (lobe.x - chance) / (1.0 - chance), bounceSample);
|
|
871
|
+
|
|
872
|
+
// The first scatter splits the path: its direct light by lobe, and everything after it by the lobe it chose.
|
|
873
|
+
if (!split) {
|
|
874
|
+
split = true;
|
|
875
|
+
splitBase = before;
|
|
876
|
+
splitDirect = added;
|
|
877
|
+
splitDirectDiffuse = lit * directDiffuse * select(1.0, luminanceOf(added) / max(luminanceOf(direct), 1e-20),
|
|
878
|
+
bounce > 0u);
|
|
879
|
+
splitDiffuse = !scattered.valid || scattered.diffuse;
|
|
880
|
+
waitingForSpecular = scattered.valid && !scattered.diffuse;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
if (!scattered.valid) {
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
throughput = throughput * scattered.weight;
|
|
888
|
+
bsdfPdf = scattered.pdf;
|
|
889
|
+
lastPosition = position;
|
|
890
|
+
lastNormal = treeNormal(surface);
|
|
891
|
+
lightsOwnDirect = surface.kind == KIND_TOON;
|
|
892
|
+
escapeMap = surface.envMap;
|
|
893
|
+
escapeIntensity = surface.envMapIntensity;
|
|
894
|
+
next = scattered.direction;
|
|
895
|
+
nextOrigin = position;
|
|
896
|
+
primary = false;
|
|
897
|
+
straight = false;
|
|
898
|
+
bounce = bounce + 1u;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
if (dielectric) {
|
|
793
903
|
var ior = surface.ior;
|
|
794
904
|
|
|
795
905
|
// Three's dispersion: each colour refracts with its own index, spread around the material's. The path picks one
|
|
@@ -809,7 +919,8 @@ fn traceRadiance(
|
|
|
809
919
|
|
|
810
920
|
let crossing = sampleDielectric(surface, view, ior, lobe.y / surface.transmission, bounceSample);
|
|
811
921
|
|
|
812
|
-
|
|
922
|
+
// A reflection off the glass is a scattering, which a spent path no longer has.
|
|
923
|
+
if (!crossing.valid || (spent && !crossing.straight)) {
|
|
813
924
|
break;
|
|
814
925
|
}
|
|
815
926
|
|
|
@@ -844,85 +955,6 @@ fn traceRadiance(
|
|
|
844
955
|
if (!primary) {
|
|
845
956
|
bounce = bounce + 1u;
|
|
846
957
|
}
|
|
847
|
-
} else {
|
|
848
|
-
// Light that enters the material: a random walk inside it from here, in place of the share of the diffuse
|
|
849
|
-
// layer that scatters inside. Chosen by chance, so neither branch is weighted against the other.
|
|
850
|
-
var chance = 0.0;
|
|
851
|
-
|
|
852
|
-
if (SUBSURFACE_WALK) {
|
|
853
|
-
chance = subsurfaceChance(surface, view);
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
if (SUBSURFACE_WALK && lobe.x < chance) {
|
|
857
|
-
let medium = materials[surface.material].subsurface;
|
|
858
|
-
|
|
859
|
-
throughput = throughput
|
|
860
|
-
* ((1.0 - surface.metalness) * surface.subsurface * coatTransmittance(surface, view) / chance);
|
|
861
|
-
sigma = vec3<f32>(1.0) / max(medium.rgb, vec3<f32>(1e-6));
|
|
862
|
-
walkAlbedo = subsurfaceAlbedo(surface.albedo);
|
|
863
|
-
walkG = materials[surface.material].subsurfaceAnisotropy;
|
|
864
|
-
walkSteps = 0u;
|
|
865
|
-
|
|
866
|
-
// Light that scattered inside is diffuse light, which is the signal it feeds.
|
|
867
|
-
if (!split) {
|
|
868
|
-
split = true;
|
|
869
|
-
splitBase = radiance;
|
|
870
|
-
splitDiffuse = true;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
inMedium = true;
|
|
874
|
-
primary = false;
|
|
875
|
-
straight = false;
|
|
876
|
-
bsdfPdf = 0.0;
|
|
877
|
-
lightsOwnDirect = false;
|
|
878
|
-
escapeMap = NO_TEXTURE;
|
|
879
|
-
bounce = bounce + 1u;
|
|
880
|
-
direction = cosineDirection(-surface.facing, bounceSample);
|
|
881
|
-
origin = point - surface.facing * RAY_EPSILON;
|
|
882
|
-
limit = walkDistance(throughput, sigma, pick, &walkOdds);
|
|
883
|
-
continue;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
throughput = throughput / (1.0 - chance);
|
|
887
|
-
|
|
888
|
-
let position = point + surface.normal * RAY_EPSILON;
|
|
889
|
-
var directDiffuse: vec3<f32>;
|
|
890
|
-
let direct = throughput * directLight(surface, position, view, pick.x, lightSample, rng, &directDiffuse,
|
|
891
|
-
select(0.0, volumeDensity, inVolume));
|
|
892
|
-
let added = select(direct, clampIndirect(direct), bounce > 0u);
|
|
893
|
-
let before = radiance;
|
|
894
|
-
|
|
895
|
-
radiance = radiance + added;
|
|
896
|
-
|
|
897
|
-
let scattered = sampleBsdf(surface, view, (lobe.x - chance) / (1.0 - chance), bounceSample);
|
|
898
|
-
|
|
899
|
-
// The first scatter splits the path: its direct light by lobe, and everything after it by the lobe it chose.
|
|
900
|
-
if (!split) {
|
|
901
|
-
split = true;
|
|
902
|
-
splitBase = before;
|
|
903
|
-
splitDirect = added;
|
|
904
|
-
splitDirectDiffuse = throughput * directDiffuse * select(1.0, luminanceOf(added) / max(luminanceOf(direct), 1e-20),
|
|
905
|
-
bounce > 0u);
|
|
906
|
-
splitDiffuse = !scattered.valid || scattered.diffuse;
|
|
907
|
-
waitingForSpecular = scattered.valid && !scattered.diffuse;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
if (!scattered.valid) {
|
|
911
|
-
break;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
throughput = throughput * scattered.weight;
|
|
915
|
-
bsdfPdf = scattered.pdf;
|
|
916
|
-
lastPosition = position;
|
|
917
|
-
lastNormal = treeNormal(surface);
|
|
918
|
-
lightsOwnDirect = surface.kind == KIND_TOON;
|
|
919
|
-
escapeMap = surface.envMap;
|
|
920
|
-
escapeIntensity = surface.envMapIntensity;
|
|
921
|
-
next = scattered.direction;
|
|
922
|
-
nextOrigin = position;
|
|
923
|
-
primary = false;
|
|
924
|
-
straight = false;
|
|
925
|
-
bounce = bounce + 1u;
|
|
926
958
|
}
|
|
927
959
|
|
|
928
960
|
// A path that carries almost nothing is ended by chance rather than by a cut, which keeps the estimate unbiased.
|
package/src/wgsl/present.wgsl.ts
CHANGED
|
@@ -15,6 +15,8 @@ struct Present {
|
|
|
15
15
|
transparent: u32,
|
|
16
16
|
// Whether the colour comes from the denoiser's output rather than straight from the accumulation.
|
|
17
17
|
denoised: u32,
|
|
18
|
+
// How much of AgX's Punchy look goes over its base curve.
|
|
19
|
+
contrast: f32,
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
@group(0) @binding(0) var<uniform> present: Present;
|
|
@@ -63,8 +65,16 @@ fn toneMapAgx(color: vec3<f32>) -> vec3<f32> {
|
|
|
63
65
|
vec3<f32>(-0.0728, -0.0083, 1.1187));
|
|
64
66
|
let logged = inset * (toAgx * color);
|
|
65
67
|
let x = clamp((log2(max(logged, vec3<f32>(1e-10))) + 12.47393) / 16.499999, vec3<f32>(0.0), vec3<f32>(1.0));
|
|
66
|
-
let
|
|
68
|
+
let base = 15.5 * pow(x, vec3<f32>(6.0)) - 40.14 * pow(x, vec3<f32>(5.0)) + 31.96 * pow(x, vec3<f32>(4.0))
|
|
67
69
|
- 6.868 * pow(x, vec3<f32>(3.0)) + 0.4298 * x * x + 0.1191 * x - 0.00232;
|
|
70
|
+
// A look in the spirit of Blender's Punchy, a power of 1.35 and more saturation, but pivoted on middle grey: Punchy
|
|
71
|
+
// raises the power around zero, which takes middle grey from half the display down to a third and darkens the whole
|
|
72
|
+
// image. Here the highlights rise and the shadows fall while grey, which the automatic exposure aims at, stands.
|
|
73
|
+
let pivot = 0.49673;
|
|
74
|
+
let contrasted = pivot * pow(max(base, vec3<f32>(0.0)) / pivot, vec3<f32>(1.35));
|
|
75
|
+
let luma = dot(contrasted, vec3<f32>(0.2126, 0.7152, 0.0722));
|
|
76
|
+
let punchy = luma + 1.2 * (contrasted - luma);
|
|
77
|
+
let curved = mix(base, punchy, clamp(present.contrast, 0.0, 1.0));
|
|
68
78
|
|
|
69
79
|
return fromAgx * pow(max(outset * curved, vec3<f32>(0.0)), vec3<f32>(2.2));
|
|
70
80
|
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
Binary file
|