@zephyr3d/scene 0.9.3 → 0.9.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/animation/animationmask.js +224 -0
- package/dist/animation/animationmask.js.map +1 -0
- package/dist/animation/animationset.js +268 -67
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +3 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +7 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +6 -4
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +390 -43
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +4 -3
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +2 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/morphtarget.js +3 -72
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -0
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +3 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/proptrack.js +3 -0
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +3 -0
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +3 -0
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +254 -79
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +4 -4
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/animation/translationtrack.js +3 -0
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/engine.js +129 -17
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +251 -80
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +133 -102
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +18 -14
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js +1 -6
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
- package/dist/asset/model.js +1052 -183
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +474 -0
- package/dist/avatar/wardrobe.js.map +1 -0
- package/dist/index.d.ts +1810 -233
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +1 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +21 -6
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +277 -277
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.js.map +1 -0
- package/dist/posteffect/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +54 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/sky.js +9 -0
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +18 -8
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +16 -2
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +164 -102
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +2 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +437 -230
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +146 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +50 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +188 -1
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +16 -1
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/pmrem.js +34 -8
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/serialization/manager.js +340 -283
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +702 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +66 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +189 -8
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/textures/sheenlut.js +138 -0
- package/dist/utility/textures/sheenlut.js.map +1 -0
- package/dist/values.js +48 -48
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -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;
|
|
@@ -122,25 +122,25 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
122
122
|
}
|
|
123
123
|
return bindGroupLayout;
|
|
124
124
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Prepares the fragment shader which is going to be used in our material system
|
|
127
|
-
*
|
|
128
|
-
* @remarks
|
|
129
|
-
* This function will setup all nessesary uniforms acoording to the drawing context
|
|
130
|
-
*
|
|
131
|
-
* @param pb - The program builder
|
|
132
|
-
* @param ctx - The drawing context
|
|
125
|
+
/**
|
|
126
|
+
* Prepares the fragment shader which is going to be used in our material system
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* This function will setup all nessesary uniforms acoording to the drawing context
|
|
130
|
+
*
|
|
131
|
+
* @param pb - The program builder
|
|
132
|
+
* @param ctx - The drawing context
|
|
133
133
|
*/ static prepareFragmentShader(pb, ctx) {
|
|
134
134
|
this.setupGlobalUniforms(pb, ctx);
|
|
135
135
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Prepares the vertex shader which is going to be used in our material system
|
|
138
|
-
*
|
|
139
|
-
* @remarks
|
|
140
|
-
* This function will setup all nessesary uniforms according to the drawing context
|
|
141
|
-
*
|
|
142
|
-
* @param pb - The program builder
|
|
143
|
-
* @param ctx - The drawing context
|
|
136
|
+
/**
|
|
137
|
+
* Prepares the vertex shader which is going to be used in our material system
|
|
138
|
+
*
|
|
139
|
+
* @remarks
|
|
140
|
+
* This function will setup all nessesary uniforms according to the drawing context
|
|
141
|
+
*
|
|
142
|
+
* @param pb - The program builder
|
|
143
|
+
* @param ctx - The drawing context
|
|
144
144
|
*/ static prepareVertexShader(pb, ctx) {
|
|
145
145
|
this.setupGlobalUniforms(pb, ctx);
|
|
146
146
|
this.prepareVertexShaderCommon(pb, ctx);
|
|
@@ -248,30 +248,30 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
/**
|
|
252
|
-
* This function checks if the shader needs to process skeletal animation.
|
|
253
|
-
*
|
|
254
|
-
* @param scope - Current shader scope
|
|
255
|
-
*
|
|
256
|
-
* @returns true if the shader needs to process skeletal animation, otherwise false.
|
|
251
|
+
/**
|
|
252
|
+
* This function checks if the shader needs to process skeletal animation.
|
|
253
|
+
*
|
|
254
|
+
* @param scope - Current shader scope
|
|
255
|
+
*
|
|
256
|
+
* @returns true if the shader needs to process skeletal animation, otherwise false.
|
|
257
257
|
*/ static hasSkinning(scope) {
|
|
258
258
|
return !!scope[UNIFORM_NAME_BONE_MATRICES];
|
|
259
259
|
}
|
|
260
|
-
/**
|
|
261
|
-
* This function checks if the shader needs to process morph target animation.
|
|
262
|
-
*
|
|
263
|
-
* @param scope - Current shader scope
|
|
264
|
-
*
|
|
265
|
-
* @returns true if the shader needs to process morph target animation, otherwise false.
|
|
260
|
+
/**
|
|
261
|
+
* This function checks if the shader needs to process morph target animation.
|
|
262
|
+
*
|
|
263
|
+
* @param scope - Current shader scope
|
|
264
|
+
*
|
|
265
|
+
* @returns true if the shader needs to process morph target animation, otherwise false.
|
|
266
266
|
*/ static hasMorphing(scope) {
|
|
267
267
|
return !!scope[UNIFORM_NAME_MORPH_DATA];
|
|
268
268
|
}
|
|
269
|
-
/**
|
|
270
|
-
* Calculate skinning matrix for current vertex
|
|
271
|
-
*
|
|
272
|
-
* @param scope - Current shader scope
|
|
273
|
-
*
|
|
274
|
-
* @returns Skinning matrix for current vertex, or null if there is not skeletal animation
|
|
269
|
+
/**
|
|
270
|
+
* Calculate skinning matrix for current vertex
|
|
271
|
+
*
|
|
272
|
+
* @param scope - Current shader scope
|
|
273
|
+
*
|
|
274
|
+
* @returns Skinning matrix for current vertex, or null if there is not skeletal animation
|
|
275
275
|
*/ static calculateSkinMatrix(scope) {
|
|
276
276
|
if (!this.hasSkinning(scope)) {
|
|
277
277
|
return null;
|
|
@@ -426,12 +426,12 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
426
426
|
scope.$l[that.SKIN_PREV_MATRIX_NAME] = scope[funcNameGetSkinningMatrix](scope[that.SKIN_BONE_OFFSET].y);
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
/**
|
|
430
|
-
* Calculates the vertex position of type vec3 in object space
|
|
431
|
-
*
|
|
432
|
-
* @param scope - Current shader scope
|
|
433
|
-
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
434
|
-
* @returns The calculated vertex position in object space, or null if pos is null
|
|
429
|
+
/**
|
|
430
|
+
* Calculates the vertex position of type vec3 in object space
|
|
431
|
+
*
|
|
432
|
+
* @param scope - Current shader scope
|
|
433
|
+
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
434
|
+
* @returns The calculated vertex position in object space, or null if pos is null
|
|
435
435
|
*/ static resolveVertexPosition(scope) {
|
|
436
436
|
const pb = scope.$builder;
|
|
437
437
|
if (pb.shaderKind !== 'vertex') {
|
|
@@ -473,12 +473,12 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
473
473
|
});
|
|
474
474
|
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();
|
|
475
475
|
}
|
|
476
|
-
/**
|
|
477
|
-
* Resolve motion vector
|
|
478
|
-
*
|
|
479
|
-
* @param scope - Current shader scope
|
|
480
|
-
* @param worldPos - Current object position in world space
|
|
481
|
-
* @param prevWorldPos - Previous object position in world space
|
|
476
|
+
/**
|
|
477
|
+
* Resolve motion vector
|
|
478
|
+
*
|
|
479
|
+
* @param scope - Current shader scope
|
|
480
|
+
* @param worldPos - Current object position in world space
|
|
481
|
+
* @param prevWorldPos - Previous object position in world space
|
|
482
482
|
*/ static resolveMotionVector(scope, worldPos, prevWorldPos) {
|
|
483
483
|
const that = this;
|
|
484
484
|
const pb = scope.$builder;
|
|
@@ -489,13 +489,13 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
489
489
|
scope.$outputs.zMotionVectorPosPrev = pb.mul(prevUnjitteredVPMatrix, pb.vec4(prevWorldPos.xyz, 1));
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
/**
|
|
493
|
-
* Calculates the normal vector of type vec3 in object space
|
|
494
|
-
*
|
|
495
|
-
* @param scope - Current shader scope
|
|
496
|
-
* @param normal - Vertex normal input, must be type of vec3, null if no vertex normal input
|
|
497
|
-
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
498
|
-
* @returns The calculated normal vector in object space, or null if normal is null
|
|
492
|
+
/**
|
|
493
|
+
* Calculates the normal vector of type vec3 in object space
|
|
494
|
+
*
|
|
495
|
+
* @param scope - Current shader scope
|
|
496
|
+
* @param normal - Vertex normal input, must be type of vec3, null if no vertex normal input
|
|
497
|
+
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
498
|
+
* @returns The calculated normal vector in object space, or null if normal is null
|
|
499
499
|
*/ static resolveVertexNormal(scope, normal) {
|
|
500
500
|
const pb = scope.$builder;
|
|
501
501
|
if (pb.shaderKind !== 'vertex') {
|
|
@@ -520,13 +520,13 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
520
520
|
return normal;
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
/**
|
|
524
|
-
* Calculates the tangent vector of type vec3 in object space
|
|
525
|
-
*
|
|
526
|
-
* @param scope - Current shader scope
|
|
527
|
-
* @param tangent - Vertex tangent input, must be type of vec4, null if no vertex tangent input
|
|
528
|
-
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
529
|
-
* @returns The calculated tangent vector of type vec4 in object space, or null if tangent is null
|
|
523
|
+
/**
|
|
524
|
+
* Calculates the tangent vector of type vec3 in object space
|
|
525
|
+
*
|
|
526
|
+
* @param scope - Current shader scope
|
|
527
|
+
* @param tangent - Vertex tangent input, must be type of vec4, null if no vertex tangent input
|
|
528
|
+
* @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
|
|
529
|
+
* @returns The calculated tangent vector of type vec4 in object space, or null if tangent is null
|
|
530
530
|
*/ static resolveVertexTangent(scope, tangent) {
|
|
531
531
|
const pb = scope.$builder;
|
|
532
532
|
if (pb.shaderKind !== 'vertex') {
|
|
@@ -551,18 +551,18 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
551
551
|
return tangent;
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
|
-
/**
|
|
555
|
-
* Gets the uniform variable of type mat4 which holds the world matrix of current object to be drawn
|
|
556
|
-
* @param scope - Current shader scope
|
|
557
|
-
* @returns The world matrix of current object to be drawn
|
|
554
|
+
/**
|
|
555
|
+
* Gets the uniform variable of type mat4 which holds the world matrix of current object to be drawn
|
|
556
|
+
* @param scope - Current shader scope
|
|
557
|
+
* @returns The world matrix of current object to be drawn
|
|
558
558
|
*/ static getWorldMatrix(scope) {
|
|
559
559
|
const pb = scope.$builder;
|
|
560
560
|
return scope[UNIFORM_NAME_WORLD_MATRIX] ?? pb.mat4(this.getInstancedUniform(scope, 0), this.getInstancedUniform(scope, 1), this.getInstancedUniform(scope, 2), this.getInstancedUniform(scope, 3));
|
|
561
561
|
}
|
|
562
|
-
/**
|
|
563
|
-
* Gets the uniform variable of type mat4 which holds the world matrix at previous frame of current object to be drawn
|
|
564
|
-
* @param scope - Current shader scope
|
|
565
|
-
* @returns The world matrix at previous frame of current object to be drawn
|
|
562
|
+
/**
|
|
563
|
+
* Gets the uniform variable of type mat4 which holds the world matrix at previous frame of current object to be drawn
|
|
564
|
+
* @param scope - Current shader scope
|
|
565
|
+
* @returns The world matrix at previous frame of current object to be drawn
|
|
566
566
|
*/ static getPrevWorldMatrix(scope) {
|
|
567
567
|
const pb = scope.$builder;
|
|
568
568
|
const that = this;
|
|
@@ -593,28 +593,28 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
593
593
|
return scope.Z_getPrevWorldMatrix(framestamp);
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
|
-
/**
|
|
597
|
-
* Gets the instance uniform value of type vec4 by uniform index
|
|
598
|
-
* @param scope - Current shader scope
|
|
599
|
-
* @returns instance uniform value
|
|
596
|
+
/**
|
|
597
|
+
* Gets the instance uniform value of type vec4 by uniform index
|
|
598
|
+
* @param scope - Current shader scope
|
|
599
|
+
* @returns instance uniform value
|
|
600
600
|
*/ static getInstancedUniform(scope, uniformIndex) {
|
|
601
601
|
const pb = scope.$builder;
|
|
602
602
|
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)));
|
|
603
603
|
}
|
|
604
|
-
/**
|
|
605
|
-
* Gets the uniform variable of type mat4 which holds the normal matrix of current object to be drawn
|
|
606
|
-
*
|
|
607
|
-
* @param scope - Current shader scope
|
|
608
|
-
* @returns The normal matrix of current object to be drawn
|
|
604
|
+
/**
|
|
605
|
+
* Gets the uniform variable of type mat4 which holds the normal matrix of current object to be drawn
|
|
606
|
+
*
|
|
607
|
+
* @param scope - Current shader scope
|
|
608
|
+
* @returns The normal matrix of current object to be drawn
|
|
609
609
|
*/ static getNormalMatrix(scope) {
|
|
610
610
|
return this.getWorldMatrix(scope);
|
|
611
611
|
}
|
|
612
|
-
/**
|
|
613
|
-
* Vertex shader drawable stuff
|
|
614
|
-
*
|
|
615
|
-
* @param scope - Current shader scope
|
|
616
|
-
* @param skinning - true if skinning is used, otherwise false.
|
|
617
|
-
* @param instanced - true if instancing is used, otherwise false.
|
|
612
|
+
/**
|
|
613
|
+
* Vertex shader drawable stuff
|
|
614
|
+
*
|
|
615
|
+
* @param scope - Current shader scope
|
|
616
|
+
* @param skinning - true if skinning is used, otherwise false.
|
|
617
|
+
* @param instanced - true if instancing is used, otherwise false.
|
|
618
618
|
*/ static vertexShaderDrawableStuff(scope, skinning, morphing, instanced) {
|
|
619
619
|
const pb = scope.$builder;
|
|
620
620
|
if (instanced) {
|
|
@@ -741,133 +741,133 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
741
741
|
ctx.env.light.envLight.updateBindGroup(bindGroup);
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
|
-
/**
|
|
745
|
-
* Gets the uniform variable of type float which holds the strength of the environment light
|
|
746
|
-
*
|
|
747
|
-
* @remarks
|
|
748
|
-
* This function can only be used in the fragment shader
|
|
749
|
-
*
|
|
750
|
-
* @param scope - Current shader scope
|
|
751
|
-
* @returns The uniform variable of which presents the strength of the environment light
|
|
744
|
+
/**
|
|
745
|
+
* Gets the uniform variable of type float which holds the strength of the environment light
|
|
746
|
+
*
|
|
747
|
+
* @remarks
|
|
748
|
+
* This function can only be used in the fragment shader
|
|
749
|
+
*
|
|
750
|
+
* @param scope - Current shader scope
|
|
751
|
+
* @returns The uniform variable of which presents the strength of the environment light
|
|
752
752
|
*/ static getEnvLightStrength(scope) {
|
|
753
753
|
return scope.light.envLightStrength;
|
|
754
754
|
}
|
|
755
|
-
/**
|
|
756
|
-
* Gets current scene color texture
|
|
757
|
-
* @param scope - Current shader scope
|
|
758
|
-
* @returns current scene color texture
|
|
755
|
+
/**
|
|
756
|
+
* Gets current scene color texture
|
|
757
|
+
* @param scope - Current shader scope
|
|
758
|
+
* @returns current scene color texture
|
|
759
759
|
*/ static getSceneColorTexture(scope) {
|
|
760
760
|
return scope[UNIFORM_NAME_SCENE_COLOR_MAP];
|
|
761
761
|
}
|
|
762
|
-
/**
|
|
763
|
-
* Gets the size of current scene color texture
|
|
764
|
-
* @param scope - Current shader scope
|
|
765
|
-
* @returns The size of current scene color texture
|
|
762
|
+
/**
|
|
763
|
+
* Gets the size of current scene color texture
|
|
764
|
+
* @param scope - Current shader scope
|
|
765
|
+
* @returns The size of current scene color texture
|
|
766
766
|
*/ static getSceneColorTextureSize(scope) {
|
|
767
767
|
return scope[UNIFORM_NAME_SCENE_COLOR_MAP_SIZE];
|
|
768
768
|
}
|
|
769
|
-
/**
|
|
770
|
-
* Gets current linear depth texture
|
|
771
|
-
* @param scope - Current shader scope
|
|
772
|
-
* @returns current linear depth texture
|
|
769
|
+
/**
|
|
770
|
+
* Gets current linear depth texture
|
|
771
|
+
* @param scope - Current shader scope
|
|
772
|
+
* @returns current linear depth texture
|
|
773
773
|
*/ static getLinearDepthTexture(scope) {
|
|
774
774
|
return scope[UNIFORM_NAME_LINEAR_DEPTH_MAP];
|
|
775
775
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Gets the size of current linear depth texture
|
|
778
|
-
* @param scope - Current shader scope
|
|
779
|
-
* @returns The size of current linear depth texture
|
|
776
|
+
/**
|
|
777
|
+
* Gets the size of current linear depth texture
|
|
778
|
+
* @param scope - Current shader scope
|
|
779
|
+
* @returns The size of current linear depth texture
|
|
780
780
|
*/ static getLinearDepthTextureSize(scope) {
|
|
781
781
|
return scope[UNIFORM_NAME_LINEAR_DEPTH_MAP_SIZE];
|
|
782
782
|
}
|
|
783
|
-
/**
|
|
784
|
-
* Gets current HiZ depth texture
|
|
785
|
-
* @param scope - Current shader scope
|
|
786
|
-
* @returns current HiZ depth texture
|
|
783
|
+
/**
|
|
784
|
+
* Gets current HiZ depth texture
|
|
785
|
+
* @param scope - Current shader scope
|
|
786
|
+
* @returns current HiZ depth texture
|
|
787
787
|
*/ static getHiZDepthTexture(scope) {
|
|
788
788
|
return scope[UNIFORM_NAME_HIZ_DEPTH_MAP];
|
|
789
789
|
}
|
|
790
|
-
/**
|
|
791
|
-
* Gets the size of current HiZ depth texture
|
|
792
|
-
* @param scope - Current shader scope
|
|
793
|
-
* @returns The size of current HiZ depth texture
|
|
790
|
+
/**
|
|
791
|
+
* Gets the size of current HiZ depth texture
|
|
792
|
+
* @param scope - Current shader scope
|
|
793
|
+
* @returns The size of current HiZ depth texture
|
|
794
794
|
*/ static getHiZDepthTextureSize(scope) {
|
|
795
795
|
return scope[UNIFORM_NAME_HIZ_DEPTH_MAP_INFO].xy;
|
|
796
796
|
}
|
|
797
|
-
/**
|
|
798
|
-
* Gets the mipmap levels count of current HiZ depth texture
|
|
799
|
-
* @param scope - Current shader scope
|
|
800
|
-
* @returns The mipmap levels count of current HiZ depth texture
|
|
797
|
+
/**
|
|
798
|
+
* Gets the mipmap levels count of current HiZ depth texture
|
|
799
|
+
* @param scope - Current shader scope
|
|
800
|
+
* @returns The mipmap levels count of current HiZ depth texture
|
|
801
801
|
*/ static getHiZDepthTextureMipLevelCount(scope) {
|
|
802
802
|
return scope[UNIFORM_NAME_HIZ_DEPTH_MAP_INFO].z;
|
|
803
803
|
}
|
|
804
|
-
/**
|
|
805
|
-
* Gets current baked skybox texture
|
|
806
|
-
* @param scope - Current shader scope
|
|
807
|
-
* @returns current baked skybox texture
|
|
804
|
+
/**
|
|
805
|
+
* Gets current baked skybox texture
|
|
806
|
+
* @param scope - Current shader scope
|
|
807
|
+
* @returns current baked skybox texture
|
|
808
808
|
*/ static getBakedSkyTexture(scope) {
|
|
809
809
|
return scope[UNIFORM_NAME_BAKED_SKY_MAP];
|
|
810
810
|
}
|
|
811
|
-
/**
|
|
812
|
-
* Gets the elapsed time in seconds
|
|
813
|
-
* @param scope - Current shader scope
|
|
814
|
-
* @returns The elapsed time in seconds
|
|
811
|
+
/**
|
|
812
|
+
* Gets the elapsed time in seconds
|
|
813
|
+
* @param scope - Current shader scope
|
|
814
|
+
* @returns The elapsed time in seconds
|
|
815
815
|
*/ static getElapsedTime(scope) {
|
|
816
816
|
return scope.camera.elapsedTime;
|
|
817
817
|
}
|
|
818
|
-
/**
|
|
819
|
-
* Gets the elapsed time since last frame in seconds
|
|
820
|
-
* @param scope - Current shader scope
|
|
821
|
-
* @returns The elapsed time since last frame in seconds
|
|
818
|
+
/**
|
|
819
|
+
* Gets the elapsed time since last frame in seconds
|
|
820
|
+
* @param scope - Current shader scope
|
|
821
|
+
* @returns The elapsed time since last frame in seconds
|
|
822
822
|
*/ static getElapsedTimeFrame(scope) {
|
|
823
823
|
return scope.camera.frameDeltaTime;
|
|
824
824
|
}
|
|
825
|
-
/**
|
|
826
|
-
* Gets the uniform variable of type vec3 which holds the camera position
|
|
827
|
-
* @param scope - Current shader scope
|
|
828
|
-
* @returns The camera position
|
|
825
|
+
/**
|
|
826
|
+
* Gets the uniform variable of type vec3 which holds the camera position
|
|
827
|
+
* @param scope - Current shader scope
|
|
828
|
+
* @returns The camera position
|
|
829
829
|
*/ static getCameraPosition(scope) {
|
|
830
830
|
return scope.camera.position.xyz;
|
|
831
831
|
}
|
|
832
|
-
/**
|
|
833
|
-
* Gets the uniform variable of type float which holds the roughness factor
|
|
834
|
-
* @param scope - Current shader scope
|
|
835
|
-
* @returns The roughness factor
|
|
832
|
+
/**
|
|
833
|
+
* Gets the uniform variable of type float which holds the roughness factor
|
|
834
|
+
* @param scope - Current shader scope
|
|
835
|
+
* @returns The roughness factor
|
|
836
836
|
*/ static getCameraRoughnessFactor(scope) {
|
|
837
837
|
return scope.camera.roughnessFactor;
|
|
838
838
|
}
|
|
839
|
-
/**
|
|
840
|
-
* Gets framebuffer size for rendering
|
|
841
|
-
* @param scope - Current shader scope
|
|
842
|
-
* @returns The roughness factor
|
|
839
|
+
/**
|
|
840
|
+
* Gets framebuffer size for rendering
|
|
841
|
+
* @param scope - Current shader scope
|
|
842
|
+
* @returns The roughness factor
|
|
843
843
|
*/ static getRenderSize(scope) {
|
|
844
844
|
return scope.camera.renderSize;
|
|
845
845
|
}
|
|
846
|
-
/**
|
|
847
|
-
* Gets the uniform variable of type uint which holds the framestamp
|
|
848
|
-
* @param scope - Current shader scope
|
|
849
|
-
* @returns The framestamp
|
|
846
|
+
/**
|
|
847
|
+
* Gets the uniform variable of type uint which holds the framestamp
|
|
848
|
+
* @param scope - Current shader scope
|
|
849
|
+
* @returns The framestamp
|
|
850
850
|
*/ static getFramestamp(scope) {
|
|
851
851
|
return scope.camera.framestamp;
|
|
852
852
|
}
|
|
853
|
-
/**
|
|
854
|
-
* Gets the clip plane flag
|
|
855
|
-
* @param scope - Current shader scope
|
|
856
|
-
* @returns A float value of 1 indices the clip plane presents, otherwise 0
|
|
853
|
+
/**
|
|
854
|
+
* Gets the clip plane flag
|
|
855
|
+
* @param scope - Current shader scope
|
|
856
|
+
* @returns A float value of 1 indices the clip plane presents, otherwise 0
|
|
857
857
|
*/ static getCameraClipPlaneFlag(scope) {
|
|
858
858
|
return scope.camera.position.w;
|
|
859
859
|
}
|
|
860
|
-
/**
|
|
861
|
-
* Gets the clip plane
|
|
862
|
-
* @param scope - Current shader scope
|
|
863
|
-
* @returns A vec4 presents the clip plane
|
|
860
|
+
/**
|
|
861
|
+
* Gets the clip plane
|
|
862
|
+
* @param scope - Current shader scope
|
|
863
|
+
* @returns A vec4 presents the clip plane
|
|
864
864
|
*/ static getCameraClipPlane(scope) {
|
|
865
865
|
return scope.camera.clipPlane;
|
|
866
866
|
}
|
|
867
|
-
/**
|
|
868
|
-
* Gets the uniform variable of type vec4 which holds the camera parameters
|
|
869
|
-
* @param scope - Current shader scope
|
|
870
|
-
* @returns The camera parameters
|
|
867
|
+
/**
|
|
868
|
+
* Gets the uniform variable of type vec4 which holds the camera parameters
|
|
869
|
+
* @param scope - Current shader scope
|
|
870
|
+
* @returns The camera parameters
|
|
871
871
|
*/ static getCameraParams(scope) {
|
|
872
872
|
return scope.camera.params;
|
|
873
873
|
}
|
|
@@ -880,87 +880,87 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
880
880
|
/** @internal */ static getClusteredLightIndexTexture(scope) {
|
|
881
881
|
return scope[UNIFORM_NAME_LIGHT_INDEX_TEXTURE];
|
|
882
882
|
}
|
|
883
|
-
/**
|
|
884
|
-
* Gets the uniform variable that contains atmosphere parameters
|
|
885
|
-
* @param scope - Current shader scope
|
|
886
|
-
* @returns The atmosphere parameters
|
|
883
|
+
/**
|
|
884
|
+
* Gets the uniform variable that contains atmosphere parameters
|
|
885
|
+
* @param scope - Current shader scope
|
|
886
|
+
* @returns The atmosphere parameters
|
|
887
887
|
*/ static getAtmosphereParams(scope) {
|
|
888
888
|
return scope.fog.atmosphereParams;
|
|
889
889
|
}
|
|
890
|
-
/**
|
|
891
|
-
* Gets the aerial perspective LUT
|
|
892
|
-
* @param scope - Current shader scope
|
|
893
|
-
* @returns The aerial perspective LUT texture
|
|
890
|
+
/**
|
|
891
|
+
* Gets the aerial perspective LUT
|
|
892
|
+
* @param scope - Current shader scope
|
|
893
|
+
* @returns The aerial perspective LUT texture
|
|
894
894
|
*/ static getAerialPerspectiveLUT(scope) {
|
|
895
895
|
return scope[UNIFORM_NAME_AERIALPERSPECTIVE_LUT];
|
|
896
896
|
}
|
|
897
|
-
/**
|
|
898
|
-
* Gets the uniform variable of type mat4 which holds the view projection matrix of current camera
|
|
899
|
-
* @param scope - Current shader scope
|
|
900
|
-
* @returns The view projection matrix of current camera
|
|
897
|
+
/**
|
|
898
|
+
* Gets the uniform variable of type mat4 which holds the view projection matrix of current camera
|
|
899
|
+
* @param scope - Current shader scope
|
|
900
|
+
* @returns The view projection matrix of current camera
|
|
901
901
|
*/ static getViewProjectionMatrix(scope) {
|
|
902
902
|
return scope.camera.viewProjectionMatrix;
|
|
903
903
|
}
|
|
904
|
-
/**
|
|
905
|
-
* Gets the uniform variable of type mat4 which holds the inversed view projection matrix of current camera
|
|
906
|
-
* @param scope - Current shader scope
|
|
907
|
-
* @returns The inversed view projection matrix of current camera
|
|
904
|
+
/**
|
|
905
|
+
* Gets the uniform variable of type mat4 which holds the inversed view projection matrix of current camera
|
|
906
|
+
* @param scope - Current shader scope
|
|
907
|
+
* @returns The inversed view projection matrix of current camera
|
|
908
908
|
*/ static getInvViewProjectionMatrix(scope) {
|
|
909
909
|
return scope.camera.invViewProjectionMatrix;
|
|
910
910
|
}
|
|
911
|
-
/**
|
|
912
|
-
* Gets the uniform variable of type mat4 which holds the projection matrix of current camera
|
|
913
|
-
* @param scope - Current shader scope
|
|
914
|
-
* @returns The projection matrix of current camera
|
|
911
|
+
/**
|
|
912
|
+
* Gets the uniform variable of type mat4 which holds the projection matrix of current camera
|
|
913
|
+
* @param scope - Current shader scope
|
|
914
|
+
* @returns The projection matrix of current camera
|
|
915
915
|
*/ static getProjectionMatrix(scope) {
|
|
916
916
|
return scope.camera.projectionMatrix;
|
|
917
917
|
}
|
|
918
|
-
/**
|
|
919
|
-
* Gets the uniform variable of type mat4 which holds the inversed projection matrix of current camera
|
|
920
|
-
* @param scope - Current shader scope
|
|
921
|
-
* @returns The inversed projection matrix of current camera
|
|
918
|
+
/**
|
|
919
|
+
* Gets the uniform variable of type mat4 which holds the inversed projection matrix of current camera
|
|
920
|
+
* @param scope - Current shader scope
|
|
921
|
+
* @returns The inversed projection matrix of current camera
|
|
922
922
|
*/ static getInvProjectionMatrix(scope) {
|
|
923
923
|
return scope.camera.invProjectionMatrix;
|
|
924
924
|
}
|
|
925
|
-
/**
|
|
926
|
-
* Gets the uniform variable of type mat4 which holds the unjittered view projection matrix of current camera
|
|
927
|
-
* @param scope - Current shader scope
|
|
928
|
-
* @returns The unjittered view projection matrix of current camera
|
|
925
|
+
/**
|
|
926
|
+
* Gets the uniform variable of type mat4 which holds the unjittered view projection matrix of current camera
|
|
927
|
+
* @param scope - Current shader scope
|
|
928
|
+
* @returns The unjittered view projection matrix of current camera
|
|
929
929
|
*/ static getUnjitteredViewProjectionMatrix(scope) {
|
|
930
930
|
return scope.camera.unjitteredVPMatrix;
|
|
931
931
|
}
|
|
932
|
-
/**
|
|
933
|
-
* Gets the uniform variable of type vec2 which holds the jitter value of the projection matrix of current camera
|
|
934
|
-
* @param scope - Current shader scope
|
|
935
|
-
* @returns The jitter value of projection matrix of current camera
|
|
932
|
+
/**
|
|
933
|
+
* Gets the uniform variable of type vec2 which holds the jitter value of the projection matrix of current camera
|
|
934
|
+
* @param scope - Current shader scope
|
|
935
|
+
* @returns The jitter value of projection matrix of current camera
|
|
936
936
|
*/ static getProjectionMatrixJitterValue(scope) {
|
|
937
937
|
return scope.camera.jitterValue;
|
|
938
938
|
}
|
|
939
|
-
/**
|
|
940
|
-
* Gets the uniform variable of type mat4 which holds the jittered inversed view-projection matrix
|
|
941
|
-
* @param scope - Current shader scope
|
|
942
|
-
* @returns The jittered inversed view-projection matrix
|
|
939
|
+
/**
|
|
940
|
+
* Gets the uniform variable of type mat4 which holds the jittered inversed view-projection matrix
|
|
941
|
+
* @param scope - Current shader scope
|
|
942
|
+
* @returns The jittered inversed view-projection matrix
|
|
943
943
|
*/ static getJitteredInvVPMatrix(scope) {
|
|
944
944
|
return scope.camera.jitteredInvVPMatrix;
|
|
945
945
|
}
|
|
946
|
-
/**
|
|
947
|
-
* Gets the uniform variable of type mat4 which holds the unjittered view projection at previous frame matrix of current camera
|
|
948
|
-
* @param scope - Current shader scope
|
|
949
|
-
* @returns The unjittered view projection matrix at previous frame of current camera
|
|
946
|
+
/**
|
|
947
|
+
* Gets the uniform variable of type mat4 which holds the unjittered view projection at previous frame matrix of current camera
|
|
948
|
+
* @param scope - Current shader scope
|
|
949
|
+
* @returns The unjittered view projection matrix at previous frame of current camera
|
|
950
950
|
*/ static getPrevUnjitteredViewProjectionMatrix(scope) {
|
|
951
951
|
return scope.camera.prevUnjitteredVPMatrix;
|
|
952
952
|
}
|
|
953
|
-
/**
|
|
954
|
-
* Gets the uniform variable of type mat4 which holds the view matrix of current camera (world space to camera space)
|
|
955
|
-
* @param scope - Current shader scope
|
|
956
|
-
* @returns The view matrix of current camera
|
|
953
|
+
/**
|
|
954
|
+
* Gets the uniform variable of type mat4 which holds the view matrix of current camera (world space to camera space)
|
|
955
|
+
* @param scope - Current shader scope
|
|
956
|
+
* @returns The view matrix of current camera
|
|
957
957
|
*/ static getViewMatrix(scope) {
|
|
958
958
|
return scope.camera.viewMatrix;
|
|
959
959
|
}
|
|
960
|
-
/**
|
|
961
|
-
* Gets the uniform variable of type mat4 which holds the inv-view matrix of current camera (camera space to world space)
|
|
962
|
-
* @param scope - Current shader scope
|
|
963
|
-
* @returns The inv-view matrix of current camera
|
|
960
|
+
/**
|
|
961
|
+
* Gets the uniform variable of type mat4 which holds the inv-view matrix of current camera (camera space to world space)
|
|
962
|
+
* @param scope - Current shader scope
|
|
963
|
+
* @returns The inv-view matrix of current camera
|
|
964
964
|
*/ static getInvViewMatrix(scope) {
|
|
965
965
|
return scope.camera.worldMatrix;
|
|
966
966
|
}
|
|
@@ -1011,20 +1011,20 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1011
1011
|
/** @internal */ static getLightExtra(scope, lightIndex) {
|
|
1012
1012
|
return scope[UNIFORM_NAME_LIGHT_BUFFER].at(scope.$builder.add(scope.$builder.mul(lightIndex, 4), 3));
|
|
1013
1013
|
}
|
|
1014
|
-
/**
|
|
1015
|
-
* Sets the clip space position in vertex shader
|
|
1016
|
-
*
|
|
1017
|
-
* @remarks
|
|
1018
|
-
* Use this function instead of using
|
|
1019
|
-
* <pre>
|
|
1020
|
-
* // Do not use this
|
|
1021
|
-
* this.$builtins.position = some_value;
|
|
1022
|
-
* // Use this
|
|
1023
|
-
* ShaderFramework.setClipSpacePosition(some_value);
|
|
1024
|
-
* </pre>,
|
|
1025
|
-
*
|
|
1026
|
-
* @param scope - Current shader scope
|
|
1027
|
-
* @param pos - The clip space position to be set
|
|
1014
|
+
/**
|
|
1015
|
+
* Sets the clip space position in vertex shader
|
|
1016
|
+
*
|
|
1017
|
+
* @remarks
|
|
1018
|
+
* Use this function instead of using
|
|
1019
|
+
* <pre>
|
|
1020
|
+
* // Do not use this
|
|
1021
|
+
* this.$builtins.position = some_value;
|
|
1022
|
+
* // Use this
|
|
1023
|
+
* ShaderFramework.setClipSpacePosition(some_value);
|
|
1024
|
+
* </pre>,
|
|
1025
|
+
*
|
|
1026
|
+
* @param scope - Current shader scope
|
|
1027
|
+
* @param pos - The clip space position to be set
|
|
1028
1028
|
*/ static setClipSpacePosition(scope, pos) {
|
|
1029
1029
|
const pb = scope.$builder;
|
|
1030
1030
|
const cameraParams = this.getCameraParams(scope);
|
|
@@ -1034,20 +1034,20 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1034
1034
|
scope.$builtins.position = pos;
|
|
1035
1035
|
}
|
|
1036
1036
|
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Get shadow map uniform value
|
|
1039
|
-
*
|
|
1040
|
-
* @param scope - Shader scope
|
|
1041
|
-
* @returns The shadow map texture uniform
|
|
1037
|
+
/**
|
|
1038
|
+
* Get shadow map uniform value
|
|
1039
|
+
*
|
|
1040
|
+
* @param scope - Shader scope
|
|
1041
|
+
* @returns The shadow map texture uniform
|
|
1042
1042
|
*/ static getShadowMap(scope) {
|
|
1043
1043
|
return scope[UNIFORM_NAME_SHADOW_MAP];
|
|
1044
1044
|
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Calculates shadow of current fragment
|
|
1047
|
-
*
|
|
1048
|
-
* @param scope - Shader scope
|
|
1049
|
-
* @param NoL - NdotL vector
|
|
1050
|
-
* @returns Shadow of current fragment, 1 means no shadow and 0 means full shadowed.
|
|
1045
|
+
/**
|
|
1046
|
+
* Calculates shadow of current fragment
|
|
1047
|
+
*
|
|
1048
|
+
* @param scope - Shader scope
|
|
1049
|
+
* @param NoL - NdotL vector
|
|
1050
|
+
* @returns Shadow of current fragment, 1 means no shadow and 0 means full shadowed.
|
|
1051
1051
|
*/ static calculateShadow(scope, worldPos, NoL, ctx) {
|
|
1052
1052
|
const pb = scope.$builder;
|
|
1053
1053
|
const that = this;
|
|
@@ -1103,57 +1103,57 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1103
1103
|
], function() {
|
|
1104
1104
|
this.$l.uv = pb.div(pb.vec2(this.$builtins.fragCoord.xy), that.getRenderSize(this));
|
|
1105
1105
|
this.$l.fogging = calculateFog(this, this.fog.withAerialPerspective, this.fog.fogType, this.fog.atmosphereParams, this.fog.heightFogParams, this.uv, false, that.getCameraPosition(this).xyz, this.worldPos, this.fog.additive, this[UNIFORM_NAME_AERIALPERSPECTIVE_LUT], this[UNIFORM_NAME_SKYDISTANTLIGHT_LUT]);
|
|
1106
|
-
this.color = pb.vec4(pb.add(pb.mul(this.color.rgb, this.fogging.a), this.fogging.rgb), this.color.a);
|
|
1106
|
+
this.color = pb.vec4(pb.add(pb.mul(this.color.rgb, this.fogging.a), pb.mul(this.fogging.rgb, this.color.a)), this.color.a);
|
|
1107
1107
|
//this.color = pb.vec4(pb.vec3(pb.mix(this.u0, this.u1, this.factor)), this.color.a);
|
|
1108
1108
|
});
|
|
1109
1109
|
scope[funcName](worldPos, color);
|
|
1110
1110
|
}
|
|
1111
1111
|
}
|
|
1112
|
-
/**
|
|
1113
|
-
* Calculates the non-linear depth from linear depth
|
|
1114
|
-
*
|
|
1115
|
-
* @param scope - Current shader scope
|
|
1116
|
-
* @param depth - The linear depth
|
|
1117
|
-
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1118
|
-
* @returns The calculated non-linear depth
|
|
1112
|
+
/**
|
|
1113
|
+
* Calculates the non-linear depth from linear depth
|
|
1114
|
+
*
|
|
1115
|
+
* @param scope - Current shader scope
|
|
1116
|
+
* @param depth - The linear depth
|
|
1117
|
+
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1118
|
+
* @returns The calculated non-linear depth
|
|
1119
1119
|
*/ static linearDepthToNonLinear(scope, depth, nearFar) {
|
|
1120
1120
|
const pb = scope.$builder;
|
|
1121
1121
|
nearFar = nearFar ?? this.getCameraParams(scope);
|
|
1122
1122
|
return pb.add(pb.mul(pb.div(pb.sub(pb.add(nearFar.x, nearFar.y), pb.div(pb.mul(nearFar.x, nearFar.y, 2), depth)), pb.sub(nearFar.y, nearFar.x)), 0.5), 0.5);
|
|
1123
1123
|
}
|
|
1124
|
-
/**
|
|
1125
|
-
* Calculates the linear depth from non-linear depth
|
|
1126
|
-
*
|
|
1127
|
-
* @param scope - Current shader scope
|
|
1128
|
-
* @param depth - The non-linear depth
|
|
1129
|
-
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1130
|
-
* @returns The calculated linear depth
|
|
1124
|
+
/**
|
|
1125
|
+
* Calculates the linear depth from non-linear depth
|
|
1126
|
+
*
|
|
1127
|
+
* @param scope - Current shader scope
|
|
1128
|
+
* @param depth - The non-linear depth
|
|
1129
|
+
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1130
|
+
* @returns The calculated linear depth
|
|
1131
1131
|
*/ static nonLinearDepthToLinear(scope, depth, nearFar) {
|
|
1132
1132
|
const pb = scope.$builder;
|
|
1133
1133
|
nearFar = nearFar ?? this.getCameraParams(scope);
|
|
1134
1134
|
return pb.div(pb.mul(nearFar.x, nearFar.y, 2), pb.add(nearFar.x, nearFar.y, pb.mul(pb.sub(nearFar.x, nearFar.y), pb.sub(pb.mul(depth, 2), 1))));
|
|
1135
1135
|
//return pb.div(pb.mul(nearFar.x, nearFar.y), pb.mix(nearFar.y, nearFar.x, depth));
|
|
1136
1136
|
}
|
|
1137
|
-
/**
|
|
1138
|
-
* Calculates the normalized linear depth from non-linear depth
|
|
1139
|
-
*
|
|
1140
|
-
* @param scope - Current shader scope
|
|
1141
|
-
* @param depth - The non-linear depth
|
|
1142
|
-
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1143
|
-
* @returns The calculated normalized linear depth
|
|
1137
|
+
/**
|
|
1138
|
+
* Calculates the normalized linear depth from non-linear depth
|
|
1139
|
+
*
|
|
1140
|
+
* @param scope - Current shader scope
|
|
1141
|
+
* @param depth - The non-linear depth
|
|
1142
|
+
* @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
|
|
1143
|
+
* @returns The calculated normalized linear depth
|
|
1144
1144
|
*/ static nonLinearDepthToLinearNormalized(scope, depth, nearFar) {
|
|
1145
1145
|
const pb = scope.$builder;
|
|
1146
1146
|
nearFar = nearFar ?? this.getCameraParams(scope);
|
|
1147
1147
|
//return pb.div(nearFar.x, pb.mix(nearFar.y, nearFar.x, depth));
|
|
1148
1148
|
return pb.div(pb.sub(this.nonLinearDepthToLinear(scope, depth, nearFar), nearFar.x), pb.sub(nearFar.y, nearFar.x));
|
|
1149
1149
|
}
|
|
1150
|
-
/**
|
|
1151
|
-
* Sample linear depth from linear depth texture
|
|
1152
|
-
* @param scope - Current shader scope
|
|
1153
|
-
* @param tex - The linear depth texture
|
|
1154
|
-
* @param uv - The uv coordinates
|
|
1155
|
-
* @param level - The mipmap level to sample
|
|
1156
|
-
* @returns Linear depth value
|
|
1150
|
+
/**
|
|
1151
|
+
* Sample linear depth from linear depth texture
|
|
1152
|
+
* @param scope - Current shader scope
|
|
1153
|
+
* @param tex - The linear depth texture
|
|
1154
|
+
* @param uv - The uv coordinates
|
|
1155
|
+
* @param level - The mipmap level to sample
|
|
1156
|
+
* @returns Linear depth value
|
|
1157
1157
|
*/ static sampleLinearDepth(scope, tex, uv, level) {
|
|
1158
1158
|
const pb = scope.$builder;
|
|
1159
1159
|
const depth = pb.textureSampleLevel(tex, uv, level);
|
|
@@ -1175,23 +1175,23 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
|
|
|
1175
1175
|
});
|
|
1176
1176
|
return scope.zSamplePositionFromDepth(uv, cameraNearFar, mat);
|
|
1177
1177
|
}
|
|
1178
|
-
/**
|
|
1179
|
-
* Sample linear depth from linear depth texture with backface
|
|
1180
|
-
* @param scope - Current shader scope
|
|
1181
|
-
* @param tex - The linear depth texture
|
|
1182
|
-
* @param uv - The uv coordinates
|
|
1183
|
-
* @param level - The mipmap level to sample
|
|
1184
|
-
* @returns Linear depth value
|
|
1178
|
+
/**
|
|
1179
|
+
* Sample linear depth from linear depth texture with backface
|
|
1180
|
+
* @param scope - Current shader scope
|
|
1181
|
+
* @param tex - The linear depth texture
|
|
1182
|
+
* @param uv - The uv coordinates
|
|
1183
|
+
* @param level - The mipmap level to sample
|
|
1184
|
+
* @returns Linear depth value
|
|
1185
1185
|
*/ static sampleLinearDepthWithBackface(scope, tex, uv, level) {
|
|
1186
1186
|
const pb = scope.$builder;
|
|
1187
1187
|
return pb.textureSampleLevel(tex, uv, level).rg;
|
|
1188
1188
|
}
|
|
1189
|
-
/**
|
|
1190
|
-
* Transform color to sRGB color space if nessesary
|
|
1191
|
-
*
|
|
1192
|
-
* @param scope - Current shader scope
|
|
1193
|
-
* @param outputColor - The color to be transformed
|
|
1194
|
-
* @returns The transformed color
|
|
1189
|
+
/**
|
|
1190
|
+
* Transform color to sRGB color space if nessesary
|
|
1191
|
+
*
|
|
1192
|
+
* @param scope - Current shader scope
|
|
1193
|
+
* @param outputColor - The color to be transformed
|
|
1194
|
+
* @returns The transformed color
|
|
1195
1195
|
*/ static encodeColorOutput(scope, outputColor) {
|
|
1196
1196
|
const pb = scope.$builder;
|
|
1197
1197
|
const that = this;
|