@zephyr3d/scene 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationmask.js +224 -0
- package/dist/animation/animationmask.js.map +1 -0
- package/dist/animation/animationset.js +268 -67
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +3 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +7 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +6 -4
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +390 -43
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +4 -3
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +2 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/morphtarget.js +3 -72
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -0
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +3 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/proptrack.js +3 -0
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +3 -0
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +3 -0
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +254 -79
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +4 -4
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/animation/translationtrack.js +3 -0
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/engine.js +129 -17
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +251 -80
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +133 -102
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +18 -14
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js +1 -6
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
- package/dist/asset/model.js +1052 -183
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +474 -0
- package/dist/avatar/wardrobe.js.map +1 -0
- package/dist/index.d.ts +1810 -233
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +1 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +21 -6
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +277 -277
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.js.map +1 -0
- package/dist/posteffect/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +54 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/sky.js +9 -0
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +18 -8
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +16 -2
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +164 -102
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +2 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +437 -230
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +146 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +50 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +188 -1
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +16 -1
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/pmrem.js +34 -8
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/serialization/manager.js +340 -283
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +702 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +66 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +189 -8
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/textures/sheenlut.js +138 -0
- package/dist/utility/textures/sheenlut.js.map +1 -0
- package/dist/values.js +48 -48
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
2
|
import { Vector4, Vector3 } from '@zephyr3d/base';
|
|
3
3
|
import { getGGXLUT } from '../../../utility/textures/ggxlut.js';
|
|
4
|
+
import { getSheenLUT } from '../../../utility/textures/sheenlut.js';
|
|
4
5
|
import { mixinTextureProps } from '../texture.js';
|
|
5
6
|
import { ShaderHelper } from '../../shader/helper.js';
|
|
6
7
|
import { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../../../values.js';
|
|
@@ -266,6 +267,7 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
266
267
|
}
|
|
267
268
|
if (this.sheen) {
|
|
268
269
|
scope.zSheenFactor = pb.vec4().uniform(2);
|
|
270
|
+
scope.zSheenLut = pb.tex2D().uniform(2);
|
|
269
271
|
}
|
|
270
272
|
if (this.clearcoat) {
|
|
271
273
|
scope.zClearcoatFactor = pb.vec4().uniform(2);
|
|
@@ -300,6 +302,7 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
300
302
|
}
|
|
301
303
|
if (this.sheen) {
|
|
302
304
|
bindGroup.setValue('zSheenFactor', this._sheenFactor);
|
|
305
|
+
bindGroup.setTexture('zSheenLut', getSheenLUT(64));
|
|
303
306
|
}
|
|
304
307
|
if (this.clearcoat) {
|
|
305
308
|
bindGroup.setValue('zClearcoatFactor', this._clearcoatFactor);
|
|
@@ -331,7 +334,6 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
331
334
|
pb.float('roughness'),
|
|
332
335
|
pb.float('specularWeight'),
|
|
333
336
|
...this.sheen ? [
|
|
334
|
-
pb.float('sheenAlbedoScaling'),
|
|
335
337
|
pb.vec3('sheenColor'),
|
|
336
338
|
pb.float('sheenRoughness')
|
|
337
339
|
] : [],
|
|
@@ -383,8 +385,6 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
383
385
|
} else {
|
|
384
386
|
data.sheenRoughness = scope.zSheenFactor.a;
|
|
385
387
|
}
|
|
386
|
-
scope.$l.sheenDFG = 0.157;
|
|
387
|
-
data.sheenAlbedoScaling = pb.sub(1, pb.mul(pb.max(pb.max(data.sheenColor.r, data.sheenColor.g), data.sheenColor.b), scope.sheenDFG));
|
|
388
388
|
}
|
|
389
389
|
if (this.clearcoat) {
|
|
390
390
|
if (this.clearcoatNormalTexture) {
|
|
@@ -444,6 +444,18 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
444
444
|
return pb.mul(this.getEmissiveColor(scope), this.getEmissiveStrength(scope));
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
+
getSheenAlbedoScaling(scope, Ndot, sheenColor, sheenRoughness) {
|
|
448
|
+
const pb = scope.$builder;
|
|
449
|
+
const sheenE = pb.textureSampleLevel(scope.zSheenLut, pb.clamp(pb.vec2(Ndot, sheenRoughness), pb.vec2(0), pb.vec2(1)), 0).r;
|
|
450
|
+
const maxSheenColor = pb.max(pb.max(sheenColor.r, sheenColor.g), sheenColor.b);
|
|
451
|
+
return pb.sub(1, pb.mul(maxSheenColor, sheenE));
|
|
452
|
+
}
|
|
453
|
+
getSheenAlbedoScalingForDirect(scope, NoV, NoL, sheenColor, sheenRoughness) {
|
|
454
|
+
const pb = scope.$builder;
|
|
455
|
+
const eV = this.getSheenAlbedoScaling(scope, NoV, sheenColor, sheenRoughness);
|
|
456
|
+
const eL = this.getSheenAlbedoScaling(scope, NoL, sheenColor, sheenRoughness);
|
|
457
|
+
return pb.min(eV, eL);
|
|
458
|
+
}
|
|
447
459
|
D_Charlie(scope, NdotH, sheenRoughness) {
|
|
448
460
|
const funcNameDCharlie = 'Z_DCharlie';
|
|
449
461
|
const pb = scope.$builder;
|
|
@@ -451,7 +463,7 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
451
463
|
pb.float('NdotH'),
|
|
452
464
|
pb.float('sheenRoughness')
|
|
453
465
|
], function() {
|
|
454
|
-
this.$l.alphaG = pb.mul(this.sheenRoughness, this.sheenRoughness);
|
|
466
|
+
this.$l.alphaG = pb.mul(pb.max(this.sheenRoughness, 0.000001), pb.max(this.sheenRoughness, 0.000001));
|
|
455
467
|
this.$l.invR = pb.div(1, this.alphaG);
|
|
456
468
|
this.$l.cos2h = pb.mul(this.NdotH, this.NdotH);
|
|
457
469
|
this.$l.sin2h = pb.max(pb.sub(1, this.cos2h), 0.0078125);
|
|
@@ -459,6 +471,40 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
459
471
|
});
|
|
460
472
|
return scope.$g[funcNameDCharlie](NdotH, sheenRoughness);
|
|
461
473
|
}
|
|
474
|
+
V_Sheen(scope, NdotL, NdotV, sheenRoughness) {
|
|
475
|
+
const funcNameVSheen = 'Z_VSheen';
|
|
476
|
+
const pb = scope.$builder;
|
|
477
|
+
pb.func('Z_lambdaSheenNumericHelper', [
|
|
478
|
+
pb.float('x'),
|
|
479
|
+
pb.float('alphaG')
|
|
480
|
+
], function() {
|
|
481
|
+
this.$l.oneMinusAlphaSq = pb.mul(pb.sub(1, this.alphaG), pb.sub(1, this.alphaG));
|
|
482
|
+
this.$l.a = pb.mix(21.5473, 25.3245, this.oneMinusAlphaSq);
|
|
483
|
+
this.$l.b = pb.mix(3.82987, 3.32435, this.oneMinusAlphaSq);
|
|
484
|
+
this.$l.c = pb.mix(0.19823, 0.16801, this.oneMinusAlphaSq);
|
|
485
|
+
this.$l.d = pb.mix(-1.9776, -1.27393, this.oneMinusAlphaSq);
|
|
486
|
+
this.$l.e = pb.mix(-4.32054, -4.85967, this.oneMinusAlphaSq);
|
|
487
|
+
this.$return(pb.add(pb.div(this.a, pb.add(1, pb.mul(this.b, pb.pow(this.x, this.c)))), pb.mul(this.d, this.x), this.e));
|
|
488
|
+
});
|
|
489
|
+
pb.func('Z_lambdaSheen', [
|
|
490
|
+
pb.float('cosTheta'),
|
|
491
|
+
pb.float('alphaG')
|
|
492
|
+
], function() {
|
|
493
|
+
this.$if(pb.lessThan(pb.abs(this.cosTheta), 0.5), function() {
|
|
494
|
+
this.$return(pb.exp(this.Z_lambdaSheenNumericHelper(pb.abs(this.cosTheta), this.alphaG)));
|
|
495
|
+
});
|
|
496
|
+
this.$return(pb.exp(pb.sub(pb.mul(2, this.Z_lambdaSheenNumericHelper(0.5, this.alphaG)), this.Z_lambdaSheenNumericHelper(pb.sub(1, pb.abs(this.cosTheta)), this.alphaG))));
|
|
497
|
+
});
|
|
498
|
+
pb.func(funcNameVSheen, [
|
|
499
|
+
pb.float('NdotL'),
|
|
500
|
+
pb.float('NdotV'),
|
|
501
|
+
pb.float('sheenRoughness')
|
|
502
|
+
], function() {
|
|
503
|
+
this.$l.alphaG = pb.mul(pb.max(this.sheenRoughness, 0.000001), pb.max(this.sheenRoughness, 0.000001));
|
|
504
|
+
this.$return(pb.clamp(pb.div(1, pb.mul(pb.add(1, this.Z_lambdaSheen(this.NdotV, this.alphaG), this.Z_lambdaSheen(this.NdotL, this.alphaG)), 4, this.NdotV, this.NdotL)), 0, 1));
|
|
505
|
+
});
|
|
506
|
+
return scope.$g[funcNameVSheen](NdotL, NdotV, sheenRoughness);
|
|
507
|
+
}
|
|
462
508
|
V_Ashikhmin(scope, NdotL, NdotV) {
|
|
463
509
|
const funcNameVAshikhmin = 'Z_VAshikhmin';
|
|
464
510
|
const pb = scope.$builder;
|
|
@@ -598,13 +644,16 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
598
644
|
} else {
|
|
599
645
|
this.$l.F = this.schlickFresnel;
|
|
600
646
|
}
|
|
647
|
+
if (that.sheen) {
|
|
648
|
+
this.$l.sheenAlbedoScaling = that.getSheenAlbedoScalingForDirect(this, this.NoV, this.NoL, this.data.sheenColor, this.data.sheenRoughness);
|
|
649
|
+
}
|
|
601
650
|
this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);
|
|
602
651
|
this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);
|
|
603
652
|
this.$l.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
604
653
|
this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);
|
|
605
654
|
this.$l.specular = pb.mul(this.lightColor, this.D, this.V, this.F, this.specularScale);
|
|
606
655
|
if (that.sheen) {
|
|
607
|
-
this.specular = pb.mul(this.specular, this.
|
|
656
|
+
this.specular = pb.mul(this.specular, this.sheenAlbedoScaling);
|
|
608
657
|
}
|
|
609
658
|
this.outColor = pb.add(this.outColor, this.specular);
|
|
610
659
|
if (that.iridescence) {
|
|
@@ -621,12 +670,12 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
621
670
|
this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);
|
|
622
671
|
}
|
|
623
672
|
if (that.sheen) {
|
|
624
|
-
this.diffuse = pb.mul(this.diffuse, this.
|
|
673
|
+
this.diffuse = pb.mul(this.diffuse, this.sheenAlbedoScaling);
|
|
625
674
|
}
|
|
626
675
|
this.outColor = pb.add(this.outColor, this.diffuse);
|
|
627
676
|
if (that.sheen) {
|
|
628
677
|
this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);
|
|
629
|
-
this.$l.sheenV = that.
|
|
678
|
+
this.$l.sheenV = that.V_Sheen(this, this.NoL, this.NoV, this.data.sheenRoughness);
|
|
630
679
|
this.outColor = pb.add(this.outColor, pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV));
|
|
631
680
|
}
|
|
632
681
|
if (that.clearcoat) {
|
|
@@ -858,6 +907,10 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
858
907
|
this.$l.occlusion = envLightStrength;
|
|
859
908
|
}
|
|
860
909
|
this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0.0001, 1);
|
|
910
|
+
if (that.sheen) {
|
|
911
|
+
this.$l.sheenLutSample = pb.clamp(pb.textureSampleLevel(this.zSheenLut, pb.clamp(pb.vec2(this.NoV, this.data.sheenRoughness), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1));
|
|
912
|
+
this.$l.sheenAlbedoScaling = pb.sub(1, pb.mul(pb.max(pb.max(this.data.sheenColor.r, this.data.sheenColor.g), this.data.sheenColor.b), this.sheenLutSample.r));
|
|
913
|
+
}
|
|
861
914
|
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));
|
|
862
915
|
this.$l.f_ab = this.ggxLutSample.rg;
|
|
863
916
|
this.$l.F0 = pb.mul(this.data.f0.rgb, this.specWeight);
|
|
@@ -869,9 +922,9 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
869
922
|
}
|
|
870
923
|
if (outRoughness || ctx.env.light.envLight.hasRadiance()) {
|
|
871
924
|
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
|
|
872
|
-
this.$l.specularFactor = pb.mul(this.FssEss, this.occlusion);
|
|
925
|
+
this.$l.specularFactor = pb.mul(this.FssEss, this.data.specularWeight, this.occlusion);
|
|
873
926
|
if (that.sheen) {
|
|
874
|
-
this.specularFactor = pb.mul(this.specularFactor, this.
|
|
927
|
+
this.specularFactor = pb.mul(this.specularFactor, this.sheenAlbedoScaling);
|
|
875
928
|
}
|
|
876
929
|
if (outRoughness) {
|
|
877
930
|
this.outRoughness = pb.vec4(this.specularFactor /*this.data.f0.rgb*/ , this.data.roughness);
|
|
@@ -895,9 +948,9 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
895
948
|
this.$l.F_avg = pb.add(this.mixedF0, pb.div(pb.sub(pb.vec3(1), this.mixedF0), 21));
|
|
896
949
|
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)));
|
|
897
950
|
this.$l.k_D = pb.mul(this.data.diffuse.rgb, pb.add(pb.sub(pb.vec3(1), this.FssEss), this.FmsEms));
|
|
898
|
-
this.$l.iblDiffuse = pb.mul(pb.add(this.FmsEms, this.k_D),
|
|
951
|
+
this.$l.iblDiffuse = pb.mul(pb.add(this.FmsEms, this.k_D), this.irradiance, this.occlusion);
|
|
899
952
|
if (that.sheen) {
|
|
900
|
-
this.iblDiffuse = pb.mul(this.iblDiffuse, this.
|
|
953
|
+
this.iblDiffuse = pb.mul(this.iblDiffuse, this.sheenAlbedoScaling);
|
|
901
954
|
}
|
|
902
955
|
if (that.transmission && that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
903
956
|
this.$l.iblTransmission = that.getIBLVolumnRefraction(this, this.ggxLutSample.rg, this.normal, this.viewVec, this.data.roughness, this.data.diffuse.rgb, this.data.f0.rgb, this.data.f90, this.$inputs.worldPos, this.data.f0.a, this.data.thicknessFactor, this.data.attenuationColor, this.data.attenuationDistance);
|
|
@@ -905,10 +958,14 @@ import { mixinPBRBRDF } from './brdf.js';
|
|
|
905
958
|
}
|
|
906
959
|
this.outColor = pb.add(this.outColor, this.iblDiffuse);
|
|
907
960
|
}
|
|
908
|
-
if (that.sheen && ctx.env.light.envLight.hasIrradiance()) {
|
|
909
|
-
this.$l.
|
|
910
|
-
|
|
911
|
-
|
|
961
|
+
if (that.sheen && (ctx.env.light.envLight.hasSheenRadiance() || ctx.env.light.envLight.hasIrradiance())) {
|
|
962
|
+
this.$l.sheenBRDF = this.sheenLutSample.b;
|
|
963
|
+
if (ctx.env.light.envLight.hasSheenRadiance()) {
|
|
964
|
+
this.$l.sheenRadiance = ctx.env.light.envLight.getSheenRadiance(this, pb.reflect(pb.neg(this.viewVec), this.normal), this.data.sheenRoughness);
|
|
965
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.data.sheenColor, this.sheenRadiance, this.sheenBRDF, this.occlusion));
|
|
966
|
+
} else {
|
|
967
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.data.sheenColor, this.irradiance.rgb, this.sheenBRDF, this.occlusion));
|
|
968
|
+
}
|
|
912
969
|
}
|
|
913
970
|
if (that.clearcoat && ctx.env.light.envLight.hasRadiance()) {
|
|
914
971
|
this.$l.NoV = pb.clamp(pb.dot(this.data.ccNormal, this.viewVec), 0.0001, 1);
|