@zephyr3d/scene 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asset/assetmanager.js +124 -67
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/builtin.js +2 -2
- package/dist/asset/loaders/gltf/gltf_loader.js +105 -59
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/hdr/hdr.js +1 -1
- package/dist/blitter/blitter.js +0 -1
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/depthlimitedgaussion.js +0 -1
- package/dist/blitter/depthlimitedgaussion.js.map +1 -1
- package/dist/blitter/gaussianblur.js +0 -1
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/camera.js +10 -8
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/orbit.js +24 -7
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +1842 -2484
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +47 -57
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/grassmat.js +127 -0
- package/dist/material/grassmat.js.map +1 -0
- package/dist/material/grassmaterial.js +66 -194
- package/dist/material/grassmaterial.js.map +1 -1
- package/dist/material/lambert.js +48 -22
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/lightmodel.js +4 -4
- package/dist/material/material.js +100 -59
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +227 -186
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +29 -100
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/foliage.js +47 -0
- package/dist/material/mixins/foliage.js.map +1 -0
- package/dist/material/mixins/ggxlut.js +213 -0
- package/dist/material/mixins/ggxlut.js.map +1 -0
- package/dist/material/mixins/lightmodel/blinnphong.js +89 -0
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -0
- package/dist/material/mixins/lightmodel/lambert.js +58 -0
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -0
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +132 -0
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +105 -0
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
- package/dist/material/mixins/lit.js +464 -0
- package/dist/material/mixins/lit.js.map +1 -0
- package/dist/material/mixins/pbr/common.js +451 -0
- package/dist/material/mixins/pbr/common.js.map +1 -0
- package/dist/material/mixins/pbr/metallicroughness.js +126 -0
- package/dist/material/mixins/pbr/metallicroughness.js.map +1 -0
- package/dist/material/mixins/pbr/specularglossness.js +104 -0
- package/dist/material/mixins/pbr/specularglossness.js.map +1 -0
- package/dist/material/mixins/texture.js +157 -0
- package/dist/material/mixins/texture.js.map +1 -0
- package/dist/material/mixins/vertexcolor.js +16 -11
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/pbrmr.js +65 -0
- package/dist/material/pbrmr.js.map +1 -0
- package/dist/material/pbrsg.js +64 -0
- package/dist/material/pbrsg.js.map +1 -0
- package/dist/material/shader/helper.js +903 -0
- package/dist/material/shader/helper.js.map +1 -0
- package/dist/material/terrainmat.js +357 -0
- package/dist/material/terrainmat.js.map +1 -0
- package/dist/material/terrainmaterial.js +311 -103
- package/dist/material/terrainmaterial.js.map +1 -1
- package/dist/material/unlit.js +12 -9
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/bloom.js +8 -6
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +14 -6
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/posteffect.js +1 -1
- package/dist/posteffect/sao.js +8 -5
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/tonemap.js +2 -2
- package/dist/posteffect/water.js +10 -8
- package/dist/posteffect/water.js.map +1 -1
- package/dist/render/cluster_light.js +6 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/depthpass.js +46 -0
- package/dist/render/depthpass.js.map +1 -0
- package/dist/render/envlight.js +26 -24
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fullscreenquad.js +38 -0
- package/dist/render/fullscreenquad.js.map +1 -0
- package/dist/render/lightpass.js +98 -0
- package/dist/render/lightpass.js.map +1 -0
- package/dist/render/render_queue.js +2 -1
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +191 -0
- package/dist/render/renderer.js.map +1 -0
- package/dist/render/renderpass.js +10 -8
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +3 -4
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +31 -15
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/environment.js +8 -6
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +3 -0
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/mesh.js +13 -12
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/scene.js +11 -15
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +10 -16
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +4 -14
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/patch.js +3 -3
- package/dist/scene/terrain/terrain.js +4 -9
- package/dist/scene/terrain/terrain.js.map +1 -1
- package/dist/shaders/framework.js +17 -3
- package/dist/shaders/framework.js.map +1 -1
- package/dist/shaders/misc.js +13 -161
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +7 -7
- package/dist/shaders/pbr.js +1 -82
- package/dist/shaders/pbr.js.map +1 -1
- package/dist/shaders/shadow.js +33 -31
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/water.js +3 -9
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/esm.js +11 -9
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -15
- package/dist/shadow/pcf_pd.js +15 -15
- package/dist/shadow/shadowmapper.js +13 -15
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +21 -55
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +15 -13
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/torus.js +2 -2
- package/dist/utility/bounding_volume.js +27 -27
- package/dist/utility/pmrem.js +4 -4
- package/dist/utility/sheenlut.js +196 -0
- package/dist/utility/sheenlut.js.map +1 -0
- package/dist/utility/shprojection.js +0 -1
- package/dist/utility/shprojection.js.map +1 -1
- package/dist/values.js +11 -8
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
|
+
import { Vector4 } from '@zephyr3d/base';
|
|
3
|
+
import { getGGXLUT } from '../ggxlut.js';
|
|
4
|
+
import { mixinTextureProps } from '../texture.js';
|
|
5
|
+
import { ShaderHelper } from '../../shader/helper.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* PBR common stuff mixin
|
|
9
|
+
* @param BaseCls - Class to mix in
|
|
10
|
+
* @returns Mixed class
|
|
11
|
+
*/ function mixinPBRCommon(BaseCls) {
|
|
12
|
+
if (BaseCls.pbrCommonMixed) {
|
|
13
|
+
return BaseCls;
|
|
14
|
+
}
|
|
15
|
+
const S = applyMaterialMixins(BaseCls, mixinTextureProps('occlusion'), mixinTextureProps('emissive'), mixinTextureProps('sheenColor'), mixinTextureProps('sheenRoughness'), mixinTextureProps('clearcoatIntensity'), mixinTextureProps('clearcoatRoughness'), mixinTextureProps('clearcoatNormal'));
|
|
16
|
+
let FEATURE_SHEEN = 0;
|
|
17
|
+
let FEATURE_CLEARCOAT = 0;
|
|
18
|
+
const cls = class extends S {
|
|
19
|
+
static pbrCommonMixed = true;
|
|
20
|
+
_f0;
|
|
21
|
+
_emissiveFactor;
|
|
22
|
+
_occlusionStrength;
|
|
23
|
+
_sheenFactor;
|
|
24
|
+
_clearcoatFactor;
|
|
25
|
+
constructor(){
|
|
26
|
+
super();
|
|
27
|
+
this._f0 = new Vector4(0.04, 0.04, 0.04, 1.5);
|
|
28
|
+
this._occlusionStrength = 1;
|
|
29
|
+
this._emissiveFactor = new Vector4(0, 0, 0, 1);
|
|
30
|
+
this._sheenFactor = Vector4.zero();
|
|
31
|
+
this._clearcoatFactor = new Vector4(0, 0, 1, 0);
|
|
32
|
+
}
|
|
33
|
+
get ior() {
|
|
34
|
+
return this._f0.w;
|
|
35
|
+
}
|
|
36
|
+
set ior(val) {
|
|
37
|
+
if (val !== this._f0.w) {
|
|
38
|
+
let k = (val - 1) / (val + 1);
|
|
39
|
+
k *= k;
|
|
40
|
+
this._f0.setXYZW(k, k, k, val);
|
|
41
|
+
this.uniformChanged();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
get occlusionStrength() {
|
|
45
|
+
return this._occlusionStrength;
|
|
46
|
+
}
|
|
47
|
+
set occlusionStrength(val) {
|
|
48
|
+
if (val !== this._occlusionStrength) {
|
|
49
|
+
this._occlusionStrength = val;
|
|
50
|
+
this.uniformChanged();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
get emissiveColor() {
|
|
54
|
+
return this._emissiveFactor.xyz();
|
|
55
|
+
}
|
|
56
|
+
set emissiveColor(val) {
|
|
57
|
+
if (val.x !== this._emissiveFactor.x || val.y !== this._emissiveFactor.y || val.z !== this._emissiveFactor.z) {
|
|
58
|
+
this._emissiveFactor.x = val.x;
|
|
59
|
+
this._emissiveFactor.y = val.y;
|
|
60
|
+
this._emissiveFactor.z = val.z;
|
|
61
|
+
this.uniformChanged();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
get emissiveStrength() {
|
|
65
|
+
return this._emissiveFactor.w;
|
|
66
|
+
}
|
|
67
|
+
set emissiveStrength(val) {
|
|
68
|
+
if (this._emissiveFactor.w !== val) {
|
|
69
|
+
this._emissiveFactor.w = val;
|
|
70
|
+
this.uniformChanged();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
get clearcoat() {
|
|
74
|
+
return this.featureUsed(FEATURE_CLEARCOAT);
|
|
75
|
+
}
|
|
76
|
+
set clearcoat(val) {
|
|
77
|
+
this.useFeature(FEATURE_CLEARCOAT, !!val);
|
|
78
|
+
}
|
|
79
|
+
get clearcoatIntensity() {
|
|
80
|
+
return this._clearcoatFactor.x;
|
|
81
|
+
}
|
|
82
|
+
set clearcoatIntensity(val) {
|
|
83
|
+
if (val !== this._clearcoatFactor.x) {
|
|
84
|
+
this._clearcoatFactor.x = val;
|
|
85
|
+
this.uniformChanged();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
get clearcoatRoughnessFactor() {
|
|
89
|
+
return this._clearcoatFactor.y;
|
|
90
|
+
}
|
|
91
|
+
set clearcoatRoughnessFactor(val) {
|
|
92
|
+
if (val !== this._clearcoatFactor.y) {
|
|
93
|
+
this._clearcoatFactor.y = val;
|
|
94
|
+
this.uniformChanged();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
get clearcoatNormalScale() {
|
|
98
|
+
return this._clearcoatFactor.z;
|
|
99
|
+
}
|
|
100
|
+
set clearcoatNormalScale(val) {
|
|
101
|
+
if (val !== this._clearcoatFactor.z) {
|
|
102
|
+
this._clearcoatFactor.z = val;
|
|
103
|
+
this.uniformChanged();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get sheen() {
|
|
107
|
+
return this.featureUsed(FEATURE_SHEEN);
|
|
108
|
+
}
|
|
109
|
+
set sheen(val) {
|
|
110
|
+
this.useFeature(FEATURE_SHEEN, !!val);
|
|
111
|
+
}
|
|
112
|
+
get sheenColorFactor() {
|
|
113
|
+
return this._sheenFactor.xyz();
|
|
114
|
+
}
|
|
115
|
+
set sheenColorFactor(val) {
|
|
116
|
+
if (val.x !== this._sheenFactor.x || val.y !== this._sheenFactor.y || val.z !== this._sheenFactor.z) {
|
|
117
|
+
this._sheenFactor.x = val.x;
|
|
118
|
+
this._sheenFactor.y = val.y;
|
|
119
|
+
this._sheenFactor.z = val.z;
|
|
120
|
+
this.uniformChanged();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
get sheenRoughnessFactor() {
|
|
124
|
+
return this._sheenFactor.w;
|
|
125
|
+
}
|
|
126
|
+
set sheenRoughnessFactor(val) {
|
|
127
|
+
if (val !== this._sheenFactor.w) {
|
|
128
|
+
this._sheenFactor.w = val;
|
|
129
|
+
this.uniformChanged();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
fragmentShader(scope) {
|
|
133
|
+
const pb = scope.$builder;
|
|
134
|
+
super.fragmentShader(scope);
|
|
135
|
+
if (this.needFragmentColor()) {
|
|
136
|
+
scope.zF0 = pb.vec4().uniform(2);
|
|
137
|
+
scope.zEmissiveFactor = pb.vec4().uniform(2);
|
|
138
|
+
if (this.occlusionTexture) {
|
|
139
|
+
scope.zOcclusionStrength = pb.float().uniform(2);
|
|
140
|
+
}
|
|
141
|
+
if (this.sheen) {
|
|
142
|
+
scope.zSheenFactor = pb.vec4().uniform(2);
|
|
143
|
+
}
|
|
144
|
+
if (this.clearcoat) {
|
|
145
|
+
scope.zClearcoatFactor = pb.vec4().uniform(2);
|
|
146
|
+
}
|
|
147
|
+
if (this.drawContext.drawEnvLight) {
|
|
148
|
+
scope.zGGXLut = pb.tex2D().uniform(2);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
applyUniformValues(bindGroup, ctx, pass) {
|
|
153
|
+
super.applyUniformValues(bindGroup, ctx, pass);
|
|
154
|
+
if (this.needFragmentColor(ctx)) {
|
|
155
|
+
bindGroup.setValue('zF0', this._f0);
|
|
156
|
+
bindGroup.setValue('zEmissiveFactor', this._emissiveFactor);
|
|
157
|
+
if (this.occlusionTexture) {
|
|
158
|
+
bindGroup.setValue('zOcclusionStrength', this._occlusionStrength);
|
|
159
|
+
}
|
|
160
|
+
if (this.sheen) {
|
|
161
|
+
bindGroup.setValue('zSheenFactor', this._sheenFactor);
|
|
162
|
+
}
|
|
163
|
+
if (this.clearcoat) {
|
|
164
|
+
bindGroup.setValue('zClearcoatFactor', this._clearcoatFactor);
|
|
165
|
+
}
|
|
166
|
+
if (ctx.drawEnvLight) {
|
|
167
|
+
bindGroup.setTexture('zGGXLut', getGGXLUT(1024));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
getF0(scope) {
|
|
172
|
+
return scope.zF0;
|
|
173
|
+
}
|
|
174
|
+
getCommonDatasStruct(scope) {
|
|
175
|
+
const pb = scope.$builder;
|
|
176
|
+
return pb.defineStruct([
|
|
177
|
+
pb.vec4('f0'),
|
|
178
|
+
pb.vec3('f90'),
|
|
179
|
+
pb.vec4('diffuse'),
|
|
180
|
+
pb.float('metallic'),
|
|
181
|
+
pb.float('roughness'),
|
|
182
|
+
pb.float('specularWeight'),
|
|
183
|
+
...this.sheen ? [
|
|
184
|
+
pb.float('sheenAlbedoScaling'),
|
|
185
|
+
pb.vec3('sheenColor'),
|
|
186
|
+
pb.float('sheenRoughness')
|
|
187
|
+
] : [],
|
|
188
|
+
...this.clearcoat ? [
|
|
189
|
+
pb.vec4('ccFactor'),
|
|
190
|
+
pb.vec3('ccNormal'),
|
|
191
|
+
pb.float('ccNoV'),
|
|
192
|
+
pb.float('ccFresnel')
|
|
193
|
+
] : []
|
|
194
|
+
]);
|
|
195
|
+
}
|
|
196
|
+
getCommonData(scope, albedo, viewVec, TBN) {
|
|
197
|
+
const pb = scope.$builder;
|
|
198
|
+
const that = this;
|
|
199
|
+
const funcName = 'Z_getCommonData';
|
|
200
|
+
pb.func(funcName, [
|
|
201
|
+
pb.vec4('albedo'),
|
|
202
|
+
pb.vec3('viewVec'),
|
|
203
|
+
pb.mat3('TBN')
|
|
204
|
+
], function() {
|
|
205
|
+
this.$l.data = that.getCommonDatasStruct(this)();
|
|
206
|
+
that.calculateCommonData(this, this.albedo, this.viewVec, this.TBN, this.data);
|
|
207
|
+
this.$return(this.data);
|
|
208
|
+
});
|
|
209
|
+
return scope.$g[funcName](albedo, viewVec, TBN);
|
|
210
|
+
}
|
|
211
|
+
calculateCommonData(scope, albedo, viewVec, TBN, data) {
|
|
212
|
+
const pb = scope.$builder;
|
|
213
|
+
if (this.sheen) {
|
|
214
|
+
if (this.sheenColorTexture) {
|
|
215
|
+
data.sheenColor = pb.mul(this.sampleSheenColorTexture(scope).rgb, scope.zSheenFactor.rgb);
|
|
216
|
+
} else {
|
|
217
|
+
data.sheenColor = scope.zSheenFactor.rgb;
|
|
218
|
+
}
|
|
219
|
+
if (this.sheenRoughnessTexture) {
|
|
220
|
+
data.sheenRoughness = pb.mul(this.sampleSheenRoughnessTexture(scope).a, scope.zSheenFactor.a);
|
|
221
|
+
} else {
|
|
222
|
+
data.sheenRoughness = scope.zSheenFactor.a;
|
|
223
|
+
}
|
|
224
|
+
scope.$l.sheenDFG = 0.157;
|
|
225
|
+
data.sheenAlbedoScaling = pb.sub(1, pb.mul(pb.max(pb.max(data.sheenColor.r, data.sheenColor.g), data.sheenColor.b), scope.sheenDFG));
|
|
226
|
+
}
|
|
227
|
+
if (this.clearcoat) {
|
|
228
|
+
if (this.clearcoatNormalTexture) {
|
|
229
|
+
const ccNormal = pb.mul(pb.sub(pb.mul(this.sampleClearcoatNormalTexture(scope).rgb, 2), pb.vec3(1)), pb.vec3(scope.zClearcoatFactor.zz, 1));
|
|
230
|
+
data.ccNormal = pb.normalize(pb.mul(TBN, ccNormal));
|
|
231
|
+
} else {
|
|
232
|
+
data.ccNormal = TBN[2];
|
|
233
|
+
}
|
|
234
|
+
data.ccNoV = pb.clamp(pb.dot(data.ccNormal, viewVec), 0.0001, 1);
|
|
235
|
+
data.ccFactor = scope.zClearcoatFactor;
|
|
236
|
+
if (this.clearcoatIntensityTexture) {
|
|
237
|
+
data.ccFactor.x = pb.mul(data.ccFactor.x, this.sampleClearcoatIntensityTexture(scope).r);
|
|
238
|
+
}
|
|
239
|
+
if (this.clearcoatRoughnessTexture) {
|
|
240
|
+
data.ccFactor.y = pb.clamp(pb.mul(data.ccFactor.y, this.sampleClearcoatRoughnessTexture(scope).g), 0, 1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
calculateEmissiveColor(scope) {
|
|
245
|
+
const pb = scope.$builder;
|
|
246
|
+
if (this.emissiveTexture) {
|
|
247
|
+
return pb.mul(this.sampleEmissiveTexture(scope).rgb, scope.zEmissiveFactor.rgb, scope.zEmissiveFactor.a);
|
|
248
|
+
} else {
|
|
249
|
+
return pb.mul(scope.zEmissiveFactor.rgb, scope.zEmissiveFactor.a);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
D_Charlie(scope, NdotH, sheenRoughness) {
|
|
253
|
+
const funcNameDCharlie = 'Z_DCharlie';
|
|
254
|
+
const pb = scope.$builder;
|
|
255
|
+
pb.func(funcNameDCharlie, [
|
|
256
|
+
pb.float('NdotH'),
|
|
257
|
+
pb.float('sheenRoughness')
|
|
258
|
+
], function() {
|
|
259
|
+
this.$l.alphaG = pb.mul(this.sheenRoughness, this.sheenRoughness);
|
|
260
|
+
this.$l.invR = pb.div(1, this.alphaG);
|
|
261
|
+
this.$l.cos2h = pb.mul(this.NdotH, this.NdotH);
|
|
262
|
+
this.$l.sin2h = pb.max(pb.sub(1, this.cos2h), 0.0078125);
|
|
263
|
+
this.$return(pb.div(pb.mul(pb.add(this.invR, 2), pb.pow(this.sin2h, pb.mul(this.invR, 0.5))), 2 * Math.PI));
|
|
264
|
+
});
|
|
265
|
+
return scope.$g[funcNameDCharlie](NdotH, sheenRoughness);
|
|
266
|
+
}
|
|
267
|
+
V_Ashikhmin(scope, NdotL, NdotV) {
|
|
268
|
+
const funcNameVAshikhmin = 'Z_VAshikhmin';
|
|
269
|
+
const pb = scope.$builder;
|
|
270
|
+
pb.func(funcNameVAshikhmin, [
|
|
271
|
+
pb.float('NdotL'),
|
|
272
|
+
pb.float('NdotV')
|
|
273
|
+
], function() {
|
|
274
|
+
this.$return(pb.clamp(pb.div(1, pb.mul(pb.sub(pb.add(this.NdotL, this.NdotV), pb.mul(this.NdotL, this.NdotV)), 4)), 0, 1));
|
|
275
|
+
});
|
|
276
|
+
return scope.$g[funcNameVAshikhmin](NdotL, NdotV);
|
|
277
|
+
}
|
|
278
|
+
directLighting(scope, lightDir, lightColor, normal, viewVec, commonData, outColor) {
|
|
279
|
+
const pb = scope.$builder;
|
|
280
|
+
const that = this;
|
|
281
|
+
const funcName = 'Z_PBRDirectLighting';
|
|
282
|
+
pb.func(funcName, [
|
|
283
|
+
pb.vec3('L'),
|
|
284
|
+
pb.vec3('lightColor'),
|
|
285
|
+
pb.vec3('normal'),
|
|
286
|
+
pb.vec3('viewVec'),
|
|
287
|
+
that.getCommonDatasStruct(scope)('data'),
|
|
288
|
+
pb.vec3('outColor').inout()
|
|
289
|
+
], function() {
|
|
290
|
+
this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));
|
|
291
|
+
this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);
|
|
292
|
+
this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);
|
|
293
|
+
this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);
|
|
294
|
+
this.$if(pb.greaterThan(this.NoL, 0), function() {
|
|
295
|
+
this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);
|
|
296
|
+
this.$l.F = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);
|
|
297
|
+
this.$l.alphaRoughness = pb.mul(this.data.roughness, this.data.roughness);
|
|
298
|
+
this.$l.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
299
|
+
this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);
|
|
300
|
+
this.$l.specular = pb.mul(this.lightColor, this.D, this.V, this.F, this.data.specularWeight);
|
|
301
|
+
if (that.sheen) {
|
|
302
|
+
this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);
|
|
303
|
+
}
|
|
304
|
+
this.outColor = pb.add(this.outColor, this.specular);
|
|
305
|
+
this.$l.diffuse = pb.mul(this.lightColor, pb.max(pb.mul(pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)), pb.div(this.data.diffuse.rgb, Math.PI)), pb.vec3(0)));
|
|
306
|
+
if (that.sheen) {
|
|
307
|
+
this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);
|
|
308
|
+
}
|
|
309
|
+
this.outColor = pb.add(this.outColor, this.diffuse);
|
|
310
|
+
if (that.sheen) {
|
|
311
|
+
this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);
|
|
312
|
+
this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);
|
|
313
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV));
|
|
314
|
+
}
|
|
315
|
+
if (that.clearcoat) {
|
|
316
|
+
this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);
|
|
317
|
+
this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);
|
|
318
|
+
this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);
|
|
319
|
+
this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));
|
|
320
|
+
this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));
|
|
321
|
+
this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
322
|
+
this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);
|
|
323
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
scope.$g[funcName](lightDir, lightColor, normal, viewVec, commonData, outColor);
|
|
328
|
+
}
|
|
329
|
+
indirectLighting(scope, normal, viewVec, commonData, outColor) {
|
|
330
|
+
const pb = scope.$builder;
|
|
331
|
+
const that = this;
|
|
332
|
+
const ctx = that.drawContext;
|
|
333
|
+
const funcName = 'Z_PBRIndirectLighting';
|
|
334
|
+
pb.func(funcName, [
|
|
335
|
+
pb.vec3('normal'),
|
|
336
|
+
pb.vec3('viewVec'),
|
|
337
|
+
that.getCommonDatasStruct(scope)('data'),
|
|
338
|
+
pb.vec3('outColor').inout()
|
|
339
|
+
], function() {
|
|
340
|
+
if (!ctx.drawEnvLight || !ctx.env.light.envLight.hasRadiance() && !ctx.env.light.envLight.hasIrradiance()) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const envLightStrength = ShaderHelper.getEnvLightStrength(this);
|
|
344
|
+
if (that.occlusionTexture) {
|
|
345
|
+
const occlusionSample = that.sampleOcclusionTexture(this).r;
|
|
346
|
+
this.$l.occlusion = pb.mul(pb.add(pb.mul(this.zOcclusionStrength, pb.sub(occlusionSample, 1)), 1), envLightStrength);
|
|
347
|
+
} else {
|
|
348
|
+
this.$l.occlusion = envLightStrength;
|
|
349
|
+
}
|
|
350
|
+
this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0.0001, 1);
|
|
351
|
+
this.$l.ggxLutSample = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.roughness), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1));
|
|
352
|
+
this.$l.f_ab = this.ggxLutSample.rg;
|
|
353
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.roughness)), this.data.f0.rgb), this.data.f0.rgb);
|
|
354
|
+
this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
355
|
+
if (ctx.env.light.envLight.hasRadiance()) {
|
|
356
|
+
this.$l.radiance = ctx.env.light.envLight.getRadiance(this, pb.reflect(pb.neg(this.viewVec), this.normal), this.data.roughness);
|
|
357
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
|
|
358
|
+
this.$l.iblSpecular = pb.mul(this.radiance, this.FssEss, this.data.specularWeight, this.occlusion);
|
|
359
|
+
if (that.sheen) {
|
|
360
|
+
this.iblSpecular = pb.mul(this.iblSpecular, this.data.sheenAlbedoScaling);
|
|
361
|
+
}
|
|
362
|
+
this.outColor = pb.add(this.outColor, this.iblSpecular);
|
|
363
|
+
}
|
|
364
|
+
if (ctx.env.light.envLight.hasIrradiance()) {
|
|
365
|
+
this.$l.irradiance = ctx.env.light.envLight.getIrradiance(this, this.normal);
|
|
366
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x, this.data.specularWeight), pb.vec3(this.f_ab.y));
|
|
367
|
+
this.$l.Ems = pb.sub(1, pb.add(this.f_ab.x, this.f_ab.y));
|
|
368
|
+
this.$l.F_avg = pb.mul(pb.add(this.data.f0.rgb, pb.div(pb.sub(pb.vec3(1), this.data.f0.rgb), 21)), this.data.specularWeight);
|
|
369
|
+
this.$l.FmsEms = pb.div(pb.mul(this.FssEss, this.F_avg, this.Ems), pb.sub(pb.vec3(1), pb.mul(this.F_avg, this.Ems)));
|
|
370
|
+
this.$l.k_D = pb.mul(this.data.diffuse.rgb, pb.add(pb.sub(pb.vec3(1), this.FssEss), this.FmsEms));
|
|
371
|
+
this.$l.iblDiffuse = pb.mul(pb.add(this.FmsEms, this.k_D), this.irradiance, this.occlusion);
|
|
372
|
+
if (that.sheen) {
|
|
373
|
+
this.iblDiffuse = pb.mul(this.iblDiffuse, this.data.sheenAlbedoScaling);
|
|
374
|
+
}
|
|
375
|
+
this.outColor = pb.add(this.outColor, this.iblDiffuse);
|
|
376
|
+
}
|
|
377
|
+
if (that.sheen && ctx.env.light.envLight.hasIrradiance()) {
|
|
378
|
+
this.$l.refl = pb.reflect(pb.neg(this.viewVec), this.normal);
|
|
379
|
+
this.$l.sheenBRDF = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.sheenRoughness), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1)).b;
|
|
380
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.data.sheenColor, this.irradiance.rgb, this.sheenBRDF));
|
|
381
|
+
}
|
|
382
|
+
if (that.clearcoat && ctx.env.light.envLight.hasRadiance()) {
|
|
383
|
+
this.$l.NoV = pb.clamp(pb.dot(this.data.ccNormal, this.viewVec), 0.0001, 1);
|
|
384
|
+
this.$l.ggxLutSample = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.ccFactor.y), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1));
|
|
385
|
+
this.$l.f_ab = this.ggxLutSample.rg;
|
|
386
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.ccFactor.y)), this.data.f0.rgb), this.data.f0.rgb);
|
|
387
|
+
this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
388
|
+
this.$l.radiance = ctx.env.light.envLight.getRadiance(this, pb.reflect(pb.neg(this.viewVec), this.data.ccNormal), this.data.ccFactor.y);
|
|
389
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
|
|
390
|
+
this.$l.ccSpecular = pb.mul(this.radiance, this.FssEss, this.data.specularWeight, this.occlusion);
|
|
391
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.ccSpecular, this.data.ccFactor.x));
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
scope.$g[funcName](normal, viewVec, commonData, outColor);
|
|
395
|
+
}
|
|
396
|
+
fresnelSchlick(scope, cosTheta, F0, F90) {
|
|
397
|
+
const pb = scope.$builder;
|
|
398
|
+
const funcName = 'Z_fresnelSchlick';
|
|
399
|
+
pb.func(funcName, [
|
|
400
|
+
pb.float('cosTheta'),
|
|
401
|
+
pb.vec3('f0'),
|
|
402
|
+
pb.vec3('f90')
|
|
403
|
+
], function() {
|
|
404
|
+
this.$return(pb.add(this.f0, pb.mul(pb.sub(this.f90, this.f0), pb.pow(pb.clamp(pb.sub(1, this.cosTheta), 0, 1), 5))));
|
|
405
|
+
});
|
|
406
|
+
return scope.$g[funcName](cosTheta, F0, F90);
|
|
407
|
+
}
|
|
408
|
+
distributionGGX(scope, NdotH, alphaRoughness) {
|
|
409
|
+
const pb = scope.$builder;
|
|
410
|
+
const funcName = 'Z_distributionGGX';
|
|
411
|
+
pb.func(funcName, [
|
|
412
|
+
pb.float('NdotH'),
|
|
413
|
+
pb.float('roughness')
|
|
414
|
+
], function() {
|
|
415
|
+
this.$l.a2 = pb.mul(this.roughness, this.roughness);
|
|
416
|
+
this.$l.NdotH2 = pb.mul(this.NdotH, this.NdotH);
|
|
417
|
+
this.$l.num = this.a2;
|
|
418
|
+
this.$l.denom = pb.add(pb.mul(this.NdotH2, pb.sub(this.a2, 1)), 1);
|
|
419
|
+
this.denom = pb.mul(pb.mul(3.14159265, this.denom), this.denom);
|
|
420
|
+
this.$return(pb.div(this.num, this.denom));
|
|
421
|
+
});
|
|
422
|
+
return scope.$g[funcName](NdotH, alphaRoughness);
|
|
423
|
+
}
|
|
424
|
+
visGGX(scope, NdotV, NdotL, alphaRoughness) {
|
|
425
|
+
const pb = scope.$builder;
|
|
426
|
+
const funcName = 'Z_visGGX';
|
|
427
|
+
pb.func(funcName, [
|
|
428
|
+
pb.float('NdotV'),
|
|
429
|
+
pb.float('NdotL'),
|
|
430
|
+
pb.float('roughness')
|
|
431
|
+
], function() {
|
|
432
|
+
this.$l.a = this.roughness;
|
|
433
|
+
this.$l.ggxV = pb.mul(this.NdotL, pb.sqrt(pb.add(pb.mul(this.NdotV, this.NdotV, pb.sub(1, this.a)), this.a)));
|
|
434
|
+
this.$l.ggxL = pb.mul(this.NdotV, pb.sqrt(pb.add(pb.mul(this.NdotL, this.NdotL, pb.sub(1, this.a)), this.a)));
|
|
435
|
+
this.$l.ggx = pb.add(this.ggxV, this.ggxL, 1e-5);
|
|
436
|
+
this.$if(pb.greaterThan(this.ggx, 0), function() {
|
|
437
|
+
this.$return(pb.div(0.5, this.ggx));
|
|
438
|
+
}).$else(function() {
|
|
439
|
+
this.$return(pb.float(0));
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
return scope.$g[funcName](NdotV, NdotL, alphaRoughness);
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
FEATURE_SHEEN = cls.defineFeature();
|
|
446
|
+
FEATURE_CLEARCOAT = cls.defineFeature();
|
|
447
|
+
return cls;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export { mixinPBRCommon };
|
|
451
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
|
+
import { mixinTextureProps } from '../texture.js';
|
|
3
|
+
import { mixinPBRCommon } from './common.js';
|
|
4
|
+
import { Vector4 } from '@zephyr3d/base';
|
|
5
|
+
import { mixinLight } from '../lit.js';
|
|
6
|
+
|
|
7
|
+
function mixinPBRMetallicRoughness(BaseCls) {
|
|
8
|
+
if (BaseCls.pbrMetallicRoughnessMixed) {
|
|
9
|
+
return BaseCls;
|
|
10
|
+
}
|
|
11
|
+
const S = applyMaterialMixins(BaseCls, mixinPBRCommon, mixinLight, mixinTextureProps('metallicRoughness'), mixinTextureProps('occlusion'), mixinTextureProps('specular'), mixinTextureProps('specularColor'));
|
|
12
|
+
return class extends S {
|
|
13
|
+
static pbrMetallicRoughnessMixed = true;
|
|
14
|
+
_metallic;
|
|
15
|
+
_roughness;
|
|
16
|
+
_specularFactor;
|
|
17
|
+
constructor(){
|
|
18
|
+
super();
|
|
19
|
+
this._metallic = 1;
|
|
20
|
+
this._roughness = 1;
|
|
21
|
+
this._specularFactor = Vector4.one();
|
|
22
|
+
}
|
|
23
|
+
get metallic() {
|
|
24
|
+
return this._metallic;
|
|
25
|
+
}
|
|
26
|
+
set metallic(val) {
|
|
27
|
+
if (val !== this._metallic) {
|
|
28
|
+
this._metallic = val;
|
|
29
|
+
this.optionChanged(false);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
get roughness() {
|
|
33
|
+
return this._roughness;
|
|
34
|
+
}
|
|
35
|
+
set roughness(val) {
|
|
36
|
+
if (val !== this._roughness) {
|
|
37
|
+
this._roughness = val;
|
|
38
|
+
this.optionChanged(false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
get specularFactor() {
|
|
42
|
+
return this._specularFactor;
|
|
43
|
+
}
|
|
44
|
+
set specularFactor(val) {
|
|
45
|
+
if (!val.equalsTo(this._specularFactor)) {
|
|
46
|
+
this._specularFactor.set(val);
|
|
47
|
+
this.optionChanged(true);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
PBRLight(scope, normal, TBN, viewVec, albedo) {
|
|
51
|
+
const pb = scope.$builder;
|
|
52
|
+
const funcName = 'z_PBRLight';
|
|
53
|
+
const that = this;
|
|
54
|
+
pb.func(funcName, [
|
|
55
|
+
pb.vec3('normal'),
|
|
56
|
+
pb.mat3('TBN'),
|
|
57
|
+
pb.vec3('viewVec'),
|
|
58
|
+
pb.vec4('albedo')
|
|
59
|
+
], function() {
|
|
60
|
+
this.$l.pbrData = that.getCommonData(this, this.albedo, this.viewVec, this.TBN);
|
|
61
|
+
this.$l.lightingColor = pb.vec3(0);
|
|
62
|
+
this.$l.emissiveColor = that.calculateEmissiveColor(this);
|
|
63
|
+
that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);
|
|
64
|
+
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, shadow) {
|
|
65
|
+
this.$l.diffuse = pb.vec3();
|
|
66
|
+
this.$l.specular = pb.vec3();
|
|
67
|
+
this.$l.lightAtten = that.calculateLightAttenuation(this, type, posRange, dirCutoff);
|
|
68
|
+
this.$l.lightDir = that.calculateLightDirection(this, type, posRange, dirCutoff);
|
|
69
|
+
this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);
|
|
70
|
+
this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);
|
|
71
|
+
if (shadow) {
|
|
72
|
+
this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.NoL));
|
|
73
|
+
}
|
|
74
|
+
that.directLighting(this, this.lightDir, this.lightColor, this.normal, this.viewVec, this.pbrData, this.lightingColor);
|
|
75
|
+
});
|
|
76
|
+
this.$return(pb.add(this.lightingColor, this.emissiveColor));
|
|
77
|
+
});
|
|
78
|
+
return pb.getGlobalScope()[funcName](normal, TBN, viewVec, albedo);
|
|
79
|
+
}
|
|
80
|
+
fragmentShader(scope) {
|
|
81
|
+
super.fragmentShader(scope);
|
|
82
|
+
if (this.needFragmentColor()) {
|
|
83
|
+
const pb = scope.$builder;
|
|
84
|
+
scope.zMetallic = pb.float().uniform(2);
|
|
85
|
+
scope.zRoughness = pb.float().uniform(2);
|
|
86
|
+
scope.zSpecularFactor = pb.vec4().uniform(2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
applyUniformValues(bindGroup, ctx, pass) {
|
|
90
|
+
super.applyUniformValues(bindGroup, ctx, pass);
|
|
91
|
+
if (this.needFragmentColor(ctx)) {
|
|
92
|
+
bindGroup.setValue('zMetallic', this._metallic);
|
|
93
|
+
bindGroup.setValue('zRoughness', this._roughness);
|
|
94
|
+
bindGroup.setValue('zSpecularFactor', this._specularFactor);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
calculateCommonData(scope, albedo, viewVec, TBN, data) {
|
|
98
|
+
super.calculateCommonData(scope, albedo, viewVec, TBN, data);
|
|
99
|
+
const pb = scope.$builder;
|
|
100
|
+
if (this.metallicRoughnessTexture) {
|
|
101
|
+
scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);
|
|
102
|
+
data.metallic = pb.mul(scope.zMetallic, scope.metallicRoughnessSample.z);
|
|
103
|
+
data.roughness = pb.mul(scope.zRoughness, scope.metallicRoughnessSample.y);
|
|
104
|
+
} else {
|
|
105
|
+
data.metallic = scope.zMetallic;
|
|
106
|
+
data.roughness = scope.zRoughness;
|
|
107
|
+
}
|
|
108
|
+
if (this.specularColorTexture) {
|
|
109
|
+
scope.$l.specularColor = pb.mul(scope.zSpecularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);
|
|
110
|
+
} else {
|
|
111
|
+
scope.$l.specularColor = scope.zSpecularFactor.rgb;
|
|
112
|
+
}
|
|
113
|
+
if (this.specularTexture) {
|
|
114
|
+
data.specularWeight = pb.mul(scope.zSpecularFactor.a, this.sampleSpecularTexture(scope).a);
|
|
115
|
+
} else {
|
|
116
|
+
data.specularWeight = scope.zSpecularFactor.a;
|
|
117
|
+
}
|
|
118
|
+
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);
|
|
119
|
+
data.f90 = pb.vec3(1);
|
|
120
|
+
data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { mixinPBRMetallicRoughness };
|
|
126
|
+
//# sourceMappingURL=metallicroughness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metallicroughness.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|