@zephyr3d/scene 0.4.0 → 0.6.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/animation.js +25 -117
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +191 -51
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +6 -18
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +16 -6
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +104 -0
- package/dist/animation/morphtarget.js.map +1 -0
- package/dist/animation/morphtrack.js +70 -0
- package/dist/animation/morphtrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +15 -7
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +15 -7
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +107 -5
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +15 -7
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app.js +4 -26
- package/dist/app.js.map +1 -1
- package/dist/asset/assetmanager.js +60 -109
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +77 -3
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +287 -40
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +1 -1
- package/dist/asset/loaders/image/webimage_loader.js +16 -0
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/model.js +16 -9
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js +222 -0
- package/dist/{render/temporalcache.js.map → blitter/bilateralblur.js.map} +1 -1
- package/dist/blitter/blitter.js +9 -3
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/depthlimitedgaussion.js +96 -39
- package/dist/blitter/depthlimitedgaussion.js.map +1 -1
- package/dist/blitter/gaussianblur.js +21 -21
- package/dist/camera/camera.js +200 -4
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +6406 -5786
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +15 -4
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +26 -17
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +13 -2
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +103 -31
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +5 -4
- package/dist/material/mixins/albedocolor.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 +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -7
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -7
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +2 -2
- package/dist/material/mixins/pbr/common.js +454 -19
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +28 -6
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +27 -9
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +128 -23
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/unlit.js +8 -4
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/bloom.js +34 -53
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +48 -58
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +3 -11
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -11
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/posteffect.js +4 -0
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +55 -48
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +536 -0
- package/dist/{material/lit.js.map → posteffect/ssr.js.map} +1 -1
- package/dist/posteffect/tonemap.js +3 -11
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/posteffect/water.js +306 -340
- package/dist/posteffect/water.js.map +1 -1
- package/dist/render/abuffer_oit.js +2 -2
- package/dist/render/clipmap.js +16 -19
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cull_visitor.js +8 -6
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +30 -14
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +70 -22
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +169 -33
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +989 -0
- package/dist/{shaders/framework.js.map → render/fft_wavegenerator.js.map} +1 -1
- package/dist/render/gerstner_wavegenerator.js +265 -0
- package/dist/{material/standard.js.map → render/gerstner_wavegenerator.js.map} +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +273 -0
- package/dist/{material/terrainlightmodel.js.map → render/hzb.js.map} +1 -1
- package/dist/render/lightpass.js +68 -28
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +51 -0
- package/dist/render/objectcolorpass.js.map +1 -0
- package/dist/render/render_queue.js +211 -158
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +79 -0
- package/dist/render/renderbundle_wrapper.js.map +1 -1
- package/dist/render/renderer.js +151 -35
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +27 -20
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +20 -14
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +12 -13
- package/dist/render/sky.js.map +1 -1
- package/dist/render/watermesh.js +94 -828
- package/dist/render/watermesh.js.map +1 -1
- package/dist/render/wavegenerator.js +8 -0
- package/dist/render/wavegenerator.js.map +1 -0
- package/dist/render/weightedblended_oit.js +11 -28
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/batchgroup.js +60 -14
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +24 -3
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +0 -14
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +5 -5
- package/dist/scene/mesh.js +62 -15
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js +5 -2
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/raycast_visitor.js +4 -2
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +6 -9
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +11 -8
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +10 -2
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/heightfield.js +135 -53
- package/dist/scene/terrain/heightfield.js.map +1 -1
- package/dist/scene/terrain/patch.js +10 -2
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/quadtree.js +2 -2
- package/dist/scene/terrain/terrain.js +1 -1
- package/dist/scene/xform.js +7 -9
- package/dist/scene/xform.js.map +1 -1
- package/dist/shaders/misc.js +10 -1
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +81 -16
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/shadow.js +1 -9
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js +442 -0
- package/dist/{material/terrainmat.js.map → shaders/ssr.js.map} +1 -1
- package/dist/shaders/water.js +377 -250
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/esm.js +4 -22
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/shadowmapper.js +56 -31
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +4 -24
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/cylinder.js +6 -5
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/utility/bounding_volume.js +1 -53
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/draco/decoder.js +116 -0
- package/dist/utility/draco/decoder.js.map +1 -0
- package/dist/utility/misc.js +93 -0
- package/dist/utility/misc.js.map +1 -0
- package/dist/utility/shprojection.js +2 -7
- package/dist/utility/shprojection.js.map +1 -1
- package/dist/utility/textures/ggxlut.js +213 -0
- package/dist/utility/textures/ggxlut.js.map +1 -0
- package/dist/utility/textures/gradientnoise.js +61 -0
- package/dist/utility/textures/gradientnoise.js.map +1 -0
- package/dist/utility/textures/randomnoise.js +41 -0
- package/dist/utility/textures/randomnoise.js.map +1 -0
- package/dist/values.js +25 -1
- package/dist/values.js.map +1 -1
- package/package.json +5 -8
- package/dist/animation/usertrack.js +0 -47
- package/dist/animation/usertrack.js.map +0 -1
- package/dist/material/grassmat.js +0 -127
- package/dist/material/grassmat.js.map +0 -1
- package/dist/material/lightmodel.js +0 -2074
- package/dist/material/lightmodel.js.map +0 -1
- package/dist/material/lit.js +0 -578
- package/dist/material/mixins/pbr/metallicroughness.js +0 -126
- package/dist/material/mixins/pbr/metallicroughness.js.map +0 -1
- package/dist/material/mixins/pbr/specularglossness.js +0 -104
- package/dist/material/mixins/pbr/specularglossness.js.map +0 -1
- package/dist/material/pbr.js +0 -27
- package/dist/material/pbr.js.map +0 -1
- package/dist/material/standard.js +0 -282
- package/dist/material/terrainlightmodel.js +0 -259
- package/dist/material/terrainmat.js +0 -357
- package/dist/render/depth_pass.js +0 -47
- package/dist/render/depth_pass.js.map +0 -1
- package/dist/render/forward.js +0 -186
- package/dist/render/forward.js.map +0 -1
- package/dist/render/forward_pass.js +0 -137
- package/dist/render/forward_pass.js.map +0 -1
- package/dist/render/helper.js +0 -38
- package/dist/render/helper.js.map +0 -1
- package/dist/render/renderscheme.js +0 -61
- package/dist/render/renderscheme.js.map +0 -1
- package/dist/render/temporalcache.js +0 -222
- package/dist/scene/model.js +0 -111
- package/dist/scene/model.js.map +0 -1
- package/dist/scene/octree_update_visitor.js +0 -20
- package/dist/scene/octree_update_visitor.js.map +0 -1
- package/dist/shaders/builtins.js +0 -110
- package/dist/shaders/builtins.js.map +0 -1
- package/dist/shaders/framework.js +0 -723
- package/dist/shaders/lighting.js +0 -335
- package/dist/shaders/lighting.js.map +0 -1
- package/dist/utility/sheenlut.js +0 -196
- package/dist/utility/sheenlut.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
2
|
import { mixinLight } from '../lit.js';
|
|
3
|
+
import { ShaderHelper } from '../../shader/helper.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Blinn-phong lighting model mixin
|
|
@@ -40,7 +41,7 @@ import { mixinLight } from '../lit.js';
|
|
|
40
41
|
bindGroup.setValue('zShininess', this._shininess);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
blinnPhongLight(scope, worldPos, normal, viewVec, albedo) {
|
|
44
|
+
blinnPhongLight(scope, worldPos, normal, viewVec, albedo, outRoughness) {
|
|
44
45
|
const pb = scope.$builder;
|
|
45
46
|
const funcName = 'Z_blinnPhongLight';
|
|
46
47
|
const that = this;
|
|
@@ -48,12 +49,15 @@ import { mixinLight } from '../lit.js';
|
|
|
48
49
|
pb.vec3('worldPos'),
|
|
49
50
|
pb.vec3('normal'),
|
|
50
51
|
pb.vec3('viewVec'),
|
|
51
|
-
pb.vec4('albedo')
|
|
52
|
+
pb.vec4('albedo'),
|
|
53
|
+
...outRoughness ? [
|
|
54
|
+
pb.vec4('outRoughness').out()
|
|
55
|
+
] : []
|
|
52
56
|
], function() {
|
|
53
57
|
if (!that.needFragmentColor()) {
|
|
54
58
|
this.$return(this.albedo.rgb);
|
|
55
59
|
} else {
|
|
56
|
-
if (that.needCalculateEnvLight()) {
|
|
60
|
+
if (that.needCalculateEnvLight() && !outRoughness) {
|
|
57
61
|
this.$l.diffuseColor = that.getEnvLightIrradiance(this, this.normal);
|
|
58
62
|
} else {
|
|
59
63
|
this.$l.diffuseColor = pb.vec3(0);
|
|
@@ -69,18 +73,24 @@ import { mixinLight } from '../lit.js';
|
|
|
69
73
|
this.$l.diffuse = pb.mul(this.lightColor, this.NoL);
|
|
70
74
|
this.$l.specular = pb.mul(this.lightColor, pb.pow(this.NoH, this.zShininess));
|
|
71
75
|
if (shadow) {
|
|
72
|
-
this.$
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
this.$if(pb.greaterThan(this.NoL, 0), function() {
|
|
77
|
+
this.$l.shadow = pb.vec3(that.calculateShadow(this, this.worldPos, this.NoL));
|
|
78
|
+
this.diffuse = pb.mul(this.diffuse, this.shadow);
|
|
79
|
+
this.specular = pb.mul(this.specular, this.shadow);
|
|
80
|
+
});
|
|
75
81
|
}
|
|
76
82
|
this.diffuseColor = pb.add(this.diffuseColor, this.diffuse);
|
|
77
83
|
this.specularColor = pb.add(this.specularColor, this.specular);
|
|
78
84
|
});
|
|
79
85
|
this.$l.litColor = pb.add(pb.mul(this.albedo.rgb, this.diffuseColor), this.specularColor);
|
|
86
|
+
if (outRoughness) {
|
|
87
|
+
this.$l.roughness = pb.sqrt(pb.div(2, pb.add(this.zShininess, 2)));
|
|
88
|
+
this.outRoughness = pb.vec4(pb.mul(this.albedo.rgb, pb.sub(1, this.roughness)), pb.mul(this.roughness, ShaderHelper.getCameraRoughnessFactor(this)));
|
|
89
|
+
}
|
|
80
90
|
this.$return(this.litColor);
|
|
81
91
|
}
|
|
82
92
|
});
|
|
83
|
-
return pb.getGlobalScope()[funcName](worldPos, normal, viewVec, albedo);
|
|
93
|
+
return outRoughness ? pb.getGlobalScope()[funcName](worldPos, normal, viewVec, albedo, outRoughness) : pb.getGlobalScope()[funcName](worldPos, normal, viewVec, albedo);
|
|
84
94
|
}
|
|
85
95
|
};
|
|
86
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blinnphong.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blinnphong.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
2
|
import { mixinLight } from '../lit.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Lambert lighting model mixin
|
|
6
|
-
* @param BaseCls - Class to mix in
|
|
7
|
-
* @returns Mixed class
|
|
8
|
-
* @public
|
|
4
|
+
/**
|
|
5
|
+
* Lambert lighting model mixin
|
|
6
|
+
* @param BaseCls - Class to mix in
|
|
7
|
+
* @returns Mixed class
|
|
8
|
+
* @public
|
|
9
9
|
*/ function mixinLambert(BaseCls) {
|
|
10
10
|
if (BaseCls.lambertMixed) {
|
|
11
11
|
return BaseCls;
|
|
@@ -3,6 +3,7 @@ import { mixinTextureProps } from '../texture.js';
|
|
|
3
3
|
import { mixinPBRCommon } from '../pbr/common.js';
|
|
4
4
|
import { Vector4 } from '@zephyr3d/base';
|
|
5
5
|
import { mixinLight } from '../lit.js';
|
|
6
|
+
import { ShaderHelper } from '../../shader/helper.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* PBRMetallicRoughness lighting model mixin
|
|
@@ -52,7 +53,7 @@ import { mixinLight } from '../lit.js';
|
|
|
52
53
|
this.uniformChanged();
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
PBRLight(scope, worldPos, normal, viewVec, albedo, TBN) {
|
|
56
|
+
PBRLight(scope, worldPos, normal, viewVec, albedo, TBN, outRoughness) {
|
|
56
57
|
const pb = scope.$builder;
|
|
57
58
|
const funcName = 'Z_PBRMetallicRoughnessLight';
|
|
58
59
|
const that = this;
|
|
@@ -61,12 +62,19 @@ import { mixinLight } from '../lit.js';
|
|
|
61
62
|
pb.vec3('normal'),
|
|
62
63
|
pb.mat3('TBN'),
|
|
63
64
|
pb.vec3('viewVec'),
|
|
64
|
-
pb.vec4('albedo')
|
|
65
|
+
pb.vec4('albedo'),
|
|
66
|
+
...outRoughness ? [
|
|
67
|
+
pb.vec4('outRoughness').out()
|
|
68
|
+
] : []
|
|
65
69
|
], function() {
|
|
66
|
-
this.$l.pbrData = that.getCommonData(this, this.albedo, this.viewVec, this.TBN);
|
|
70
|
+
this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);
|
|
67
71
|
this.$l.lightingColor = pb.vec3(0);
|
|
68
72
|
this.$l.emissiveColor = that.calculateEmissiveColor(this);
|
|
69
|
-
|
|
73
|
+
if (outRoughness) {
|
|
74
|
+
that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor, this.outRoughness);
|
|
75
|
+
} else {
|
|
76
|
+
that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);
|
|
77
|
+
}
|
|
70
78
|
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, shadow) {
|
|
71
79
|
this.$l.diffuse = pb.vec3();
|
|
72
80
|
this.$l.specular = pb.vec3();
|
|
@@ -81,7 +89,7 @@ import { mixinLight } from '../lit.js';
|
|
|
81
89
|
});
|
|
82
90
|
this.$return(pb.add(this.lightingColor, this.emissiveColor));
|
|
83
91
|
});
|
|
84
|
-
return pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo);
|
|
92
|
+
return outRoughness ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness) : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo);
|
|
85
93
|
}
|
|
86
94
|
fragmentShader(scope) {
|
|
87
95
|
super.fragmentShader(scope);
|
|
@@ -100,8 +108,7 @@ import { mixinLight } from '../lit.js';
|
|
|
100
108
|
bindGroup.setValue('zSpecularFactor', this._specularFactor);
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
|
-
calculateCommonData(scope, albedo, viewVec, TBN, data) {
|
|
104
|
-
super.calculateCommonData(scope, albedo, viewVec, TBN, data);
|
|
111
|
+
calculateCommonData(scope, albedo, normal, viewVec, TBN, data) {
|
|
105
112
|
const pb = scope.$builder;
|
|
106
113
|
if (this.metallicRoughnessTexture) {
|
|
107
114
|
scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);
|
|
@@ -111,6 +118,7 @@ import { mixinLight } from '../lit.js';
|
|
|
111
118
|
data.metallic = scope.zMetallic;
|
|
112
119
|
data.roughness = scope.zRoughness;
|
|
113
120
|
}
|
|
121
|
+
data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));
|
|
114
122
|
if (this.specularColorTexture) {
|
|
115
123
|
scope.$l.specularColor = pb.mul(scope.zSpecularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);
|
|
116
124
|
} else {
|
|
@@ -124,6 +132,7 @@ import { mixinLight } from '../lit.js';
|
|
|
124
132
|
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);
|
|
125
133
|
data.f90 = pb.vec3(1);
|
|
126
134
|
data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);
|
|
135
|
+
super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);
|
|
127
136
|
}
|
|
128
137
|
};
|
|
129
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrmetallicroughness.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pbrmetallicroughness.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { mixinTextureProps } from '../texture.js';
|
|
|
3
3
|
import { mixinPBRCommon } from '../pbr/common.js';
|
|
4
4
|
import { Vector4 } from '@zephyr3d/base';
|
|
5
5
|
import { mixinLight } from '../lit.js';
|
|
6
|
+
import { ShaderHelper } from '../../shader/helper.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* PBRSpecularGlossiness mixin
|
|
@@ -58,7 +59,7 @@ import { mixinLight } from '../lit.js';
|
|
|
58
59
|
bindGroup.setValue('zGlossinessFactor', this._glossinessFactor);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
PBRLight(scope, worldPos, normal, viewVec, albedo, TBN) {
|
|
62
|
+
PBRLight(scope, worldPos, normal, viewVec, albedo, TBN, outRoughness) {
|
|
62
63
|
const pb = scope.$builder;
|
|
63
64
|
const funcName = 'Z_PBRSpecularGlossinessLight';
|
|
64
65
|
const that = this;
|
|
@@ -67,12 +68,19 @@ import { mixinLight } from '../lit.js';
|
|
|
67
68
|
pb.vec3('normal'),
|
|
68
69
|
pb.mat3('TBN'),
|
|
69
70
|
pb.vec3('viewVec'),
|
|
70
|
-
pb.vec4('albedo')
|
|
71
|
+
pb.vec4('albedo'),
|
|
72
|
+
...outRoughness ? [
|
|
73
|
+
pb.vec4('outRoughness').out()
|
|
74
|
+
] : []
|
|
71
75
|
], function() {
|
|
72
|
-
this.$l.pbrData = that.getCommonData(this, this.albedo, this.viewVec, this.TBN);
|
|
76
|
+
this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);
|
|
73
77
|
this.$l.lightingColor = pb.vec3(0);
|
|
74
78
|
this.$l.emissiveColor = that.calculateEmissiveColor(this);
|
|
75
|
-
|
|
79
|
+
if (outRoughness) {
|
|
80
|
+
that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor, this.outRoughness);
|
|
81
|
+
} else {
|
|
82
|
+
that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);
|
|
83
|
+
}
|
|
76
84
|
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, shadow) {
|
|
77
85
|
this.$l.diffuse = pb.vec3();
|
|
78
86
|
this.$l.specular = pb.vec3();
|
|
@@ -87,10 +95,10 @@ import { mixinLight } from '../lit.js';
|
|
|
87
95
|
});
|
|
88
96
|
this.$return(pb.add(this.lightingColor, this.emissiveColor));
|
|
89
97
|
});
|
|
90
|
-
return pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo);
|
|
98
|
+
return outRoughness ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness) : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo);
|
|
91
99
|
}
|
|
92
|
-
calculateCommonData(scope, albedo, viewVec, TBN, data) {
|
|
93
|
-
super.calculateCommonData(scope, albedo, viewVec, TBN, data);
|
|
100
|
+
calculateCommonData(scope, albedo, normal, viewVec, TBN, data) {
|
|
101
|
+
super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);
|
|
94
102
|
const pb = scope.$builder;
|
|
95
103
|
if (this.specularTexture) {
|
|
96
104
|
scope.$l.specularTextureSample = this.sampleSpecularTexture(scope);
|
|
@@ -100,6 +108,7 @@ import { mixinLight } from '../lit.js';
|
|
|
100
108
|
data.roughness = pb.sub(1, scope.zGlossinessFactor);
|
|
101
109
|
data.f0 = pb.vec4(scope.zSpecularFactor.rgb, this.getF0(scope).a);
|
|
102
110
|
}
|
|
111
|
+
data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));
|
|
103
112
|
data.metallic = pb.max(pb.max(data.f0.r, data.f0.g), data.f0.b);
|
|
104
113
|
data.diffuse = pb.vec4(pb.mul(albedo.rgb, pb.sub(1, data.metallic)), albedo.a);
|
|
105
114
|
data.specularWeight = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrspecularglossness.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pbrspecularglossness.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -292,7 +292,7 @@ import { ShaderHelper } from '../shader/helper.js';
|
|
|
292
292
|
* Checks if shadow should be computed
|
|
293
293
|
*
|
|
294
294
|
* @returns true if shadow should be computed, other wise false
|
|
295
|
-
*/
|
|
295
|
+
*/ needCalculateShadow() {
|
|
296
296
|
return this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT && !!this.drawContext.currentShadowLight;
|
|
297
297
|
}
|
|
298
298
|
/**
|
|
@@ -303,7 +303,7 @@ import { ShaderHelper } from '../shader/helper.js';
|
|
|
303
303
|
* @returns Shadow of current fragment, 1 means no shadow and 0 means full shadowed.
|
|
304
304
|
*/ calculateShadow(scope, worldPos, NoL) {
|
|
305
305
|
const pb = scope.$builder;
|
|
306
|
-
if (!this.
|
|
306
|
+
if (!this.needCalculateShadow()) {
|
|
307
307
|
console.warn('calculateShadow(): No need to calculate shadow');
|
|
308
308
|
return pb.float(1);
|
|
309
309
|
}
|