@zephyr3d/editor 0.3.4 → 0.3.5
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/assets/{index-DzQzWsCG.js → index-DlnbO59X.js} +2 -2
- package/dist/assistant/zephyr-types-index.json +9 -10
- package/dist/index.html +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js +13 -12
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_base.js +152 -152
- package/dist/modules/zephyr3d_base.js.map +1 -1
- package/dist/modules/zephyr3d_device.js +15 -15
- package/dist/modules/zephyr3d_device.js.map +1 -1
- package/dist/modules/zephyr3d_loaders.js +6 -6
- package/dist/modules/zephyr3d_loaders.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +1382 -1385
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js +7 -6
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +6 -6
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/base/dist/vfs/common.js +152 -152
- package/dist/vendor/zephyr3d/base/dist/vfs/common.js.map +1 -1
- package/dist/vendor/zephyr3d/device/dist/device.js +15 -15
- package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
- package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js +6 -6
- package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +191 -194
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js +19 -19
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js +131 -131
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js +119 -119
- package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js +62 -62
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js +13 -13
- package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +201 -201
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/index.d.ts +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js +4 -4
- package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js +11 -11
- package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js +284 -284
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js +9 -9
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js +5 -5
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js +7 -7
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js +45 -45
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +275 -275
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/package.json +3 -3
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -31,9 +31,9 @@ const UNIFORM_NAME_BONE_TEXTURE_SIZE = 'Z_UniformBoneTexSize';
|
|
|
31
31
|
const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
|
|
32
32
|
const UNIFORM_NAME_MORPH_DATA = 'Z_UniformMorphData';
|
|
33
33
|
const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
34
|
-
/**
|
|
35
|
-
* Helper shader functions for the builtin material system
|
|
36
|
-
* @public
|
|
34
|
+
/**
|
|
35
|
+
* Helper shader functions for the builtin material system
|
|
36
|
+
* @public
|
|
37
37
|
*/ class ShaderHelper {
|
|
38
38
|
static BILLBOARD_SPHERICAL = 1;
|
|
39
39
|
static BILLBOARD_SYLINDRAL = 2;
|
|
@@ -124,25 +124,25 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
124
124
|
}
|
|
125
125
|
return bindGroupLayout;
|
|
126
126
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Prepares the fragment shader which is going to be used in our material system
|
|
129
|
-
*
|
|
130
|
-
* @remarks
|
|
131
|
-
* This function will setup all nessesary uniforms acoording to the drawing context
|
|
132
|
-
*
|
|
133
|
-
* @param pb - The program builder
|
|
134
|
-
* @param ctx - The drawing context
|
|
127
|
+
/**
|
|
128
|
+
* Prepares the fragment shader which is going to be used in our material system
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* This function will setup all nessesary uniforms acoording to the drawing context
|
|
132
|
+
*
|
|
133
|
+
* @param pb - The program builder
|
|
134
|
+
* @param ctx - The drawing context
|
|
135
135
|
*/ static prepareFragmentShader(pb, ctx) {
|
|
136
136
|
this.setupGlobalUniforms(pb, ctx);
|
|
137
137
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Prepares the vertex shader which is going to be used in our material system
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* This function will setup all nessesary uniforms according to the drawing context
|
|
143
|
-
*
|
|
144
|
-
* @param pb - The program builder
|
|
145
|
-
* @param ctx - The drawing context
|
|
138
|
+
/**
|
|
139
|
+
* Prepares the vertex shader which is going to be used in our material system
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* This function will setup all nessesary uniforms according to the drawing context
|
|
143
|
+
*
|
|
144
|
+
* @param pb - The program builder
|
|
145
|
+
* @param ctx - The drawing context
|
|
146
146
|
*/ static prepareVertexShader(pb, ctx) {
|
|
147
147
|
this.setupGlobalUniforms(pb, ctx);
|
|
148
148
|
this.prepareVertexShaderCommon(pb, ctx);
|
|
@@ -254,30 +254,30 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
/**
|
|
258
|
-
* This function checks if the shader needs to process skeletal animation.
|
|
259
|
-
*
|
|
260
|
-
* @param scope - Current shader scope
|
|
261
|
-
*
|
|
262
|
-
* @returns true if the shader needs to process skeletal animation, otherwise false.
|
|
257
|
+
/**
|
|
258
|
+
* This function checks if the shader needs to process skeletal animation.
|
|
259
|
+
*
|
|
260
|
+
* @param scope - Current shader scope
|
|
261
|
+
*
|
|
262
|
+
* @returns true if the shader needs to process skeletal animation, otherwise false.
|
|
263
263
|
*/ static hasSkinning(scope) {
|
|
264
264
|
return !!scope[UNIFORM_NAME_BONE_MATRICES];
|
|
265
265
|
}
|
|
266
|
-
/**
|
|
267
|
-
* This function checks if the shader needs to process morph target animation.
|
|
268
|
-
*
|
|
269
|
-
* @param scope - Current shader scope
|
|
270
|
-
*
|
|
271
|
-
* @returns true if the shader needs to process morph target animation, otherwise false.
|
|
266
|
+
/**
|
|
267
|
+
* This function checks if the shader needs to process morph target animation.
|
|
268
|
+
*
|
|
269
|
+
* @param scope - Current shader scope
|
|
270
|
+
*
|
|
271
|
+
* @returns true if the shader needs to process morph target animation, otherwise false.
|
|
272
272
|
*/ static hasMorphing(scope) {
|
|
273
273
|
return !!scope[UNIFORM_NAME_MORPH_DATA];
|
|
274
274
|
}
|
|
275
|
-
/**
|
|
276
|
-
* Calculate skinning matrix for current vertex
|
|
277
|
-
*
|
|
278
|
-
* @param scope - Current shader scope
|
|
279
|
-
*
|
|
280
|
-
* @returns Skinning matrix for current vertex, or null if there is not skeletal animation
|
|
275
|
+
/**
|
|
276
|
+
* Calculate skinning matrix for current vertex
|
|
277
|
+
*
|
|
278
|
+
* @param scope - Current shader scope
|
|
279
|
+
*
|
|
280
|
+
* @returns Skinning matrix for current vertex, or null if there is not skeletal animation
|
|
281
281
|
*/ static calculateSkinMatrix(scope) {
|
|
282
282
|
if (!this.hasSkinning(scope)) {
|
|
283
283
|
return null;
|
|
@@ -432,12 +432,12 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
432
432
|
scope.$l[that.SKIN_PREV_MATRIX_NAME] = scope[funcNameGetSkinningMatrix](scope[that.SKIN_BONE_OFFSET].y);
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
/**
|
|
436
|
-
* Calculates the vertex position of type vec3 in object space
|
|
437
|
-
*
|
|
438
|
-
* @param scope - Current shader scope
|
|
439
|
-
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
440
|
-
* @returns The calculated vertex position in object space, or null if pos is null
|
|
435
|
+
/**
|
|
436
|
+
* Calculates the vertex position of type vec3 in object space
|
|
437
|
+
*
|
|
438
|
+
* @param scope - Current shader scope
|
|
439
|
+
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
440
|
+
* @returns The calculated vertex position in object space, or null if pos is null
|
|
441
441
|
*/ static resolveVertexPosition(scope) {
|
|
442
442
|
const pb = scope.$builder;
|
|
443
443
|
if (pb.shaderKind !== 'vertex') {
|
|
@@ -479,12 +479,12 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
479
479
|
});
|
|
480
480
|
return scope[that.SKIN_MATRIX_NAME] && scope[that.SKIN_PREV_MATRIX_NAME] ? scope.Z_resolveVertexPosition(scope[that.SKIN_MATRIX_NAME], scope[that.SKIN_PREV_MATRIX_NAME]) : scope[that.SKIN_MATRIX_NAME] ? scope.Z_resolveVertexPosition(scope[that.SKIN_MATRIX_NAME]) : scope.Z_resolveVertexPosition();
|
|
481
481
|
}
|
|
482
|
-
/**
|
|
483
|
-
* Resolve motion vector
|
|
484
|
-
*
|
|
485
|
-
* @param scope - Current shader scope
|
|
486
|
-
* @param worldPos - Current object position in world space
|
|
487
|
-
* @param prevWorldPos - Previous object position in world space
|
|
482
|
+
/**
|
|
483
|
+
* Resolve motion vector
|
|
484
|
+
*
|
|
485
|
+
* @param scope - Current shader scope
|
|
486
|
+
* @param worldPos - Current object position in world space
|
|
487
|
+
* @param prevWorldPos - Previous object position in world space
|
|
488
488
|
*/ static resolveMotionVector(scope, worldPos, prevWorldPos) {
|
|
489
489
|
const that = this;
|
|
490
490
|
const pb = scope.$builder;
|
|
@@ -495,13 +495,13 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
495
495
|
scope.$outputs.zMotionVectorPosPrev = pb.mul(prevUnjitteredVPMatrix, pb.vec4(prevWorldPos.xyz, 1));
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
/**
|
|
499
|
-
* Calculates the normal vector of type vec3 in object space
|
|
500
|
-
*
|
|
501
|
-
* @param scope - Current shader scope
|
|
502
|
-
* @param normal - Vertex normal input, must be type of vec3, null if no vertex normal input
|
|
503
|
-
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
504
|
-
* @returns The calculated normal vector in object space, or null if normal is null
|
|
498
|
+
/**
|
|
499
|
+
* Calculates the normal vector of type vec3 in object space
|
|
500
|
+
*
|
|
501
|
+
* @param scope - Current shader scope
|
|
502
|
+
* @param normal - Vertex normal input, must be type of vec3, null if no vertex normal input
|
|
503
|
+
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
504
|
+
* @returns The calculated normal vector in object space, or null if normal is null
|
|
505
505
|
*/ static resolveVertexNormal(scope, normal) {
|
|
506
506
|
const pb = scope.$builder;
|
|
507
507
|
if (pb.shaderKind !== 'vertex') {
|
|
@@ -526,13 +526,13 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
526
526
|
return normal;
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
/**
|
|
530
|
-
* Calculates the tangent vector of type vec3 in object space
|
|
531
|
-
*
|
|
532
|
-
* @param scope - Current shader scope
|
|
533
|
-
* @param tangent - Vertex tangent input, must be type of vec4, null if no vertex tangent input
|
|
534
|
-
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
535
|
-
* @returns The calculated tangent vector of type vec4 in object space, or null if tangent is null
|
|
529
|
+
/**
|
|
530
|
+
* Calculates the tangent vector of type vec3 in object space
|
|
531
|
+
*
|
|
532
|
+
* @param scope - Current shader scope
|
|
533
|
+
* @param tangent - Vertex tangent input, must be type of vec4, null if no vertex tangent input
|
|
534
|
+
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
535
|
+
* @returns The calculated tangent vector of type vec4 in object space, or null if tangent is null
|
|
536
536
|
*/ static resolveVertexTangent(scope, tangent) {
|
|
537
537
|
const pb = scope.$builder;
|
|
538
538
|
if (pb.shaderKind !== 'vertex') {
|
|
@@ -557,18 +557,18 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
557
557
|
return tangent;
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
/**
|
|
561
|
-
* Gets the uniform variable of type mat4 which holds the world matrix of current object to be drawn
|
|
562
|
-
* @param scope - Current shader scope
|
|
563
|
-
* @returns The world matrix of current object to be drawn
|
|
560
|
+
/**
|
|
561
|
+
* Gets the uniform variable of type mat4 which holds the world matrix of current object to be drawn
|
|
562
|
+
* @param scope - Current shader scope
|
|
563
|
+
* @returns The world matrix of current object to be drawn
|
|
564
564
|
*/ static getWorldMatrix(scope) {
|
|
565
565
|
const pb = scope.$builder;
|
|
566
566
|
return scope[UNIFORM_NAME_WORLD_MATRIX] ?? pb.mat4(this.getInstancedUniform(scope, 0), this.getInstancedUniform(scope, 1), this.getInstancedUniform(scope, 2), this.getInstancedUniform(scope, 3));
|
|
567
567
|
}
|
|
568
|
-
/**
|
|
569
|
-
* Gets the uniform variable of type mat4 which holds the world matrix at previous frame of current object to be drawn
|
|
570
|
-
* @param scope - Current shader scope
|
|
571
|
-
* @returns The world matrix at previous frame of current object to be drawn
|
|
568
|
+
/**
|
|
569
|
+
* Gets the uniform variable of type mat4 which holds the world matrix at previous frame of current object to be drawn
|
|
570
|
+
* @param scope - Current shader scope
|
|
571
|
+
* @returns The world matrix at previous frame of current object to be drawn
|
|
572
572
|
*/ static getPrevWorldMatrix(scope) {
|
|
573
573
|
const pb = scope.$builder;
|
|
574
574
|
const that = this;
|
|
@@ -599,28 +599,28 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
599
599
|
return scope.Z_getPrevWorldMatrix(framestamp);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
/**
|
|
603
|
-
* Gets the instance uniform value of type vec4 by uniform index
|
|
604
|
-
* @param scope - Current shader scope
|
|
605
|
-
* @returns instance uniform value
|
|
602
|
+
/**
|
|
603
|
+
* Gets the instance uniform value of type vec4 by uniform index
|
|
604
|
+
* @param scope - Current shader scope
|
|
605
|
+
* @returns instance uniform value
|
|
606
606
|
*/ static getInstancedUniform(scope, uniformIndex) {
|
|
607
607
|
const pb = scope.$builder;
|
|
608
608
|
return scope[UNIFORM_NAME_INSTANCE_DATA].at(pb.add(pb.mul(scope[UNIFORM_NAME_INSTANCE_DATA_STRIDE], pb.uint(scope.$builtins.instanceIndex)), scope[UNIFORM_NAME_INSTANCE_DATA_OFFSET], pb.uint(uniformIndex)));
|
|
609
609
|
}
|
|
610
|
-
/**
|
|
611
|
-
* Gets the uniform variable of type mat4 which holds the normal matrix of current object to be drawn
|
|
612
|
-
*
|
|
613
|
-
* @param scope - Current shader scope
|
|
614
|
-
* @returns The normal matrix of current object to be drawn
|
|
610
|
+
/**
|
|
611
|
+
* Gets the uniform variable of type mat4 which holds the normal matrix of current object to be drawn
|
|
612
|
+
*
|
|
613
|
+
* @param scope - Current shader scope
|
|
614
|
+
* @returns The normal matrix of current object to be drawn
|
|
615
615
|
*/ static getNormalMatrix(scope) {
|
|
616
616
|
return this.getWorldMatrix(scope);
|
|
617
617
|
}
|
|
618
|
-
/**
|
|
619
|
-
* Vertex shader drawable stuff
|
|
620
|
-
*
|
|
621
|
-
* @param scope - Current shader scope
|
|
622
|
-
* @param skinning - true if skinning is used, otherwise false.
|
|
623
|
-
* @param instanced - true if instancing is used, otherwise false.
|
|
618
|
+
/**
|
|
619
|
+
* Vertex shader drawable stuff
|
|
620
|
+
*
|
|
621
|
+
* @param scope - Current shader scope
|
|
622
|
+
* @param skinning - true if skinning is used, otherwise false.
|
|
623
|
+
* @param instanced - true if instancing is used, otherwise false.
|
|
624
624
|
*/ static vertexShaderDrawableStuff(scope, skinning, morphing, instanced) {
|
|
625
625
|
const pb = scope.$builder;
|
|
626
626
|
if (instanced) {
|
|
@@ -751,144 +751,144 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
751
751
|
ctx.env.light.envLight.updateBindGroup(bindGroup);
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
|
-
/**
|
|
755
|
-
* Gets the uniform variable of type float which holds the strength of the environment light
|
|
756
|
-
*
|
|
757
|
-
* @remarks
|
|
758
|
-
* This function can only be used in the fragment shader
|
|
759
|
-
*
|
|
760
|
-
* @param scope - Current shader scope
|
|
761
|
-
* @returns The uniform variable of which presents the strength of the environment light
|
|
754
|
+
/**
|
|
755
|
+
* Gets the uniform variable of type float which holds the strength of the environment light
|
|
756
|
+
*
|
|
757
|
+
* @remarks
|
|
758
|
+
* This function can only be used in the fragment shader
|
|
759
|
+
*
|
|
760
|
+
* @param scope - Current shader scope
|
|
761
|
+
* @returns The uniform variable of which presents the strength of the environment light
|
|
762
762
|
*/ static getEnvLightStrength(scope) {
|
|
763
763
|
return scope.light.envLightStrength;
|
|
764
764
|
}
|
|
765
|
-
/**
|
|
766
|
-
* Gets the uniform variable of type float which holds the specular strength of the environment light
|
|
767
|
-
*
|
|
768
|
-
* @remarks
|
|
769
|
-
* This function can only be used in the fragment shader
|
|
770
|
-
*
|
|
771
|
-
* @param scope - Current shader scope
|
|
772
|
-
* @returns The uniform variable which presents the specular strength of the environment light
|
|
765
|
+
/**
|
|
766
|
+
* Gets the uniform variable of type float which holds the specular strength of the environment light
|
|
767
|
+
*
|
|
768
|
+
* @remarks
|
|
769
|
+
* This function can only be used in the fragment shader
|
|
770
|
+
*
|
|
771
|
+
* @param scope - Current shader scope
|
|
772
|
+
* @returns The uniform variable which presents the specular strength of the environment light
|
|
773
773
|
*/ static getEnvLightSpecularStrength(scope) {
|
|
774
774
|
return scope.light.envLightSpecularStrength ?? scope.$builder.float(1);
|
|
775
775
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Gets current scene color texture
|
|
778
|
-
* @param scope - Current shader scope
|
|
779
|
-
* @returns current scene color texture
|
|
776
|
+
/**
|
|
777
|
+
* Gets current scene color texture
|
|
778
|
+
* @param scope - Current shader scope
|
|
779
|
+
* @returns current scene color texture
|
|
780
780
|
*/ static getSceneColorTexture(scope) {
|
|
781
781
|
return scope[UNIFORM_NAME_SCENE_COLOR_MAP];
|
|
782
782
|
}
|
|
783
|
-
/**
|
|
784
|
-
* Gets the size of current scene color texture
|
|
785
|
-
* @param scope - Current shader scope
|
|
786
|
-
* @returns The size of current scene color texture
|
|
783
|
+
/**
|
|
784
|
+
* Gets the size of current scene color texture
|
|
785
|
+
* @param scope - Current shader scope
|
|
786
|
+
* @returns The size of current scene color texture
|
|
787
787
|
*/ static getSceneColorTextureSize(scope) {
|
|
788
788
|
return scope[UNIFORM_NAME_SCENE_COLOR_MAP_SIZE];
|
|
789
789
|
}
|
|
790
|
-
/**
|
|
791
|
-
* Gets current linear depth texture
|
|
792
|
-
* @param scope - Current shader scope
|
|
793
|
-
* @returns current linear depth texture
|
|
790
|
+
/**
|
|
791
|
+
* Gets current linear depth texture
|
|
792
|
+
* @param scope - Current shader scope
|
|
793
|
+
* @returns current linear depth texture
|
|
794
794
|
*/ static getLinearDepthTexture(scope) {
|
|
795
795
|
return scope[UNIFORM_NAME_LINEAR_DEPTH_MAP];
|
|
796
796
|
}
|
|
797
|
-
/**
|
|
798
|
-
* Gets the size of current linear depth texture
|
|
799
|
-
* @param scope - Current shader scope
|
|
800
|
-
* @returns The size of current linear depth texture
|
|
797
|
+
/**
|
|
798
|
+
* Gets the size of current linear depth texture
|
|
799
|
+
* @param scope - Current shader scope
|
|
800
|
+
* @returns The size of current linear depth texture
|
|
801
801
|
*/ static getLinearDepthTextureSize(scope) {
|
|
802
802
|
return scope[UNIFORM_NAME_LINEAR_DEPTH_MAP_SIZE];
|
|
803
803
|
}
|
|
804
|
-
/**
|
|
805
|
-
* Gets current HiZ depth texture
|
|
806
|
-
* @param scope - Current shader scope
|
|
807
|
-
* @returns current HiZ depth texture
|
|
804
|
+
/**
|
|
805
|
+
* Gets current HiZ depth texture
|
|
806
|
+
* @param scope - Current shader scope
|
|
807
|
+
* @returns current HiZ depth texture
|
|
808
808
|
*/ static getHiZDepthTexture(scope) {
|
|
809
809
|
return scope[UNIFORM_NAME_HIZ_DEPTH_MAP];
|
|
810
810
|
}
|
|
811
|
-
/**
|
|
812
|
-
* Gets the size of current HiZ depth texture
|
|
813
|
-
* @param scope - Current shader scope
|
|
814
|
-
* @returns The size of current HiZ depth texture
|
|
811
|
+
/**
|
|
812
|
+
* Gets the size of current HiZ depth texture
|
|
813
|
+
* @param scope - Current shader scope
|
|
814
|
+
* @returns The size of current HiZ depth texture
|
|
815
815
|
*/ static getHiZDepthTextureSize(scope) {
|
|
816
816
|
return scope[UNIFORM_NAME_HIZ_DEPTH_MAP_INFO].xy;
|
|
817
817
|
}
|
|
818
|
-
/**
|
|
819
|
-
* Gets the mipmap levels count of current HiZ depth texture
|
|
820
|
-
* @param scope - Current shader scope
|
|
821
|
-
* @returns The mipmap levels count of current HiZ depth texture
|
|
818
|
+
/**
|
|
819
|
+
* Gets the mipmap levels count of current HiZ depth texture
|
|
820
|
+
* @param scope - Current shader scope
|
|
821
|
+
* @returns The mipmap levels count of current HiZ depth texture
|
|
822
822
|
*/ static getHiZDepthTextureMipLevelCount(scope) {
|
|
823
823
|
return scope[UNIFORM_NAME_HIZ_DEPTH_MAP_INFO].z;
|
|
824
824
|
}
|
|
825
|
-
/**
|
|
826
|
-
* Gets current baked skybox texture
|
|
827
|
-
* @param scope - Current shader scope
|
|
828
|
-
* @returns current baked skybox texture
|
|
825
|
+
/**
|
|
826
|
+
* Gets current baked skybox texture
|
|
827
|
+
* @param scope - Current shader scope
|
|
828
|
+
* @returns current baked skybox texture
|
|
829
829
|
*/ static getBakedSkyTexture(scope) {
|
|
830
830
|
return scope[UNIFORM_NAME_BAKED_SKY_MAP];
|
|
831
831
|
}
|
|
832
|
-
/**
|
|
833
|
-
* Gets the elapsed time in seconds
|
|
834
|
-
* @param scope - Current shader scope
|
|
835
|
-
* @returns The elapsed time in seconds
|
|
832
|
+
/**
|
|
833
|
+
* Gets the elapsed time in seconds
|
|
834
|
+
* @param scope - Current shader scope
|
|
835
|
+
* @returns The elapsed time in seconds
|
|
836
836
|
*/ static getElapsedTime(scope) {
|
|
837
837
|
return scope.camera.elapsedTime;
|
|
838
838
|
}
|
|
839
|
-
/**
|
|
840
|
-
* Gets the elapsed time since last frame in seconds
|
|
841
|
-
* @param scope - Current shader scope
|
|
842
|
-
* @returns The elapsed time since last frame in seconds
|
|
839
|
+
/**
|
|
840
|
+
* Gets the elapsed time since last frame in seconds
|
|
841
|
+
* @param scope - Current shader scope
|
|
842
|
+
* @returns The elapsed time since last frame in seconds
|
|
843
843
|
*/ static getElapsedTimeFrame(scope) {
|
|
844
844
|
return scope.camera.frameDeltaTime;
|
|
845
845
|
}
|
|
846
|
-
/**
|
|
847
|
-
* Gets the uniform variable of type vec3 which holds the camera position
|
|
848
|
-
* @param scope - Current shader scope
|
|
849
|
-
* @returns The camera position
|
|
846
|
+
/**
|
|
847
|
+
* Gets the uniform variable of type vec3 which holds the camera position
|
|
848
|
+
* @param scope - Current shader scope
|
|
849
|
+
* @returns The camera position
|
|
850
850
|
*/ static getCameraPosition(scope) {
|
|
851
851
|
return scope.camera.position.xyz;
|
|
852
852
|
}
|
|
853
|
-
/**
|
|
854
|
-
* Gets the uniform variable of type float which holds the roughness factor
|
|
855
|
-
* @param scope - Current shader scope
|
|
856
|
-
* @returns The roughness factor
|
|
853
|
+
/**
|
|
854
|
+
* Gets the uniform variable of type float which holds the roughness factor
|
|
855
|
+
* @param scope - Current shader scope
|
|
856
|
+
* @returns The roughness factor
|
|
857
857
|
*/ static getCameraRoughnessFactor(scope) {
|
|
858
858
|
return scope.camera.roughnessFactor;
|
|
859
859
|
}
|
|
860
|
-
/**
|
|
861
|
-
* Gets framebuffer size for rendering
|
|
862
|
-
* @param scope - Current shader scope
|
|
863
|
-
* @returns The roughness factor
|
|
860
|
+
/**
|
|
861
|
+
* Gets framebuffer size for rendering
|
|
862
|
+
* @param scope - Current shader scope
|
|
863
|
+
* @returns The roughness factor
|
|
864
864
|
*/ static getRenderSize(scope) {
|
|
865
865
|
return scope.camera.renderSize;
|
|
866
866
|
}
|
|
867
|
-
/**
|
|
868
|
-
* Gets the uniform variable of type uint which holds the framestamp
|
|
869
|
-
* @param scope - Current shader scope
|
|
870
|
-
* @returns The framestamp
|
|
867
|
+
/**
|
|
868
|
+
* Gets the uniform variable of type uint which holds the framestamp
|
|
869
|
+
* @param scope - Current shader scope
|
|
870
|
+
* @returns The framestamp
|
|
871
871
|
*/ static getFramestamp(scope) {
|
|
872
872
|
return scope.camera.framestamp;
|
|
873
873
|
}
|
|
874
|
-
/**
|
|
875
|
-
* Gets the clip plane flag
|
|
876
|
-
* @param scope - Current shader scope
|
|
877
|
-
* @returns A float value of 1 indices the clip plane presents, otherwise 0
|
|
874
|
+
/**
|
|
875
|
+
* Gets the clip plane flag
|
|
876
|
+
* @param scope - Current shader scope
|
|
877
|
+
* @returns A float value of 1 indices the clip plane presents, otherwise 0
|
|
878
878
|
*/ static getCameraClipPlaneFlag(scope) {
|
|
879
879
|
return scope.camera.position.w;
|
|
880
880
|
}
|
|
881
|
-
/**
|
|
882
|
-
* Gets the clip plane
|
|
883
|
-
* @param scope - Current shader scope
|
|
884
|
-
* @returns A vec4 presents the clip plane
|
|
881
|
+
/**
|
|
882
|
+
* Gets the clip plane
|
|
883
|
+
* @param scope - Current shader scope
|
|
884
|
+
* @returns A vec4 presents the clip plane
|
|
885
885
|
*/ static getCameraClipPlane(scope) {
|
|
886
886
|
return scope.camera.clipPlane;
|
|
887
887
|
}
|
|
888
|
-
/**
|
|
889
|
-
* Gets the uniform variable of type vec4 which holds the camera parameters
|
|
890
|
-
* @param scope - Current shader scope
|
|
891
|
-
* @returns The camera parameters
|
|
888
|
+
/**
|
|
889
|
+
* Gets the uniform variable of type vec4 which holds the camera parameters
|
|
890
|
+
* @param scope - Current shader scope
|
|
891
|
+
* @returns The camera parameters
|
|
892
892
|
*/ static getCameraParams(scope) {
|
|
893
893
|
return scope.camera.params;
|
|
894
894
|
}
|
|
@@ -901,87 +901,87 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
901
901
|
/** @internal */ static getClusteredLightIndexTexture(scope) {
|
|
902
902
|
return scope[UNIFORM_NAME_LIGHT_INDEX_TEXTURE];
|
|
903
903
|
}
|
|
904
|
-
/**
|
|
905
|
-
* Gets the uniform variable that contains atmosphere parameters
|
|
906
|
-
* @param scope - Current shader scope
|
|
907
|
-
* @returns The atmosphere parameters
|
|
904
|
+
/**
|
|
905
|
+
* Gets the uniform variable that contains atmosphere parameters
|
|
906
|
+
* @param scope - Current shader scope
|
|
907
|
+
* @returns The atmosphere parameters
|
|
908
908
|
*/ static getAtmosphereParams(scope) {
|
|
909
909
|
return scope.fog.atmosphereParams;
|
|
910
910
|
}
|
|
911
|
-
/**
|
|
912
|
-
* Gets the aerial perspective LUT
|
|
913
|
-
* @param scope - Current shader scope
|
|
914
|
-
* @returns The aerial perspective LUT texture
|
|
911
|
+
/**
|
|
912
|
+
* Gets the aerial perspective LUT
|
|
913
|
+
* @param scope - Current shader scope
|
|
914
|
+
* @returns The aerial perspective LUT texture
|
|
915
915
|
*/ static getAerialPerspectiveLUT(scope) {
|
|
916
916
|
return scope[UNIFORM_NAME_AERIALPERSPECTIVE_LUT];
|
|
917
917
|
}
|
|
918
|
-
/**
|
|
919
|
-
* Gets the uniform variable of type mat4 which holds the view projection matrix of current camera
|
|
920
|
-
* @param scope - Current shader scope
|
|
921
|
-
* @returns The view projection matrix of current camera
|
|
918
|
+
/**
|
|
919
|
+
* Gets the uniform variable of type mat4 which holds the view projection matrix of current camera
|
|
920
|
+
* @param scope - Current shader scope
|
|
921
|
+
* @returns The view projection matrix of current camera
|
|
922
922
|
*/ static getViewProjectionMatrix(scope) {
|
|
923
923
|
return scope.camera.viewProjectionMatrix;
|
|
924
924
|
}
|
|
925
|
-
/**
|
|
926
|
-
* Gets the uniform variable of type mat4 which holds the inversed view projection matrix of current camera
|
|
927
|
-
* @param scope - Current shader scope
|
|
928
|
-
* @returns The inversed view projection matrix of current camera
|
|
925
|
+
/**
|
|
926
|
+
* Gets the uniform variable of type mat4 which holds the inversed view projection matrix of current camera
|
|
927
|
+
* @param scope - Current shader scope
|
|
928
|
+
* @returns The inversed view projection matrix of current camera
|
|
929
929
|
*/ static getInvViewProjectionMatrix(scope) {
|
|
930
930
|
return scope.camera.invViewProjectionMatrix;
|
|
931
931
|
}
|
|
932
|
-
/**
|
|
933
|
-
* Gets the uniform variable of type mat4 which holds the projection matrix of current camera
|
|
934
|
-
* @param scope - Current shader scope
|
|
935
|
-
* @returns The projection matrix of current camera
|
|
932
|
+
/**
|
|
933
|
+
* Gets the uniform variable of type mat4 which holds the projection matrix of current camera
|
|
934
|
+
* @param scope - Current shader scope
|
|
935
|
+
* @returns The projection matrix of current camera
|
|
936
936
|
*/ static getProjectionMatrix(scope) {
|
|
937
937
|
return scope.camera.projectionMatrix;
|
|
938
938
|
}
|
|
939
|
-
/**
|
|
940
|
-
* Gets the uniform variable of type mat4 which holds the inversed projection matrix of current camera
|
|
941
|
-
* @param scope - Current shader scope
|
|
942
|
-
* @returns The inversed projection matrix of current camera
|
|
939
|
+
/**
|
|
940
|
+
* Gets the uniform variable of type mat4 which holds the inversed projection matrix of current camera
|
|
941
|
+
* @param scope - Current shader scope
|
|
942
|
+
* @returns The inversed projection matrix of current camera
|
|
943
943
|
*/ static getInvProjectionMatrix(scope) {
|
|
944
944
|
return scope.camera.invProjectionMatrix;
|
|
945
945
|
}
|
|
946
|
-
/**
|
|
947
|
-
* Gets the uniform variable of type mat4 which holds the unjittered view projection matrix of current camera
|
|
948
|
-
* @param scope - Current shader scope
|
|
949
|
-
* @returns The unjittered view projection matrix of current camera
|
|
946
|
+
/**
|
|
947
|
+
* Gets the uniform variable of type mat4 which holds the unjittered view projection matrix of current camera
|
|
948
|
+
* @param scope - Current shader scope
|
|
949
|
+
* @returns The unjittered view projection matrix of current camera
|
|
950
950
|
*/ static getUnjitteredViewProjectionMatrix(scope) {
|
|
951
951
|
return scope.camera.unjitteredVPMatrix;
|
|
952
952
|
}
|
|
953
|
-
/**
|
|
954
|
-
* Gets the uniform variable of type vec2 which holds the jitter value of the projection matrix of current camera
|
|
955
|
-
* @param scope - Current shader scope
|
|
956
|
-
* @returns The jitter value of projection matrix of current camera
|
|
953
|
+
/**
|
|
954
|
+
* Gets the uniform variable of type vec2 which holds the jitter value of the projection matrix of current camera
|
|
955
|
+
* @param scope - Current shader scope
|
|
956
|
+
* @returns The jitter value of projection matrix of current camera
|
|
957
957
|
*/ static getProjectionMatrixJitterValue(scope) {
|
|
958
958
|
return scope.camera.jitterValue;
|
|
959
959
|
}
|
|
960
|
-
/**
|
|
961
|
-
* Gets the uniform variable of type mat4 which holds the jittered inversed view-projection matrix
|
|
962
|
-
* @param scope - Current shader scope
|
|
963
|
-
* @returns The jittered inversed view-projection matrix
|
|
960
|
+
/**
|
|
961
|
+
* Gets the uniform variable of type mat4 which holds the jittered inversed view-projection matrix
|
|
962
|
+
* @param scope - Current shader scope
|
|
963
|
+
* @returns The jittered inversed view-projection matrix
|
|
964
964
|
*/ static getJitteredInvVPMatrix(scope) {
|
|
965
965
|
return scope.camera.jitteredInvVPMatrix;
|
|
966
966
|
}
|
|
967
|
-
/**
|
|
968
|
-
* Gets the uniform variable of type mat4 which holds the unjittered view projection at previous frame matrix of current camera
|
|
969
|
-
* @param scope - Current shader scope
|
|
970
|
-
* @returns The unjittered view projection matrix at previous frame of current camera
|
|
967
|
+
/**
|
|
968
|
+
* Gets the uniform variable of type mat4 which holds the unjittered view projection at previous frame matrix of current camera
|
|
969
|
+
* @param scope - Current shader scope
|
|
970
|
+
* @returns The unjittered view projection matrix at previous frame of current camera
|
|
971
971
|
*/ static getPrevUnjitteredViewProjectionMatrix(scope) {
|
|
972
972
|
return scope.camera.prevUnjitteredVPMatrix;
|
|
973
973
|
}
|
|
974
|
-
/**
|
|
975
|
-
* Gets the uniform variable of type mat4 which holds the view matrix of current camera (world space to camera space)
|
|
976
|
-
* @param scope - Current shader scope
|
|
977
|
-
* @returns The view matrix of current camera
|
|
974
|
+
/**
|
|
975
|
+
* Gets the uniform variable of type mat4 which holds the view matrix of current camera (world space to camera space)
|
|
976
|
+
* @param scope - Current shader scope
|
|
977
|
+
* @returns The view matrix of current camera
|
|
978
978
|
*/ static getViewMatrix(scope) {
|
|
979
979
|
return scope.camera.viewMatrix;
|
|
980
980
|
}
|
|
981
|
-
/**
|
|
982
|
-
* Gets the uniform variable of type mat4 which holds the inv-view matrix of current camera (camera space to world space)
|
|
983
|
-
* @param scope - Current shader scope
|
|
984
|
-
* @returns The inv-view matrix of current camera
|
|
981
|
+
/**
|
|
982
|
+
* Gets the uniform variable of type mat4 which holds the inv-view matrix of current camera (camera space to world space)
|
|
983
|
+
* @param scope - Current shader scope
|
|
984
|
+
* @returns The inv-view matrix of current camera
|
|
985
985
|
*/ static getInvViewMatrix(scope) {
|
|
986
986
|
return scope.camera.worldMatrix;
|
|
987
987
|
}
|
|
@@ -1032,20 +1032,20 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1032
1032
|
/** @internal */ static getLightExtra(scope, lightIndex) {
|
|
1033
1033
|
return scope[UNIFORM_NAME_LIGHT_BUFFER].at(scope.$builder.add(scope.$builder.mul(lightIndex, 4), 3));
|
|
1034
1034
|
}
|
|
1035
|
-
/**
|
|
1036
|
-
* Sets the clip space position in vertex shader
|
|
1037
|
-
*
|
|
1038
|
-
* @remarks
|
|
1039
|
-
* Use this function instead of using
|
|
1040
|
-
* <pre>
|
|
1041
|
-
* // Do not use this
|
|
1042
|
-
* this.$builtins.position = some_value;
|
|
1043
|
-
* // Use this
|
|
1044
|
-
* ShaderFramework.setClipSpacePosition(some_value);
|
|
1045
|
-
* </pre>,
|
|
1046
|
-
*
|
|
1047
|
-
* @param scope - Current shader scope
|
|
1048
|
-
* @param pos - The clip space position to be set
|
|
1035
|
+
/**
|
|
1036
|
+
* Sets the clip space position in vertex shader
|
|
1037
|
+
*
|
|
1038
|
+
* @remarks
|
|
1039
|
+
* Use this function instead of using
|
|
1040
|
+
* <pre>
|
|
1041
|
+
* // Do not use this
|
|
1042
|
+
* this.$builtins.position = some_value;
|
|
1043
|
+
* // Use this
|
|
1044
|
+
* ShaderFramework.setClipSpacePosition(some_value);
|
|
1045
|
+
* </pre>,
|
|
1046
|
+
*
|
|
1047
|
+
* @param scope - Current shader scope
|
|
1048
|
+
* @param pos - The clip space position to be set
|
|
1049
1049
|
*/ static setClipSpacePosition(scope, pos) {
|
|
1050
1050
|
const pb = scope.$builder;
|
|
1051
1051
|
const cameraParams = this.getCameraParams(scope);
|
|
@@ -1055,20 +1055,20 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1055
1055
|
scope.$builtins.position = pos;
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
|
-
/**
|
|
1059
|
-
* Get shadow map uniform value
|
|
1060
|
-
*
|
|
1061
|
-
* @param scope - Shader scope
|
|
1062
|
-
* @returns The shadow map texture uniform
|
|
1058
|
+
/**
|
|
1059
|
+
* Get shadow map uniform value
|
|
1060
|
+
*
|
|
1061
|
+
* @param scope - Shader scope
|
|
1062
|
+
* @returns The shadow map texture uniform
|
|
1063
1063
|
*/ static getShadowMap(scope) {
|
|
1064
1064
|
return scope[UNIFORM_NAME_SHADOW_MAP];
|
|
1065
1065
|
}
|
|
1066
|
-
/**
|
|
1067
|
-
* Calculates shadow of current fragment
|
|
1068
|
-
*
|
|
1069
|
-
* @param scope - Shader scope
|
|
1070
|
-
* @param NoL - NdotL vector
|
|
1071
|
-
* @returns Shadow of current fragment, 1 means no shadow and 0 means full shadowed.
|
|
1066
|
+
/**
|
|
1067
|
+
* Calculates shadow of current fragment
|
|
1068
|
+
*
|
|
1069
|
+
* @param scope - Shader scope
|
|
1070
|
+
* @param NoL - NdotL vector
|
|
1071
|
+
* @returns Shadow of current fragment, 1 means no shadow and 0 means full shadowed.
|
|
1072
1072
|
*/ static calculateShadow(scope, worldPos, NoL, ctx) {
|
|
1073
1073
|
const pb = scope.$builder;
|
|
1074
1074
|
const that = this;
|
|
@@ -1144,49 +1144,49 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1144
1144
|
scope[funcName](worldPos, color);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Calculates the non-linear depth from linear depth
|
|
1149
|
-
*
|
|
1150
|
-
* @param scope - Current shader scope
|
|
1151
|
-
* @param depth - The linear depth
|
|
1152
|
-
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1153
|
-
* @returns The calculated non-linear depth
|
|
1147
|
+
/**
|
|
1148
|
+
* Calculates the non-linear depth from linear depth
|
|
1149
|
+
*
|
|
1150
|
+
* @param scope - Current shader scope
|
|
1151
|
+
* @param depth - The linear depth
|
|
1152
|
+
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1153
|
+
* @returns The calculated non-linear depth
|
|
1154
1154
|
*/ static linearDepthToNonLinear(scope, depth, nearFar) {
|
|
1155
1155
|
const pb = scope.$builder;
|
|
1156
1156
|
nearFar = nearFar ?? this.getCameraParams(scope);
|
|
1157
1157
|
return pb.div(pb.sub(nearFar.y, pb.div(pb.mul(nearFar.x, nearFar.y), depth)), pb.sub(nearFar.y, nearFar.x));
|
|
1158
1158
|
}
|
|
1159
|
-
/**
|
|
1160
|
-
* Calculates the linear depth from non-linear depth
|
|
1161
|
-
*
|
|
1162
|
-
* @param scope - Current shader scope
|
|
1163
|
-
* @param depth - The non-linear depth
|
|
1164
|
-
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1165
|
-
* @returns The calculated linear depth
|
|
1159
|
+
/**
|
|
1160
|
+
* Calculates the linear depth from non-linear depth
|
|
1161
|
+
*
|
|
1162
|
+
* @param scope - Current shader scope
|
|
1163
|
+
* @param depth - The non-linear depth
|
|
1164
|
+
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1165
|
+
* @returns The calculated linear depth
|
|
1166
1166
|
*/ static nonLinearDepthToLinear(scope, depth, nearFar) {
|
|
1167
1167
|
const pb = scope.$builder;
|
|
1168
1168
|
nearFar = nearFar ?? this.getCameraParams(scope);
|
|
1169
1169
|
return pb.div(pb.mul(nearFar.x, nearFar.y), pb.mix(nearFar.y, nearFar.x, depth));
|
|
1170
1170
|
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Calculates the normalized linear depth from non-linear depth
|
|
1173
|
-
*
|
|
1174
|
-
* @param scope - Current shader scope
|
|
1175
|
-
* @param depth - The non-linear depth
|
|
1176
|
-
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1177
|
-
* @returns The calculated normalized linear depth
|
|
1171
|
+
/**
|
|
1172
|
+
* Calculates the normalized linear depth from non-linear depth
|
|
1173
|
+
*
|
|
1174
|
+
* @param scope - Current shader scope
|
|
1175
|
+
* @param depth - The non-linear depth
|
|
1176
|
+
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1177
|
+
* @returns The calculated normalized linear depth
|
|
1178
1178
|
*/ static nonLinearDepthToLinearNormalized(scope, depth, nearFar) {
|
|
1179
1179
|
const pb = scope.$builder;
|
|
1180
1180
|
nearFar = nearFar ?? this.getCameraParams(scope);
|
|
1181
1181
|
return pb.div(nearFar.x, pb.mix(nearFar.y, nearFar.x, depth));
|
|
1182
1182
|
}
|
|
1183
|
-
/**
|
|
1184
|
-
* Sample linear depth from linear depth texture
|
|
1185
|
-
* @param scope - Current shader scope
|
|
1186
|
-
* @param tex - The linear depth texture
|
|
1187
|
-
* @param uv - The uv coordinates
|
|
1188
|
-
* @param level - The mipmap level to sample
|
|
1189
|
-
* @returns Linear depth value
|
|
1183
|
+
/**
|
|
1184
|
+
* Sample linear depth from linear depth texture
|
|
1185
|
+
* @param scope - Current shader scope
|
|
1186
|
+
* @param tex - The linear depth texture
|
|
1187
|
+
* @param uv - The uv coordinates
|
|
1188
|
+
* @param level - The mipmap level to sample
|
|
1189
|
+
* @returns Linear depth value
|
|
1190
1190
|
*/ static sampleLinearDepth(scope, tex, uv, level) {
|
|
1191
1191
|
const pb = scope.$builder;
|
|
1192
1192
|
const depth = pb.textureSampleLevel(tex, uv, level);
|
|
@@ -1208,23 +1208,23 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1208
1208
|
});
|
|
1209
1209
|
return scope.zSamplePositionFromDepth(uv, cameraNearFar, mat);
|
|
1210
1210
|
}
|
|
1211
|
-
/**
|
|
1212
|
-
* Sample linear depth from linear depth texture with backface
|
|
1213
|
-
* @param scope - Current shader scope
|
|
1214
|
-
* @param tex - The linear depth texture
|
|
1215
|
-
* @param uv - The uv coordinates
|
|
1216
|
-
* @param level - The mipmap level to sample
|
|
1217
|
-
* @returns Linear depth value
|
|
1211
|
+
/**
|
|
1212
|
+
* Sample linear depth from linear depth texture with backface
|
|
1213
|
+
* @param scope - Current shader scope
|
|
1214
|
+
* @param tex - The linear depth texture
|
|
1215
|
+
* @param uv - The uv coordinates
|
|
1216
|
+
* @param level - The mipmap level to sample
|
|
1217
|
+
* @returns Linear depth value
|
|
1218
1218
|
*/ static sampleLinearDepthWithBackface(scope, tex, uv, level) {
|
|
1219
1219
|
const pb = scope.$builder;
|
|
1220
1220
|
return pb.textureSampleLevel(tex, uv, level).rg;
|
|
1221
1221
|
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Transform color to sRGB color space if nessesary
|
|
1224
|
-
*
|
|
1225
|
-
* @param scope - Current shader scope
|
|
1226
|
-
* @param outputColor - The color to be transformed
|
|
1227
|
-
* @returns The transformed color
|
|
1222
|
+
/**
|
|
1223
|
+
* Transform color to sRGB color space if nessesary
|
|
1224
|
+
*
|
|
1225
|
+
* @param scope - Current shader scope
|
|
1226
|
+
* @param outputColor - The color to be transformed
|
|
1227
|
+
* @returns The transformed color
|
|
1228
1228
|
*/ static encodeColorOutput(scope, outputColor) {
|
|
1229
1229
|
const pb = scope.$builder;
|
|
1230
1230
|
const that = this;
|