@zephyr3d/scene 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationset.js +563 -128
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_system.js +2516 -0
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -0
- package/dist/animation/fixed_geometry_cache_track.js +138 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -0
- package/dist/animation/geometry_cache_utils.js +120 -0
- package/dist/animation/geometry_cache_utils.js.map +1 -0
- package/dist/animation/ik_modifier.js +9 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +469 -0
- package/dist/animation/joint_dynamics/collision.js.map +1 -0
- package/dist/animation/joint_dynamics/constraints.js +329 -0
- package/dist/animation/joint_dynamics/constraints.js.map +1 -0
- package/dist/animation/joint_dynamics/controller.js +699 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +393 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -0
- package/dist/animation/joint_dynamics/solver.js +794 -0
- package/dist/animation/joint_dynamics/solver.js.map +1 -0
- package/dist/animation/joint_dynamics/types.js +19 -0
- package/dist/animation/joint_dynamics/types.js.map +1 -0
- package/dist/animation/joint_dynamics/vrm_spring_bone.js +46 -0
- package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +1 -0
- package/dist/animation/joint_dynamics_modifier.js +51 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -0
- package/dist/animation/pca_geometry_cache_track.js +222 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -0
- package/dist/animation/skeleton.js +1907 -3
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +3 -5
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/multi_chain_spring_system.js +2 -0
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +3 -2
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +35 -5
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +325 -28
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring2/collision.js +469 -0
- package/dist/animation/spring2/collision.js.map +1 -0
- package/dist/animation/spring2/constraints.js +329 -0
- package/dist/animation/spring2/constraints.js.map +1 -0
- package/dist/animation/spring2/controller.js +434 -0
- package/dist/animation/spring2/controller.js.map +1 -0
- package/dist/animation/spring2/math.js +16 -0
- package/dist/animation/spring2/math.js.map +1 -0
- package/dist/animation/spring2/solver.js +624 -0
- package/dist/animation/spring2/solver.js.map +1 -0
- package/dist/animation/spring2/spring_system.js +118 -0
- package/dist/animation/spring2/spring_system.js.map +1 -0
- package/dist/animation/spring2/types.js +19 -0
- package/dist/animation/spring2/types.js.map +1 -0
- package/dist/animation/spring_modifier.js +17 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/engine.js +42 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/runtimescript.js +132 -1
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/screen.js +3 -3
- package/dist/app/screen.js.map +1 -1
- package/dist/app/scriptingsystem.js +69 -37
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +157 -146
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -1
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js +570 -0
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -0
- package/dist/asset/model.js +192 -0
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/base.js +26 -7
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +146 -24
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/fps.js +2 -2
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +2 -2
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +11701 -8506
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/dist/material/lambert.js +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +9 -3
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +54 -7
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +17 -7
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +7 -2
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +108 -16
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +222 -14
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +24 -12
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +11 -8
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -5
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrblueprint.js +148 -1
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js +125 -2
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/shader/helper.js +10 -4
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/water.js +2 -2
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/coloradjust.js +145 -0
- package/dist/posteffect/coloradjust.js.map +1 -0
- package/dist/posteffect/taa.js +68 -32
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/cluster_light.js +17 -12
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/deferredlightpass.js +510 -0
- package/dist/render/deferredlightpass.js.map +1 -0
- package/dist/render/deferredshadowlightpass.js +428 -0
- package/dist/render/deferredshadowlightpass.js.map +1 -0
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +21 -12
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +20 -22
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/gbufferpass.js +50 -0
- package/dist/render/gbufferpass.js.map +1 -0
- package/dist/render/lightpass.js +1 -2
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/primitive.js +1 -1
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/render_queue.js +3 -2
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +5 -358
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/executor.js +15 -12
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +144 -88
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +178 -0
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +12 -1
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/types.js +2 -2
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/sky.js +26 -9
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +4 -3
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +4 -4
- package/dist/scene/environment.js +7 -4
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/light.js +184 -18
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +30 -0
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/particlesys.js +3 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/raycast_visitor.js +29 -3
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +86 -19
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +87 -31
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/script_attachment.js +59 -0
- package/dist/scene/script_attachment.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +3 -2
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +4 -3
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +3 -2
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/shadow.js +2 -2
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shadow/shadowmapper.js +74 -4
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/box.js +163 -0
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/capsule.js +216 -0
- package/dist/shapes/capsule.js.map +1 -0
- package/dist/shapes/cylinder.js +91 -0
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +32 -0
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/tetrahedron.js +211 -0
- package/dist/shapes/tetrahedron.js.map +1 -1
- package/dist/shapes/torus.js +173 -0
- package/dist/shapes/torus.js.map +1 -1
- package/dist/utility/blueprint/common/math.js +111 -1
- package/dist/utility/blueprint/common/math.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js +235 -1
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +154 -10
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +273 -19
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/json.js +12 -2
- package/dist/utility/serialization/json.js.map +1 -1
- package/dist/utility/serialization/manager.js +30 -11
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +250 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -2
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +154 -2
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth_script.js +834 -0
- package/dist/utility/serialization/scene/cloth_script.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +7 -0
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +120 -4
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +453 -1
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +4 -2
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +298 -10
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -2
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +100 -3
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +130 -3
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/script.js +66 -0
- package/dist/utility/serialization/scene/script.js.map +1 -0
- package/dist/utility/serialization/scene/spring_script.js +596 -0
- package/dist/utility/serialization/scene/spring_script.js.map +1 -0
- package/dist/utility/serialization/scene/sprite.js +5 -3
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +4 -2
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -2
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +5 -1
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
2
|
import { mixinTextureProps } from '../texture.js';
|
|
3
3
|
import { mixinPBRCommon } from '../pbr/common.js';
|
|
4
|
-
import { Vector4 } from '@zephyr3d/base';
|
|
4
|
+
import { Vector4, Vector2 } from '@zephyr3d/base';
|
|
5
5
|
import { mixinLight } from '../lit.js';
|
|
6
6
|
import { ShaderHelper } from '../../shader/helper.js';
|
|
7
|
-
import { MaterialVaryingFlags } from '../../../values.js';
|
|
7
|
+
import { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT, LIGHT_TYPE_RECT, LIGHT_TYPE_POINT } from '../../../values.js';
|
|
8
8
|
|
|
9
|
+
const PBR_REFLECTION_MODE = {
|
|
10
|
+
none: 0,
|
|
11
|
+
ggx: 1,
|
|
12
|
+
anisotropic: 2,
|
|
13
|
+
glint: 3
|
|
14
|
+
};
|
|
9
15
|
/**
|
|
10
16
|
* PBRMetallicRoughness lighting model mixin
|
|
11
17
|
* @param BaseCls - Class to mix in
|
|
@@ -15,26 +21,42 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
15
21
|
if (BaseCls.pbrMetallicRoughnessMixed) {
|
|
16
22
|
return BaseCls;
|
|
17
23
|
}
|
|
18
|
-
const S = applyMaterialMixins(BaseCls, mixinPBRCommon, mixinLight, mixinTextureProps('metallicRoughness'), mixinTextureProps('specular'), mixinTextureProps('specularColor'));
|
|
24
|
+
const S = applyMaterialMixins(BaseCls, mixinPBRCommon, mixinLight, mixinTextureProps('metallicRoughness'), mixinTextureProps('specular'), mixinTextureProps('specularColor'), mixinTextureProps('anisotropyDirection'));
|
|
19
25
|
const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');
|
|
20
26
|
const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');
|
|
21
27
|
const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');
|
|
28
|
+
const REFLECTION_MODE_UNIFORM = S.defineInstanceUniform('reflectionMode', 'float', 'ReflectionMode');
|
|
29
|
+
const ANISOTROPY_UNIFORM = S.defineInstanceUniform('anisotropy', 'float', 'Anisotropy');
|
|
30
|
+
const ANISOTROPY_DIRECTION_UNIFORM = S.defineInstanceUniform('anisotropyDirection', 'float', 'AnisotropyDirection');
|
|
31
|
+
const ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM = S.defineInstanceUniform('anisotropyDirectionScaleBias', 'vec2', 'AnisotropyDirectionScaleBias');
|
|
22
32
|
return class extends S {
|
|
23
33
|
static pbrMetallicRoughnessMixed = true;
|
|
24
34
|
_metallic;
|
|
25
35
|
_roughness;
|
|
26
36
|
_specularFactor;
|
|
37
|
+
_reflectionMode;
|
|
38
|
+
_anisotropy;
|
|
39
|
+
_anisotropyDirection;
|
|
40
|
+
_anisotropyDirectionScaleBias;
|
|
27
41
|
constructor(){
|
|
28
42
|
super();
|
|
29
43
|
this._metallic = 1;
|
|
30
44
|
this._roughness = 1;
|
|
31
45
|
this._specularFactor = Vector4.one();
|
|
46
|
+
this._reflectionMode = 'ggx';
|
|
47
|
+
this._anisotropy = 0.75;
|
|
48
|
+
this._anisotropyDirection = 0;
|
|
49
|
+
this._anisotropyDirectionScaleBias = new Vector2(1, 0);
|
|
32
50
|
}
|
|
33
51
|
copyFrom(other) {
|
|
34
52
|
super.copyFrom(other);
|
|
35
53
|
this.metallic = other.metallic;
|
|
36
54
|
this.roughness = other.roughness;
|
|
37
55
|
this.specularFactor = other.specularFactor;
|
|
56
|
+
this.reflectionMode = other.reflectionMode;
|
|
57
|
+
this.anisotropy = other.anisotropy;
|
|
58
|
+
this.anisotropyDirection = other.anisotropyDirection;
|
|
59
|
+
this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;
|
|
38
60
|
}
|
|
39
61
|
get metallic() {
|
|
40
62
|
return this._metallic;
|
|
@@ -63,6 +85,154 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
63
85
|
this.uniformChanged();
|
|
64
86
|
}
|
|
65
87
|
}
|
|
88
|
+
directLighting(scope, lightDir, lightColor, normal, viewVec, commonData, diffuseScale, specularScale, sourceRadiusFactor, outColor) {
|
|
89
|
+
const pb = scope.$builder;
|
|
90
|
+
const that = this;
|
|
91
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
92
|
+
const funcName = 'Z_PBRMR_DirectLighting';
|
|
93
|
+
pb.func(funcName, [
|
|
94
|
+
pb.vec3('L'),
|
|
95
|
+
pb.vec3('lightColor'),
|
|
96
|
+
pb.vec3('normal'),
|
|
97
|
+
pb.vec3('viewVec'),
|
|
98
|
+
that.getCommonDatasStruct(scope)('data'),
|
|
99
|
+
pb.float('diffuseScale'),
|
|
100
|
+
pb.float('specularScale'),
|
|
101
|
+
pb.float('sourceRadiusFactor'),
|
|
102
|
+
pb.vec3('outColor').inout()
|
|
103
|
+
], function() {
|
|
104
|
+
this.$l.reflectionMode = instancing ? this.$inputs.zReflectionMode : this.zReflectionMode;
|
|
105
|
+
this.$l.anisotropy = instancing ? this.$inputs.zAnisotropy : this.zAnisotropy;
|
|
106
|
+
this.$l.anisotropyDirection = instancing ? this.$inputs.zAnisotropyDirection : this.zAnisotropyDirection;
|
|
107
|
+
this.$l.anisotropyDirectionScaleBias = instancing ? this.$inputs.zAnisotropyDirectionScaleBias : this.zAnisotropyDirectionScaleBias;
|
|
108
|
+
this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));
|
|
109
|
+
this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);
|
|
110
|
+
this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);
|
|
111
|
+
this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);
|
|
112
|
+
this.$if(pb.greaterThan(this.NoL, 0), function() {
|
|
113
|
+
this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);
|
|
114
|
+
this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);
|
|
115
|
+
if (that.iridescence) {
|
|
116
|
+
this.$l.F = pb.mix(this.schlickFresnel, this.data.iridescenceFresnel, this.data.iridescenceFactor.x);
|
|
117
|
+
} else {
|
|
118
|
+
this.$l.F = this.schlickFresnel;
|
|
119
|
+
}
|
|
120
|
+
this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);
|
|
121
|
+
this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);
|
|
122
|
+
this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
123
|
+
this.$l.D = this.Dggx;
|
|
124
|
+
this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function() {
|
|
125
|
+
this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);
|
|
126
|
+
if (that.anisotropyDirectionTexture) {
|
|
127
|
+
this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);
|
|
128
|
+
this.$l.dirAngle = pb.mul(pb.add(pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x), this.anisotropyDirectionScaleBias.y), Math.PI / 180);
|
|
129
|
+
}
|
|
130
|
+
this.$l.anisoAngle = this.dirAngle;
|
|
131
|
+
this.$l.up = pb.vec3(0, 1, 0);
|
|
132
|
+
this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));
|
|
133
|
+
this.$if(pb.lessThan(pb.length(this.t0), 0.001), function() {
|
|
134
|
+
this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));
|
|
135
|
+
});
|
|
136
|
+
this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));
|
|
137
|
+
this.$l.tangent = pb.normalize(pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle))));
|
|
138
|
+
this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));
|
|
139
|
+
this.$l.ToH = pb.dot(this.tangent, this.H);
|
|
140
|
+
this.$l.BoH = pb.dot(this.bitangent, this.H);
|
|
141
|
+
this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);
|
|
142
|
+
this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);
|
|
143
|
+
this.$l.anisoDenom = pb.mul(Math.PI, this.at, this.ab, pb.pow(pb.add(pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)), pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)), pb.mul(this.NoH, this.NoH)), 2));
|
|
144
|
+
this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));
|
|
145
|
+
}).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function() {
|
|
146
|
+
this.$l.glintNoise = pb.fract(pb.mul(pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))), 43758.5453));
|
|
147
|
+
this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);
|
|
148
|
+
this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));
|
|
149
|
+
});
|
|
150
|
+
this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);
|
|
151
|
+
this.$l.specular = pb.mul(this.lightColor, this.D, this.V, this.F, this.data.specularWeight, this.specularScale);
|
|
152
|
+
if (that.sheen) {
|
|
153
|
+
this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);
|
|
154
|
+
}
|
|
155
|
+
this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function() {
|
|
156
|
+
this.specular = pb.vec3(0);
|
|
157
|
+
});
|
|
158
|
+
this.outColor = pb.add(this.outColor, this.specular);
|
|
159
|
+
if (that.iridescence) {
|
|
160
|
+
this.$l.iridescenceFresnelMax = pb.vec3(pb.max(pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g), this.data.iridescenceFresnel.b));
|
|
161
|
+
this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);
|
|
162
|
+
}
|
|
163
|
+
this.$l.diffuseBRDF = pb.mul(pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)), pb.div(this.data.diffuse.rgb, Math.PI));
|
|
164
|
+
this.$l.diffuse = pb.mul(this.lightColor, pb.max(this.diffuseBRDF, pb.vec3(0)), this.diffuseScale);
|
|
165
|
+
if (that.transmission && that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
166
|
+
this.$l.transmissionRay = that.getVolumeTransmissionRay(this, this.normal, this.viewVec, this.data.thicknessFactor, this.data.f0.a);
|
|
167
|
+
this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));
|
|
168
|
+
this.$l.transmittedLight = pb.mul(this.lightColor, that.getPunctualRadianceTransmission(this, this.normal, this.viewVec, this.pointToLight, this.alphaRoughness, this.data.f0.rgb, this.data.f90.rgb, this.data.diffuse.rgb, this.data.f0.a));
|
|
169
|
+
this.transmittedLight = that.applyVolumeAttenuation(this, this.transmittedLight, pb.length(this.transmissionRay), this.data.attenuationColor, this.data.attenuationDistance);
|
|
170
|
+
this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);
|
|
171
|
+
}
|
|
172
|
+
if (that.sheen) {
|
|
173
|
+
this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);
|
|
174
|
+
}
|
|
175
|
+
this.outColor = pb.add(this.outColor, this.diffuse);
|
|
176
|
+
if (that.sheen) {
|
|
177
|
+
this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);
|
|
178
|
+
this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);
|
|
179
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV));
|
|
180
|
+
}
|
|
181
|
+
if (that.clearcoat) {
|
|
182
|
+
this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);
|
|
183
|
+
this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);
|
|
184
|
+
this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);
|
|
185
|
+
this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));
|
|
186
|
+
this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));
|
|
187
|
+
this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
188
|
+
this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);
|
|
189
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
scope.$g[funcName](lightDir, lightColor, normal, viewVec, commonData, diffuseScale, specularScale, sourceRadiusFactor, outColor);
|
|
194
|
+
}
|
|
195
|
+
get reflectionMode() {
|
|
196
|
+
return this._reflectionMode;
|
|
197
|
+
}
|
|
198
|
+
set reflectionMode(val) {
|
|
199
|
+
if (val !== this._reflectionMode) {
|
|
200
|
+
this._reflectionMode = val;
|
|
201
|
+
this.uniformChanged();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
get anisotropy() {
|
|
205
|
+
return this._anisotropy;
|
|
206
|
+
}
|
|
207
|
+
set anisotropy(val) {
|
|
208
|
+
const clamped = Math.max(-0.95, Math.min(0.95, val));
|
|
209
|
+
if (clamped !== this._anisotropy) {
|
|
210
|
+
this._anisotropy = clamped;
|
|
211
|
+
this.uniformChanged();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
get anisotropyDirection() {
|
|
215
|
+
return this._anisotropyDirection;
|
|
216
|
+
}
|
|
217
|
+
set anisotropyDirection(val) {
|
|
218
|
+
if (val !== this._anisotropyDirection) {
|
|
219
|
+
this._anisotropyDirection = val;
|
|
220
|
+
this.uniformChanged();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
get anisotropyDirectionScaleBias() {
|
|
224
|
+
return this._anisotropyDirectionScaleBias;
|
|
225
|
+
}
|
|
226
|
+
set anisotropyDirectionScaleBias(val) {
|
|
227
|
+
if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {
|
|
228
|
+
this._anisotropyDirectionScaleBias.set(val);
|
|
229
|
+
this.uniformChanged();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
calculateAnisotropyDirectionScaleBias(scope) {
|
|
233
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
234
|
+
return instancing ? scope.$inputs.zAnisotropyDirectionScaleBias : scope.zAnisotropyDirectionScaleBias;
|
|
235
|
+
}
|
|
66
236
|
PBRLight(scope, worldPos, normal, viewVec, albedo, TBN, outRoughness) {
|
|
67
237
|
const pb = scope.$builder;
|
|
68
238
|
const funcName = 'Z_PBRMetallicRoughnessLight';
|
|
@@ -85,17 +255,29 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
85
255
|
} else {
|
|
86
256
|
that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);
|
|
87
257
|
}
|
|
88
|
-
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, shadow) {
|
|
89
|
-
this.$
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.
|
|
97
|
-
|
|
98
|
-
|
|
258
|
+
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, extra, shadow) {
|
|
259
|
+
this.$if(pb.equal(type, LIGHT_TYPE_RECT), function() {
|
|
260
|
+
that.directRectLight(this, this.worldPos, this.normal, this.viewVec, this.pbrData, posRange, dirCutoff, extra, colorIntensity, this.lightingColor);
|
|
261
|
+
}).$else(function() {
|
|
262
|
+
this.$l.diffuse = pb.vec3();
|
|
263
|
+
this.$l.specular = pb.vec3();
|
|
264
|
+
this.$l.diffuseScale = pb.float(1);
|
|
265
|
+
this.$l.specularScale = pb.float(1);
|
|
266
|
+
this.$l.sourceRadiusFactor = pb.float(0);
|
|
267
|
+
this.$if(pb.equal(type, LIGHT_TYPE_POINT), function() {
|
|
268
|
+
this.diffuseScale = extra.x;
|
|
269
|
+
this.specularScale = extra.y;
|
|
270
|
+
this.sourceRadiusFactor = pb.div(extra.z, pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001));
|
|
271
|
+
});
|
|
272
|
+
this.$l.lightAtten = that.calculateLightAttenuation(this, type, this.worldPos, posRange, dirCutoff);
|
|
273
|
+
this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);
|
|
274
|
+
this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);
|
|
275
|
+
this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);
|
|
276
|
+
if (shadow) {
|
|
277
|
+
this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.worldPos, this.NoL));
|
|
278
|
+
}
|
|
279
|
+
that.directLighting(this, this.lightDir, this.lightColor, this.normal, this.viewVec, this.pbrData, this.diffuseScale, this.specularScale, this.sourceRadiusFactor, this.lightingColor);
|
|
280
|
+
});
|
|
99
281
|
});
|
|
100
282
|
this.$return(pb.add(this.lightingColor, this.emissiveColor));
|
|
101
283
|
});
|
|
@@ -107,6 +289,10 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
107
289
|
scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);
|
|
108
290
|
scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);
|
|
109
291
|
scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);
|
|
292
|
+
scope.$outputs.zReflectionMode = this.getInstancedUniform(scope, REFLECTION_MODE_UNIFORM);
|
|
293
|
+
scope.$outputs.zAnisotropy = this.getInstancedUniform(scope, ANISOTROPY_UNIFORM);
|
|
294
|
+
scope.$outputs.zAnisotropyDirection = this.getInstancedUniform(scope, ANISOTROPY_DIRECTION_UNIFORM);
|
|
295
|
+
scope.$outputs.zAnisotropyDirectionScaleBias = this.getInstancedUniform(scope, ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM);
|
|
110
296
|
}
|
|
111
297
|
}
|
|
112
298
|
fragmentShader(scope) {
|
|
@@ -117,6 +303,10 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
117
303
|
scope.zMetallic = pb.float().uniform(2);
|
|
118
304
|
scope.zRoughness = pb.float().uniform(2);
|
|
119
305
|
scope.zSpecularFactor = pb.vec4().uniform(2);
|
|
306
|
+
scope.zReflectionMode = pb.float().uniform(2);
|
|
307
|
+
scope.zAnisotropy = pb.float().uniform(2);
|
|
308
|
+
scope.zAnisotropyDirection = pb.float().uniform(2);
|
|
309
|
+
scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);
|
|
120
310
|
}
|
|
121
311
|
}
|
|
122
312
|
}
|
|
@@ -127,6 +317,10 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
127
317
|
bindGroup.setValue('zMetallic', this._metallic);
|
|
128
318
|
bindGroup.setValue('zRoughness', this._roughness);
|
|
129
319
|
bindGroup.setValue('zSpecularFactor', this._specularFactor);
|
|
320
|
+
bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);
|
|
321
|
+
bindGroup.setValue('zAnisotropy', this._anisotropy);
|
|
322
|
+
bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);
|
|
323
|
+
bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);
|
|
130
324
|
}
|
|
131
325
|
}
|
|
132
326
|
}
|
|
@@ -147,6 +341,7 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
147
341
|
const metallic = this.calculateMetallic(scope, albedo, normal);
|
|
148
342
|
const roughness = this.calculateRoughness(scope, albedo, normal);
|
|
149
343
|
const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);
|
|
344
|
+
const reflectionMode = this.calculateReflectionMode(scope);
|
|
150
345
|
if (this.metallicRoughnessTexture) {
|
|
151
346
|
scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);
|
|
152
347
|
data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);
|
|
@@ -166,11 +361,24 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
166
361
|
} else {
|
|
167
362
|
data.specularWeight = specularFactor.a;
|
|
168
363
|
}
|
|
364
|
+
data.specularWeight = pb.mul(data.specularWeight, pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none)));
|
|
169
365
|
data.f0 = pb.vec4(pb.mix(pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)), albedo.rgb, data.metallic), this.getF0(scope).a);
|
|
170
366
|
data.f90 = pb.vec3(1);
|
|
171
367
|
data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);
|
|
172
368
|
super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);
|
|
173
369
|
}
|
|
370
|
+
calculateReflectionMode(scope) {
|
|
371
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
372
|
+
return instancing ? scope.$inputs.zReflectionMode : scope.zReflectionMode;
|
|
373
|
+
}
|
|
374
|
+
calculateAnisotropy(scope) {
|
|
375
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
376
|
+
return instancing ? scope.$inputs.zAnisotropy : scope.zAnisotropy;
|
|
377
|
+
}
|
|
378
|
+
calculateAnisotropyDirection(scope) {
|
|
379
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
380
|
+
return instancing ? scope.$inputs.zAnisotropyDirection : scope.zAnisotropyDirection;
|
|
381
|
+
}
|
|
174
382
|
};
|
|
175
383
|
}
|
|
176
384
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport { MaterialVaryingFlags } from '../../../values';\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<['metallicRoughness', 'occlusion', 'specular', 'specularColor']>;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, shadow) {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.worldPos, this.NoL));\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor\r\n );\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n }\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","_metallic","_roughness","_specularFactor","Vector4","one","copyFrom","other","metallic","roughness","specularFactor","val","uniformChanged","equalsTo","set","PBRLight","scope","worldPos","normal","viewVec","albedo","TBN","outRoughness","pb","$builder","funcName","that","func","vec3","mat3","vec4","out","$l","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","type","posRange","dirCutoff","colorIntensity","shadow","diffuse","specular","lightAtten","calculateLightAttenuation","lightDir","calculateLightDirection","NoL","clamp","dot","lightColor","mul","rgb","a","calculateShadow","directLighting","$return","add","getGlobalScope","vertexShader","needFragmentColor","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","float","uniform","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","instancing","$inputs","calculateRoughness","calculateSpecularFactor","calculateCommonData","data","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","z","y","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","specularWeight","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AGrF,EAAGK,CAAAA,IAAI,CAAC,CAAA,CAAA;AACnB8D,YAAAA,IAAAA,CAAK7C,OAAO,GAAGtB,EAAAA,CAAGO,IAAI,CAACP,EAAAA,CAAGkF,GAAG,CAACrF,MAAAA,CAAOoC,GAAG,EAAEjC,EAAAA,CAAGK,IAAI,CAAC,CAAA,CAAA,EAAI8D,KAAKlF,QAAQ,CAAA,EAAGY,OAAOqC,CAAC,CAAA;AAC9E,YAAA,KAAK,CAACgC,mBAAoBzE,CAAAA,KAAAA,EAAOI,MAAQF,EAAAA,MAAAA,EAAQC,SAASE,GAAKqE,EAAAA,IAAAA,CAAAA;AACjE;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector2, Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport {\r\n LIGHT_TYPE_POINT,\r\n LIGHT_TYPE_RECT,\r\n MaterialVaryingFlags,\r\n RENDER_PASS_TYPE_LIGHT\r\n} from '../../../values';\r\n\r\nexport type PBRReflectionMode = 'none' | 'ggx' | 'anisotropic' | 'glint';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n reflectionMode: PBRReflectionMode;\r\n anisotropy: number;\r\n anisotropyDirection: number;\r\n anisotropyDirectionScaleBias: Vector2;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<\r\n ['metallicRoughness', 'occlusion', 'specular', 'specularColor', 'anisotropyDirection']\r\n >;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor'),\r\n mixinTextureProps('anisotropyDirection')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n const REFLECTION_MODE_UNIFORM = S.defineInstanceUniform('reflectionMode', 'float', 'ReflectionMode');\r\n const ANISOTROPY_UNIFORM = S.defineInstanceUniform('anisotropy', 'float', 'Anisotropy');\r\n const ANISOTROPY_DIRECTION_UNIFORM = S.defineInstanceUniform(\r\n 'anisotropyDirection',\r\n 'float',\r\n 'AnisotropyDirection'\r\n );\r\n const ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM = S.defineInstanceUniform(\r\n 'anisotropyDirectionScaleBias',\r\n 'vec2',\r\n 'AnisotropyDirectionScaleBias'\r\n );\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n private _reflectionMode: PBRReflectionMode;\r\n private _anisotropy: number;\r\n private _anisotropyDirection: number;\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n this._reflectionMode = 'ggx';\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n this.reflectionMode = other.reflectionMode;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n diffuseScale: PBShaderExp,\r\n specularScale: PBShaderExp,\r\n sourceRadiusFactor: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this as any;\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n const funcName = 'Z_PBRMR_DirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('normal'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.float('diffuseScale'),\r\n pb.float('specularScale'),\r\n pb.float('sourceRadiusFactor'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.reflectionMode = instancing ? this.$inputs.zReflectionMode : this.zReflectionMode;\r\n this.$l.anisotropy = instancing ? this.$inputs.zAnisotropy : this.zAnisotropy;\r\n this.$l.anisotropyDirection = instancing\r\n ? this.$inputs.zAnisotropyDirection\r\n : this.zAnisotropyDirection;\r\n this.$l.anisotropyDirectionScaleBias = instancing\r\n ? this.$inputs.zAnisotropyDirectionScaleBias\r\n : this.zAnisotropyDirectionScaleBias;\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n if (that.iridescence) {\r\n this.$l.F = pb.mix(\r\n this.schlickFresnel,\r\n this.data.iridescenceFresnel,\r\n this.data.iridescenceFactor.x\r\n );\r\n } else {\r\n this.$l.F = this.schlickFresnel;\r\n }\r\n this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);\r\n this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);\r\n this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.D = this.Dggx;\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function () {\r\n this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);\r\n if (that.anisotropyDirectionTexture) {\r\n this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);\r\n this.$l.dirAngle = pb.mul(\r\n pb.add(\r\n pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x),\r\n this.anisotropyDirectionScaleBias.y\r\n ),\r\n Math.PI / 180\r\n );\r\n }\r\n this.$l.anisoAngle = this.dirAngle;\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));\r\n this.$if(pb.lessThan(pb.length(this.t0), 0.001), function () {\r\n this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));\r\n });\r\n this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));\r\n this.$l.tangent = pb.normalize(\r\n pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle)))\r\n );\r\n this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));\r\n this.$l.ToH = pb.dot(this.tangent, this.H);\r\n this.$l.BoH = pb.dot(this.bitangent, this.H);\r\n this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);\r\n this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);\r\n this.$l.anisoDenom = pb.mul(\r\n Math.PI,\r\n this.at,\r\n this.ab,\r\n pb.pow(\r\n pb.add(\r\n pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)),\r\n pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)),\r\n pb.mul(this.NoH, this.NoH)\r\n ),\r\n 2\r\n )\r\n );\r\n this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));\r\n }).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function () {\r\n this.$l.glintNoise = pb.fract(\r\n pb.mul(\r\n pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))),\r\n 43758.5453\r\n )\r\n );\r\n this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);\r\n this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));\r\n });\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(\r\n this.lightColor,\r\n this.D,\r\n this.V,\r\n this.F,\r\n this.data.specularWeight,\r\n this.specularScale\r\n );\r\n if (that.sheen) {\r\n this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);\r\n }\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function () {\r\n this.specular = pb.vec3(0);\r\n });\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n if (that.iridescence) {\r\n this.$l.iridescenceFresnelMax = pb.vec3(\r\n pb.max(\r\n pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g),\r\n this.data.iridescenceFresnel.b\r\n )\r\n );\r\n this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);\r\n }\r\n this.$l.diffuseBRDF = pb.mul(\r\n pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)),\r\n pb.div(this.data.diffuse.rgb, Math.PI)\r\n );\r\n this.$l.diffuse = pb.mul(\r\n this.lightColor,\r\n pb.max(this.diffuseBRDF, pb.vec3(0)),\r\n this.diffuseScale\r\n );\r\n if (that.transmission && that.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n this.$l.transmissionRay = that.getVolumeTransmissionRay(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.data.thicknessFactor,\r\n this.data.f0.a\r\n );\r\n this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));\r\n this.$l.transmittedLight = pb.mul(\r\n this.lightColor,\r\n that.getPunctualRadianceTransmission(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pointToLight,\r\n this.alphaRoughness,\r\n this.data.f0.rgb,\r\n this.data.f90.rgb,\r\n this.data.diffuse.rgb,\r\n this.data.f0.a\r\n )\r\n );\r\n this.transmittedLight = that.applyVolumeAttenuation(\r\n this,\r\n this.transmittedLight,\r\n pb.length(this.transmissionRay),\r\n this.data.attenuationColor,\r\n this.data.attenuationDistance\r\n );\r\n this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);\r\n }\r\n if (that.sheen) {\r\n this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);\r\n }\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n if (that.sheen) {\r\n this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);\r\n this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);\r\n this.outColor = pb.add(\r\n this.outColor,\r\n pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV)\r\n );\r\n }\r\n if (that.clearcoat) {\r\n this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);\r\n this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);\r\n this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);\r\n this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));\r\n this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));\r\n this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);\r\n this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));\r\n }\r\n });\r\n }\r\n );\r\n scope.$g[funcName](\r\n lightDir,\r\n lightColor,\r\n normal,\r\n viewVec,\r\n commonData,\r\n diffuseScale,\r\n specularScale,\r\n sourceRadiusFactor,\r\n outColor\r\n );\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n calculateAnisotropyDirectionScaleBias(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (\r\n instancing ? scope.$inputs.zAnisotropyDirectionScaleBias : scope.zAnisotropyDirectionScaleBias\r\n ) as PBShaderExp;\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\r\n that.directRectLight(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n posRange,\r\n dirCutoff,\r\n extra,\r\n colorIntensity,\r\n this.lightingColor\r\n );\r\n }).$else(function () {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.diffuseScale = pb.float(1);\r\n this.$l.specularScale = pb.float(1);\r\n this.$l.sourceRadiusFactor = pb.float(0);\r\n this.$if(pb.equal(type, LIGHT_TYPE_POINT), function () {\r\n this.diffuseScale = extra.x;\r\n this.specularScale = extra.y;\r\n this.sourceRadiusFactor = pb.div(\r\n extra.z,\r\n pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001)\r\n );\r\n });\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(\r\n this.lightColor,\r\n that.calculateShadow(this, this.worldPos, this.NoL)\r\n );\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.diffuseScale,\r\n this.specularScale,\r\n this.sourceRadiusFactor,\r\n this.lightingColor\r\n );\r\n });\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n scope.$outputs.zReflectionMode = this.getInstancedUniform(scope, REFLECTION_MODE_UNIFORM);\r\n scope.$outputs.zAnisotropy = this.getInstancedUniform(scope, ANISOTROPY_UNIFORM);\r\n scope.$outputs.zAnisotropyDirection = this.getInstancedUniform(scope, ANISOTROPY_DIRECTION_UNIFORM);\r\n scope.$outputs.zAnisotropyDirectionScaleBias = this.getInstancedUniform(\r\n scope,\r\n ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM\r\n );\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n scope.zReflectionMode = pb.float().uniform(2);\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n }\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n const reflectionMode = this.calculateReflectionMode(scope) as PBShaderExp;\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.specularWeight = pb.mul(\r\n data.specularWeight,\r\n pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none))\r\n );\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n calculateReflectionMode(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zReflectionMode : scope.zReflectionMode) as PBShaderExp;\r\n }\r\n calculateAnisotropy(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zAnisotropy : scope.zAnisotropy) as PBShaderExp;\r\n }\r\n calculateAnisotropyDirection(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zAnisotropyDirection : scope.zAnisotropyDirection) as PBShaderExp;\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","REFLECTION_MODE_UNIFORM","ANISOTROPY_UNIFORM","ANISOTROPY_DIRECTION_UNIFORM","ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM","_metallic","_roughness","_specularFactor","_reflectionMode","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector4","one","Vector2","copyFrom","other","metallic","roughness","specularFactor","reflectionMode","anisotropy","anisotropyDirection","anisotropyDirectionScaleBias","val","uniformChanged","equalsTo","set","directLighting","scope","lightDir","lightColor","normal","viewVec","commonData","diffuseScale","specularScale","sourceRadiusFactor","outColor","pb","$builder","that","instancing","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","funcName","func","vec3","getCommonDatasStruct","float","inout","$l","$inputs","zReflectionMode","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","H","normalize","add","L","NoH","clamp","dot","NoL","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","data","f0","rgb","f90","iridescence","F","mix","iridescenceFresnel","iridescenceFactor","x","specularRoughness","alphaRoughness","mul","Dggx","distributionGGX","D","equal","dirAngle","Math","PI","anisotropyDirectionTexture","dirSample","sampleAnisotropyDirectionTexture","r","y","anisoAngle","up","t0","cross","lessThan","length","b0","tangent","cos","sin","bitangent","ToH","BoH","at","max","ab","sub","anisoDenom","pow","div","$elseif","glintNoise","fract","glintMask","smoothStep","V","visGGX","specular","specularWeight","sheen","sheenAlbedoScaling","iridescenceFresnelMax","g","b","diffuseBRDF","diffuse","transmission","renderPass","type","RENDER_PASS_TYPE_LIGHT","transmissionRay","getVolumeTransmissionRay","thicknessFactor","a","pointToLight","transmittedLight","getPunctualRadianceTransmission","applyVolumeAttenuation","attenuationColor","attenuationDistance","transmissionFactor","sheenD","D_Charlie","sheenRoughness","sheenV","V_Ashikhmin","sheenColor","clearcoat","ccFactor","ccNormal","ccF0","ccNoV","$g","clamped","min","calculateAnisotropyDirectionScaleBias","PBRLight","worldPos","albedo","TBN","outRoughness","mat3","vec4","out","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","LIGHT_TYPE_RECT","directRectLight","$else","LIGHT_TYPE_POINT","z","distance","xyz","lightAtten","calculateLightAttenuation","calculateLightDirection","calculateShadow","$return","getGlobalScope","vertexShader","needFragmentColor","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","uniform","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","calculateRoughness","calculateSpecularFactor","calculateCommonData","calculateReflectionMode","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","sampleSpecularTexture","notEqual","getF0","calculateAnisotropy","calculateAnisotropyDirection"],"mappings":";;;;;;;;AAsBA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC,WAAa,EAAA,CAAA;IACbC,KAAO,EAAA;AACT,CAAA;AA4CA;;;;;IAMO,SAASC,yBAAAA,CAAyDC,OAAU,EAAA;IACjF,IAAKA,OAAgBC,CAAAA,yBAAyB,EAAE;QAC9C,OAAOD,OAAAA;AACT;IACA,MAAME,CAAAA,GAAIC,mBACRH,CAAAA,OAAAA,EACAI,cACAC,EAAAA,UAAAA,EACAC,iBAAkB,CAAA,mBAAA,CAAA,EAClBA,iBAAkB,CAAA,UAAA,CAAA,EAClBA,iBAAkB,CAAA,eAAA,CAAA,EAClBA,iBAAkB,CAAA,qBAAA,CAAA,CAAA;AAEpB,IAAA,MAAMC,gBAAmBL,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,YAAY,OAAS,EAAA,UAAA,CAAA;AACtE,IAAA,MAAMC,iBAAoBP,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,aAAa,OAAS,EAAA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AAMa,UAAa,GAAA,CAAC,EAAE,IAAI,CAACC,WAAW,CAACC,aAAa,GAAGC,oBAAqBC,CAAAA,UAAU,CAAD;AACrF,YAAA,OAAQJ,aAAab,KAAMyB,CAAAA,OAAO,CAACE,WAAW,GAAG3B,MAAM2B,WAAW;AACpE;AACAgL,QAAAA,4BAAAA,CAA6B3M,KAA4B,EAAE;AACzD,YAAA,MAAMa,UAAa,GAAA,CAAC,EAAE,IAAI,CAACC,WAAW,CAACC,aAAa,GAAGC,oBAAqBC,CAAAA,UAAU,CAAD;AACrF,YAAA,OAAQJ,aAAab,KAAMyB,CAAAA,OAAO,CAACG,oBAAoB,GAAG5B,MAAM4B,oBAAoB;AACtF;AACF,KAAA;AACF;;;;"}
|
|
@@ -4,7 +4,7 @@ import { mixinPBRCommon } from '../pbr/common.js';
|
|
|
4
4
|
import { Vector3 } from '@zephyr3d/base';
|
|
5
5
|
import { mixinLight } from '../lit.js';
|
|
6
6
|
import { ShaderHelper } from '../../shader/helper.js';
|
|
7
|
-
import { MaterialVaryingFlags } from '../../../values.js';
|
|
7
|
+
import { MaterialVaryingFlags, LIGHT_TYPE_RECT, LIGHT_TYPE_POINT } from '../../../values.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* PBRSpecularGlossiness mixin
|
|
@@ -96,17 +96,29 @@ import { MaterialVaryingFlags } from '../../../values.js';
|
|
|
96
96
|
} else {
|
|
97
97
|
that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);
|
|
98
98
|
}
|
|
99
|
-
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, shadow) {
|
|
100
|
-
this.$
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
|
|
109
|
-
|
|
99
|
+
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, extra, shadow) {
|
|
100
|
+
this.$if(pb.equal(type, LIGHT_TYPE_RECT), function() {
|
|
101
|
+
that.directRectLight(this, this.worldPos, this.normal, this.viewVec, this.pbrData, posRange, dirCutoff, extra, colorIntensity, this.lightingColor);
|
|
102
|
+
}).$else(function() {
|
|
103
|
+
this.$l.diffuse = pb.vec3();
|
|
104
|
+
this.$l.specular = pb.vec3();
|
|
105
|
+
this.$l.diffuseScale = pb.float(1);
|
|
106
|
+
this.$l.specularScale = pb.float(1);
|
|
107
|
+
this.$l.sourceRadiusFactor = pb.float(0);
|
|
108
|
+
this.$if(pb.equal(type, LIGHT_TYPE_POINT), function() {
|
|
109
|
+
this.diffuseScale = extra.x;
|
|
110
|
+
this.specularScale = extra.y;
|
|
111
|
+
this.sourceRadiusFactor = pb.div(extra.z, pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001));
|
|
112
|
+
});
|
|
113
|
+
this.$l.lightAtten = that.calculateLightAttenuation(this, type, this.worldPos, posRange, dirCutoff);
|
|
114
|
+
this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);
|
|
115
|
+
this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);
|
|
116
|
+
this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);
|
|
117
|
+
if (shadow) {
|
|
118
|
+
this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.worldPos, this.NoL));
|
|
119
|
+
}
|
|
120
|
+
that.directLighting(this, this.lightDir, this.lightColor, this.normal, this.viewVec, this.pbrData, this.diffuseScale, this.specularScale, this.sourceRadiusFactor, this.lightingColor);
|
|
121
|
+
});
|
|
110
122
|
});
|
|
111
123
|
this.$return(pb.add(this.lightingColor, this.emissiveColor));
|
|
112
124
|
});
|