@zephyr3d/scene 0.9.24 → 0.9.26
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/dist/animation/hair/gpu_hair_simulation.js +1090 -0
- package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
- package/dist/animation/joint_dynamics/controller.js +7 -5
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -4
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +58 -24
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/multi_chain_spring_system.js +577 -179
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +4 -3
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
- package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +2 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +11 -3
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +10 -0
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/engine.js +53 -43
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptingsystem.js +119 -6
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +3 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +284 -67
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/zhair/zhair_format.js +288 -0
- package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
- package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
- package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
- package/dist/asset/model.js +178 -67
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +193 -21
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +3 -1
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +4040 -1290
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/material/eye.js +932 -0
- package/dist/material/eye.js.map +1 -0
- package/dist/material/hair.js +917 -0
- package/dist/material/hair.js.map +1 -0
- package/dist/material/hairstrand.js +842 -0
- package/dist/material/hairstrand.js.map +1 -0
- package/dist/material/hairstrand_data.js +162 -0
- package/dist/material/hairstrand_data.js.map +1 -0
- package/dist/material/lambert.js +5 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +338 -300
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +120 -19
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +1 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -4
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +73 -18
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +4 -4
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +48 -11
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mtoon.js +6 -5
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrblueprint.js +146 -28
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrblueprint_instance.js +501 -0
- package/dist/material/pbrblueprint_instance.js.map +1 -0
- package/dist/material/pbrmr.js +15 -16
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/shader/helper.js +766 -456
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +55 -0
- package/dist/material/shader/terrain_blend.js.map +1 -0
- package/dist/material/skin.js +192 -32
- package/dist/material/skin.js.map +1 -1
- package/dist/material/spriteblueprint.js +16 -1
- package/dist/material/spriteblueprint.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +86 -23
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/water.js +3 -1
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/bloom.js +167 -7
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/coloradjust.js +2 -1
- package/dist/posteffect/coloradjust.js.map +1 -1
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +2 -1
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -1
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +4 -1
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/skinsss.js +368 -69
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +16 -9
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +91 -34
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/posteffect/tonemap.js +44 -1
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +45 -39
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +4 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +19 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +36 -2
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +26 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +52 -51
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +1 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +3 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +3 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +3 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/oit.js +29 -0
- package/dist/render/oit.js.map +1 -0
- package/dist/render/render_queue.js +3 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +2 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +61 -1
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/shadow_mask_pass.js +73 -8
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/sky.js +166 -126
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +36 -35
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +8 -0
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -0
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +4 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/hair.js +963 -0
- package/dist/scene/hair.js.map +1 -0
- package/dist/scene/light.js +5 -1
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +481 -47
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +3 -0
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +3 -0
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +6 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +3 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -1
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +273 -249
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +3 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +6 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/texture_cache.js +309 -0
- package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
- package/dist/scene/water.js +6 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/diffusion.js +54 -0
- package/dist/shaders/diffusion.js.map +1 -0
- package/dist/shaders/shadow.js +33 -21
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/temporal.js +71 -33
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shadow/dom.js +546 -0
- package/dist/shadow/dom.js.map +1 -0
- package/dist/shadow/pcf_opt.js +3 -5
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +1 -1
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/receiver_bias.js +41 -0
- package/dist/shadow/receiver_bias.js.map +1 -0
- package/dist/shadow/shader.js +20 -60
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +89 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +50 -50
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +150 -37
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/shape.js +11 -2
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +50 -9
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +112 -2
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/func.js +142 -49
- package/dist/utility/blueprint/material/func.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +490 -25
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +898 -4
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +431 -100
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +370 -3
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +133 -1
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +26 -5
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/hair.js +1141 -0
- package/dist/utility/serialization/scene/hair.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +84 -4
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1867 -166
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +231 -14
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +141 -7
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +18 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +4 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +92 -69
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +4 -0
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +96 -95
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/values.js +105 -58
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Burley (Christensen-Burley) normalized diffusion weight for one channel.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The profile is
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* R(r) = (exp(-r/d) + exp(-r/(3d))) / (8 * pi * d * r)
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* where `d` is the shaping distance. The `1/r` factor is the 2D-to-1D Jacobian
|
|
12
|
+
* of the radially symmetric profile; a separable screen-space blur integrates
|
|
13
|
+
* along a line rather than over a disc, so it is dropped here and the weights
|
|
14
|
+
* are renormalized by their own sum instead. That is the standard separable
|
|
15
|
+
* approximation - it is not exactly the 2D profile, but the error is far below
|
|
16
|
+
* what the depth-aware tap rejection introduces anyway.
|
|
17
|
+
*
|
|
18
|
+
* Two exponentials rather than one Gaussian is what gives skin its
|
|
19
|
+
* characteristic shape: a sharp peak that keeps detail near the source, plus a
|
|
20
|
+
* long tail that carries the bleed. A single Gaussian can match one or the
|
|
21
|
+
* other, not both, which is why Gaussian SSS reads as haze.
|
|
22
|
+
*
|
|
23
|
+
* {@link SSS} in `posteffect/sss.ts` carries a more elaborate variant driven by
|
|
24
|
+
* per-pixel profile slots and a LUT. This one is deliberately separate and much
|
|
25
|
+
* smaller: {@link SkinSSS} has a single global profile in uniforms, so it needs
|
|
26
|
+
* no LUT plumbing. Unifying the two is worthwhile but would mean editing a
|
|
27
|
+
* 2500-line shader that has no pixel-regression coverage.
|
|
28
|
+
*
|
|
29
|
+
* @param scope - Shader scope.
|
|
30
|
+
* @param distance - Absolute distance from the kernel center, in the same units as `d`.
|
|
31
|
+
* @param d - Shaping distance for this channel. Larger values scatter further.
|
|
32
|
+
* @returns Unnormalized weight; callers must divide by the accumulated sum.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/ function burleyDiffusionWeight(scope, distance, d) {
|
|
36
|
+
const pb = scope.$builder;
|
|
37
|
+
const funcName = 'lib_burleyDiffusionWeight';
|
|
38
|
+
pb.func(funcName, [
|
|
39
|
+
pb.float('distance'),
|
|
40
|
+
pb.float('d')
|
|
41
|
+
], function() {
|
|
42
|
+
this.$l.safeD = pb.max(this.d, 1e-4);
|
|
43
|
+
this.$l.r = pb.div(pb.abs(this.distance), this.safeD);
|
|
44
|
+
// exp() of a large negative is flushed to zero anyway; clamping keeps the
|
|
45
|
+
// argument in range on backends that are less forgiving about it.
|
|
46
|
+
this.$l.e1 = pb.exp(pb.neg(pb.min(this.r, 40)));
|
|
47
|
+
this.$l.e2 = pb.exp(pb.neg(pb.min(pb.div(this.r, 3), 40)));
|
|
48
|
+
this.$return(pb.div(pb.add(this.e1, this.e2), this.safeD));
|
|
49
|
+
});
|
|
50
|
+
return pb.getGlobalScope()[funcName](distance, d);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { burleyDiffusionWeight };
|
|
54
|
+
//# sourceMappingURL=diffusion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffusion.js","sources":["../../src/shaders/diffusion.ts"],"sourcesContent":["import type { PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\n\r\n/**\r\n * Burley (Christensen-Burley) normalized diffusion weight for one channel.\r\n *\r\n * @remarks\r\n * The profile is\r\n *\r\n * ```\r\n * R(r) = (exp(-r/d) + exp(-r/(3d))) / (8 * pi * d * r)\r\n * ```\r\n *\r\n * where `d` is the shaping distance. The `1/r` factor is the 2D-to-1D Jacobian\r\n * of the radially symmetric profile; a separable screen-space blur integrates\r\n * along a line rather than over a disc, so it is dropped here and the weights\r\n * are renormalized by their own sum instead. That is the standard separable\r\n * approximation - it is not exactly the 2D profile, but the error is far below\r\n * what the depth-aware tap rejection introduces anyway.\r\n *\r\n * Two exponentials rather than one Gaussian is what gives skin its\r\n * characteristic shape: a sharp peak that keeps detail near the source, plus a\r\n * long tail that carries the bleed. A single Gaussian can match one or the\r\n * other, not both, which is why Gaussian SSS reads as haze.\r\n *\r\n * {@link SSS} in `posteffect/sss.ts` carries a more elaborate variant driven by\r\n * per-pixel profile slots and a LUT. This one is deliberately separate and much\r\n * smaller: {@link SkinSSS} has a single global profile in uniforms, so it needs\r\n * no LUT plumbing. Unifying the two is worthwhile but would mean editing a\r\n * 2500-line shader that has no pixel-regression coverage.\r\n *\r\n * @param scope - Shader scope.\r\n * @param distance - Absolute distance from the kernel center, in the same units as `d`.\r\n * @param d - Shaping distance for this channel. Larger values scatter further.\r\n * @returns Unnormalized weight; callers must divide by the accumulated sum.\r\n *\r\n * @internal\r\n */\r\nexport function burleyDiffusionWeight(\r\n scope: PBInsideFunctionScope,\r\n distance: PBShaderExp,\r\n d: PBShaderExp\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'lib_burleyDiffusionWeight';\r\n pb.func(funcName, [pb.float('distance'), pb.float('d')], function () {\r\n this.$l.safeD = pb.max(this.d, 1e-4);\r\n this.$l.r = pb.div(pb.abs(this.distance), this.safeD);\r\n // exp() of a large negative is flushed to zero anyway; clamping keeps the\r\n // argument in range on backends that are less forgiving about it.\r\n this.$l.e1 = pb.exp(pb.neg(pb.min(this.r, 40)));\r\n this.$l.e2 = pb.exp(pb.neg(pb.min(pb.div(this.r, 3), 40)));\r\n this.$return(pb.div(pb.add(this.e1, this.e2), this.safeD));\r\n });\r\n return pb.getGlobalScope()[funcName](distance, d) as PBShaderExp;\r\n}\r\n"],"names":["burleyDiffusionWeight","scope","distance","d","pb","$builder","funcName","func","float","$l","safeD","max","r","div","abs","e1","exp","neg","min","e2","$return","add","getGlobalScope"],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCC,IACM,SAASA,qBAAAA,CACdC,KAA4B,EAC5BC,QAAqB,EACrBC,CAAc,EAAA;IAEd,MAAMC,EAAAA,GAAKH,MAAMI,QAAQ;AACzB,IAAA,MAAMC,QAAW,GAAA,2BAAA;IACjBF,EAAGG,CAAAA,IAAI,CAACD,QAAU,EAAA;AAACF,QAAAA,EAAAA,CAAGI,KAAK,CAAC,UAAA,CAAA;AAAaJ,QAAAA,EAAAA,CAAGI,KAAK,CAAC,GAAA;KAAK,EAAE,WAAA;QACvD,IAAI,CAACC,EAAE,CAACC,KAAK,GAAGN,EAAGO,CAAAA,GAAG,CAAC,IAAI,CAACR,CAAC,EAAE,IAAA,CAAA;AAC/B,QAAA,IAAI,CAACM,EAAE,CAACG,CAAC,GAAGR,GAAGS,GAAG,CAACT,EAAGU,CAAAA,GAAG,CAAC,IAAI,CAACZ,QAAQ,CAAG,EAAA,IAAI,CAACQ,KAAK,CAAA;;;AAGpD,QAAA,IAAI,CAACD,EAAE,CAACM,EAAE,GAAGX,GAAGY,GAAG,CAACZ,EAAGa,CAAAA,GAAG,CAACb,EAAGc,CAAAA,GAAG,CAAC,IAAI,CAACN,CAAC,EAAE,EAAA,CAAA,CAAA,CAAA;QAC1C,IAAI,CAACH,EAAE,CAACU,EAAE,GAAGf,EAAGY,CAAAA,GAAG,CAACZ,EAAGa,CAAAA,GAAG,CAACb,EAAGc,CAAAA,GAAG,CAACd,EAAGS,CAAAA,GAAG,CAAC,IAAI,CAACD,CAAC,EAAE,CAAI,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA;AACrD,QAAA,IAAI,CAACQ,OAAO,CAAChB,GAAGS,GAAG,CAACT,GAAGiB,GAAG,CAAC,IAAI,CAACN,EAAE,EAAE,IAAI,CAACI,EAAE,CAAG,EAAA,IAAI,CAACT,KAAK,CAAA,CAAA;AAC1D,KAAA,CAAA;AACA,IAAA,OAAON,GAAGkB,cAAc,EAAE,CAAChB,QAAAA,CAAS,CAACJ,QAAUC,EAAAA,CAAAA,CAAAA;AACjD;;;;"}
|
package/dist/shaders/shadow.js
CHANGED
|
@@ -426,15 +426,25 @@ function getShadowMapSize(scope) {
|
|
|
426
426
|
], function() {
|
|
427
427
|
this.$l.dx = pb.dpdx(this.coords);
|
|
428
428
|
this.$l.dy = pb.dpdy(this.coords);
|
|
429
|
-
this.$l.biasMultiply = pb.float(1);
|
|
430
429
|
this.$l.uv = pb.vec2(pb.sub(pb.mul(this.dy.y, this.dx.z), pb.mul(this.dx.y, this.dy.z)), pb.sub(pb.mul(this.dx.x, this.dy.z), pb.mul(this.dy.x, this.dx.z)));
|
|
431
|
-
|
|
432
|
-
//
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
this.$
|
|
430
|
+
// At grazing incidence the shadow-space footprint of a pixel collapses and
|
|
431
|
+
// this determinant tends to zero, so the gradient blows up (and flips sign
|
|
432
|
+
// across neighbouring pixels). Rather than clamp the fallout downstream,
|
|
433
|
+
// report "no usable plane" and let the caller fall back to the constant
|
|
434
|
+
// depth bias plus normal offset.
|
|
435
|
+
this.$l.det = pb.sub(pb.mul(this.dx.x, this.dy.y), pb.mul(this.dx.y, this.dy.x));
|
|
436
|
+
this.$if(pb.lessThan(pb.abs(this.det), 1e-8), function() {
|
|
437
|
+
this.$return(pb.vec3(0));
|
|
438
|
+
});
|
|
439
|
+
this.uv = pb.div(this.uv, this.det);
|
|
440
|
+
// `.z` used to carry a scalar "static bias" capped at a hardcoded 0.01.
|
|
441
|
+
// That constant came from a Unity shader operating on perspective (non
|
|
442
|
+
// linear) shadow depth; for a directional light's orthographic camera the
|
|
443
|
+
// depth is linear, so 0.01 means 1% of the whole depth range - metres of
|
|
444
|
+
// world-space push on a typical scene, which is what produced the light
|
|
445
|
+
// leaks around the terminator. Constant depth bias plus normal offset cover
|
|
446
|
+
// this properly now, so only the plane gradient survives.
|
|
447
|
+
this.$return(pb.vec3(this.uv, 0));
|
|
438
448
|
});
|
|
439
449
|
return pb.getGlobalScope()[funcNameComputeReceiverPlaneDepthBias](texCoord);
|
|
440
450
|
}
|
|
@@ -805,22 +815,27 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
805
815
|
depthBias
|
|
806
816
|
] : []);
|
|
807
817
|
}
|
|
808
|
-
/**
|
|
818
|
+
/**
|
|
819
|
+
* Fixed-kernel PCF.
|
|
820
|
+
*
|
|
821
|
+
* @remarks
|
|
822
|
+
* Unlike {@link filterShadowPCSS} and {@link filterShadowPoissonDisc}, this
|
|
823
|
+
* filter never applied the receiver plane depth gradient per tap - it only used
|
|
824
|
+
* the scalar `.z` guard, which has been removed (see
|
|
825
|
+
* {@link computeReceiverPlaneDepthBias}). Over a kernel this narrow the plane
|
|
826
|
+
* correction is worth little, and the constant depth bias plus normal offset
|
|
827
|
+
* cover the receiver slope, so the parameter is gone rather than left inert.
|
|
828
|
+
* @internal
|
|
829
|
+
*/ function filterShadowPCF(scope, lightType, shadowMapFormat, kernelSize, texCoord, cascade) {
|
|
809
830
|
const funcNameFilterShadowPCF = `lib_filterShadowPCF${kernelSize}x${kernelSize}`;
|
|
810
831
|
const pb = scope.$builder;
|
|
811
832
|
pb.func(funcNameFilterShadowPCF, [
|
|
812
833
|
pb.vec4('texCoord'),
|
|
813
|
-
...receiverPlaneDepthBias ? [
|
|
814
|
-
pb.vec3('receiverPlaneDepthBias')
|
|
815
|
-
] : [],
|
|
816
834
|
...cascade ? [
|
|
817
835
|
pb.int('cascade')
|
|
818
836
|
] : []
|
|
819
837
|
], function() {
|
|
820
838
|
this.$l.lightDepth = this.texCoord.z;
|
|
821
|
-
if (receiverPlaneDepthBias) {
|
|
822
|
-
this.lightDepth = REVERSE_Z ? pb.add(this.lightDepth, this.receiverPlaneDepthBias.z) : pb.sub(this.lightDepth, this.receiverPlaneDepthBias.z);
|
|
823
|
-
}
|
|
824
839
|
const shadowMapTexelSize = getShadowMapTexelSize(this);
|
|
825
840
|
this.$l.uv = pb.add(pb.mul(this.texCoord.xy, pb.vec2(getShadowMapSize(this))), pb.vec2(0));
|
|
826
841
|
this.$l.st = pb.fract(this.uv);
|
|
@@ -880,9 +895,7 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
880
895
|
}
|
|
881
896
|
this.$return(this.shadow);
|
|
882
897
|
});
|
|
883
|
-
return pb.getGlobalScope()[funcNameFilterShadowPCF](texCoord, ...
|
|
884
|
-
receiverPlaneDepthBias
|
|
885
|
-
] : [], ...cascade ? [
|
|
898
|
+
return pb.getGlobalScope()[funcNameFilterShadowPCF](texCoord, ...cascade ? [
|
|
886
899
|
cascade
|
|
887
900
|
] : []);
|
|
888
901
|
}
|
|
@@ -941,9 +954,8 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
941
954
|
// spot receivers and their stored depth use a linear encoding.
|
|
942
955
|
const deviceEncoded = isDeviceDepthShadow(lightType);
|
|
943
956
|
this.$l.lightDepth = this.texCoord.z;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
957
|
+
// The scalar `.z` guard is gone (see computeReceiverPlaneDepthBias); the
|
|
958
|
+
// per-tap plane gradient below is the part that was ever load bearing.
|
|
947
959
|
this.$l.sampleBounds = pb.vec4(0, 0, 1, 1);
|
|
948
960
|
if (cascade && getDevice().type === 'webgl' && numCascades > 1) {
|
|
949
961
|
const numCols = numCascades > 1 ? 2 : 1;
|