@zephyr3d/scene 0.1.1 → 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 +9 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Vector4 } from '@zephyr3d/base';
|
|
2
2
|
import { CullVisitor } from './cull_visitor.js';
|
|
3
|
-
import {
|
|
4
|
-
import '@zephyr3d/device';
|
|
5
|
-
import { ShaderFramework } from '../shaders/framework.js';
|
|
6
|
-
import { Application } from '../app.js';
|
|
7
|
-
import './scatteringlut.js';
|
|
3
|
+
import { ShaderHelper } from '../material/shader/helper.js';
|
|
8
4
|
import '../material/lambert.js';
|
|
9
5
|
import '../material/blinn.js';
|
|
10
6
|
import '../material/unlit.js';
|
|
11
|
-
import '../material/
|
|
7
|
+
import { Material } from '../material/material.js';
|
|
8
|
+
import '../material/meshmaterial.js';
|
|
9
|
+
import '../material/grassmaterial.js';
|
|
10
|
+
import '../material/terrainmaterial.js';
|
|
11
|
+
import '../material/pbrmr.js';
|
|
12
|
+
import '../material/pbrsg.js';
|
|
13
|
+
import { Application } from '../app.js';
|
|
12
14
|
import { RenderQueue } from './render_queue.js';
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -73,11 +75,11 @@ import { RenderQueue } from './render_queue.js';
|
|
|
73
75
|
//const programBuilder = new ProgramBuilder(Application.instance.device);
|
|
74
76
|
const ret = Application.instance.device.programBuilder.buildRender({
|
|
75
77
|
vertex (pb) {
|
|
76
|
-
|
|
78
|
+
ShaderHelper.prepareVertexShader(pb, ctx);
|
|
77
79
|
pb.main(function() {});
|
|
78
80
|
},
|
|
79
81
|
fragment (pb) {
|
|
80
|
-
|
|
82
|
+
ShaderHelper.prepareFragmentShader(pb, ctx);
|
|
81
83
|
pb.main(function() {});
|
|
82
84
|
}
|
|
83
85
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderpass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderpass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { RenderPass } from './renderpass.js';
|
|
2
2
|
import { RENDER_PASS_TYPE_SHADOWMAP } from '../values.js';
|
|
3
|
-
import { ShaderFramework } from '../shaders/framework.js';
|
|
4
|
-
import '@zephyr3d/device';
|
|
5
3
|
import { Application } from '../app.js';
|
|
4
|
+
import { ShaderHelper } from '../material/shader/helper.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Shadow map render pass
|
|
@@ -51,8 +50,8 @@ import { Application } from '../app.js';
|
|
|
51
50
|
const device = Application.instance.device;
|
|
52
51
|
const bindGroup = this.getGlobalBindGroupInfo(ctx).bindGroup;
|
|
53
52
|
device.setBindGroup(0, bindGroup);
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
ShaderHelper.setLightUniformsShadowMap(bindGroup, ctx, this._currentLight);
|
|
54
|
+
ShaderHelper.setCameraUniforms(bindGroup, ctx, true);
|
|
56
55
|
ctx.renderPassHash = this.getGlobalBindGroupHash(ctx);
|
|
57
56
|
const reverseWinding = ctx.camera.worldMatrixDet < 0;
|
|
58
57
|
for (const order of Object.keys(renderQueue.items).map((val)=>Number(val)).sort((a, b)=>a - b)){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadowmap_pass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shadowmap_pass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/render/sky.js
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { Application } from '../app.js';
|
|
2
2
|
import { decodeNormalizedFloatFromRGBA, linearToGamma } from '../shaders/misc.js';
|
|
3
|
-
import { ShaderFramework } from '../shaders/framework.js';
|
|
4
3
|
import { smoothNoise3D } from '../shaders/noise.js';
|
|
5
|
-
import { Matrix4x4,
|
|
4
|
+
import { Matrix4x4, Vector4, Vector2, Vector3, CubeFace } from '@zephyr3d/base';
|
|
6
5
|
import { BoxShape } from '../shapes/box.js';
|
|
7
6
|
import { ScatteringLut } from './scatteringlut.js';
|
|
8
7
|
import { Camera } from '../camera/camera.js';
|
|
9
8
|
import { prefilterCubemap } from '../utility/pmrem.js';
|
|
10
9
|
import '../utility/panorama.js';
|
|
11
10
|
import '../utility/shprojection.js';
|
|
11
|
+
import { ShaderHelper } from '../material/shader/helper.js';
|
|
12
12
|
|
|
13
13
|
const fogTypeMap = {
|
|
14
|
-
linear:
|
|
15
|
-
exp:
|
|
16
|
-
exp2:
|
|
17
|
-
scatter:
|
|
18
|
-
none:
|
|
14
|
+
linear: ShaderHelper.FOG_TYPE_LINEAR,
|
|
15
|
+
exp: ShaderHelper.FOG_TYPE_EXP,
|
|
16
|
+
exp2: ShaderHelper.FOG_TYPE_EXP2,
|
|
17
|
+
scatter: ShaderHelper.FOG_TYPE_SCATTER,
|
|
18
|
+
none: ShaderHelper.FOG_TYPE_NONE
|
|
19
19
|
};
|
|
20
20
|
const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
21
21
|
/**
|
|
22
22
|
* The sky renderer
|
|
23
23
|
* @public
|
|
24
24
|
*/ class SkyRenderer {
|
|
25
|
-
static _defaultSunDir = Vector3.one().inplaceNormalize();
|
|
26
25
|
_skyType;
|
|
27
26
|
_skyColor;
|
|
28
27
|
_skyboxTexture;
|
|
@@ -30,6 +29,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
30
29
|
_radianceMapDirty;
|
|
31
30
|
_scatterSkyboxFramebuffer;
|
|
32
31
|
_scatterSkyboxTextureWidth;
|
|
32
|
+
_aerialPerspectiveDensity;
|
|
33
33
|
_radianceMap;
|
|
34
34
|
_radianceMapWidth;
|
|
35
35
|
_irradianceMap;
|
|
@@ -54,6 +54,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
54
54
|
_renderStatesSkyNoDepthTest;
|
|
55
55
|
_renderStatesFog;
|
|
56
56
|
_renderStatesFogScatter;
|
|
57
|
+
_drawGround;
|
|
57
58
|
_lastSunDir;
|
|
58
59
|
/**
|
|
59
60
|
* Creates an instance of SkyRenderer
|
|
@@ -65,6 +66,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
65
66
|
this._skyboxTexture = null;
|
|
66
67
|
this._scatterSkyboxFramebuffer = null;
|
|
67
68
|
this._scatterSkyboxTextureWidth = 256;
|
|
69
|
+
this._aerialPerspectiveDensity = 1;
|
|
68
70
|
this._radianceMap = null;
|
|
69
71
|
this._radianceMapWidth = 128;
|
|
70
72
|
this._irradianceMap = null;
|
|
@@ -75,6 +77,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
75
77
|
this._cloudy = 0.6;
|
|
76
78
|
this._cloudIntensity = 40;
|
|
77
79
|
this._wind = Vector2.zero();
|
|
80
|
+
this._drawGround = false;
|
|
78
81
|
this._nearestSampler = null;
|
|
79
82
|
this._programSky = {};
|
|
80
83
|
this._bindgroupSky = {};
|
|
@@ -103,6 +106,12 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
103
106
|
this.invalidateIBLMaps();
|
|
104
107
|
}
|
|
105
108
|
}
|
|
109
|
+
/** Whether ground should be rendered */ get drawGround() {
|
|
110
|
+
return this._drawGround;
|
|
111
|
+
}
|
|
112
|
+
set drawGround(val) {
|
|
113
|
+
this._drawGround = !!val;
|
|
114
|
+
}
|
|
106
115
|
/**
|
|
107
116
|
* Wether the IBL maps should be updated automatically.
|
|
108
117
|
*
|
|
@@ -131,6 +140,12 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
131
140
|
this.invalidateIBLMaps();
|
|
132
141
|
}
|
|
133
142
|
}
|
|
143
|
+
/** Aerial perspective density */ get aerialPerspectiveDensity() {
|
|
144
|
+
return this._aerialPerspectiveDensity;
|
|
145
|
+
}
|
|
146
|
+
set aerialPerspectiveDensity(val) {
|
|
147
|
+
this._aerialPerspectiveDensity = val;
|
|
148
|
+
}
|
|
134
149
|
/**
|
|
135
150
|
* Light density of the sky.
|
|
136
151
|
*
|
|
@@ -270,7 +285,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
270
285
|
if (this.drawScatteredFog(ctx)) {
|
|
271
286
|
const sunDir = SkyRenderer._getSunDir(ctx.sunLight);
|
|
272
287
|
const alpha = Math.PI / 2 - Math.acos(Math.max(-1, Math.min(1, sunDir.y)));
|
|
273
|
-
const farPlane = ctx.camera.getFarPlane() *
|
|
288
|
+
const farPlane = ctx.camera.getFarPlane() * this._aerialPerspectiveDensity * this._aerialPerspectiveDensity;
|
|
274
289
|
return ScatteringLut.getAerialPerspectiveLut(alpha, farPlane);
|
|
275
290
|
} else {
|
|
276
291
|
return null;
|
|
@@ -342,13 +357,14 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
342
357
|
bindgroup.setValue('cameraPosition', camera.getWorldPosition());
|
|
343
358
|
bindgroup.setValue('srgbOut', device.getFramebuffer() ? 0 : 1);
|
|
344
359
|
if (this._fogType === 'scatter') {
|
|
345
|
-
const sunDir = sunLight ? sunLight.directionAndCutoff.xyz().scaleBy(-1) :
|
|
360
|
+
const sunDir = sunLight ? sunLight.directionAndCutoff.xyz().scaleBy(-1) : ShaderHelper.defaultSunDir;
|
|
346
361
|
const alpha = Math.PI / 2 - Math.acos(Math.max(-1, Math.min(1, sunDir.y)));
|
|
347
|
-
const
|
|
362
|
+
const scale = this._aerialPerspectiveDensity * this._aerialPerspectiveDensity;
|
|
363
|
+
const farPlane = ctx.camera.getFarPlane() * scale;
|
|
348
364
|
bindgroup.setTexture('apLut', ScatteringLut.getAerialPerspectiveLut(alpha, farPlane));
|
|
349
365
|
bindgroup.setValue('sliceDist', farPlane / ScatteringLut.aerialPerspectiveSliceZ);
|
|
350
366
|
bindgroup.setValue('sunDir', sunDir);
|
|
351
|
-
bindgroup.setValue('worldScale',
|
|
367
|
+
bindgroup.setValue('worldScale', scale);
|
|
352
368
|
} else {
|
|
353
369
|
bindgroup.setValue('fogType', this.mappedFogType);
|
|
354
370
|
bindgroup.setValue('fogColor', this._fogColor);
|
|
@@ -367,7 +383,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
367
383
|
if (!sunDir.equalsTo(this._lastSunDir)) {
|
|
368
384
|
this._radianceMapDirty = true;
|
|
369
385
|
}
|
|
370
|
-
this._renderSky(ctx.camera, true, sunDir,
|
|
386
|
+
this._renderSky(ctx.camera, true, sunDir, this._drawGround, this._skyType === 'scatter' && this._cloudy > 0);
|
|
371
387
|
if (this._radianceMapDirty && ctx.env.light.type === 'ibl') {
|
|
372
388
|
if (ctx.env.light.radianceMap && (ctx.env.light.radianceMap === this._radianceMap || ctx.env.light.irradianceMap === this._irradianceMap)) {
|
|
373
389
|
this._radianceMapDirty = false;
|
|
@@ -548,7 +564,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
548
564
|
this.$l.hPos = pb.mul(this.invProjViewMatrix, this.clipSpacePos);
|
|
549
565
|
this.$l.hPos = pb.div(this.$l.hPos, this.$l.hPos.w);
|
|
550
566
|
this.$l.viewDir = pb.sub(this.hPos.xyz, this.cameraPosition);
|
|
551
|
-
this.$l.fogFactor =
|
|
567
|
+
this.$l.fogFactor = ShaderHelper.computeFogFactor(this, this.viewDir, this.fogType, this.fogParams);
|
|
552
568
|
this.$l.color = pb.mul(this.fogColor.rgb, this.fogFactor);
|
|
553
569
|
this.$if(pb.equal(this.srgbOut, 0), function() {
|
|
554
570
|
this.$outputs.outColor = pb.vec4(this.color, this.fogFactor);
|
|
@@ -691,7 +707,7 @@ const defaultSkyWorldMatrix = Matrix4x4.identity();
|
|
|
691
707
|
}
|
|
692
708
|
/** @internal */ static _getSunDir(sunLight) {
|
|
693
709
|
// TODO: reduce GC
|
|
694
|
-
return sunLight?.directionAndCutoff.xyz().scaleBy(-1) ??
|
|
710
|
+
return sunLight?.directionAndCutoff.xyz().scaleBy(-1) ?? ShaderHelper.defaultSunDir;
|
|
695
711
|
}
|
|
696
712
|
static _createScatterProgram(device, cloud) {
|
|
697
713
|
return device.buildRenderProgram({
|
package/dist/render/sky.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sky.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sky.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Vector4 } from '@zephyr3d/base';
|
|
2
2
|
import '../app.js';
|
|
3
3
|
import './octree.js';
|
|
4
|
-
import '../material/
|
|
5
|
-
import '@zephyr3d/device';
|
|
6
|
-
import '../shaders/framework.js';
|
|
7
|
-
import '../render/scatteringlut.js';
|
|
4
|
+
import '../material/shader/helper.js';
|
|
8
5
|
import '../material/lambert.js';
|
|
9
6
|
import '../material/blinn.js';
|
|
10
7
|
import '../material/unlit.js';
|
|
11
|
-
import '../material/
|
|
12
|
-
import '../
|
|
8
|
+
import '../material/material.js';
|
|
9
|
+
import '../material/meshmaterial.js';
|
|
10
|
+
import '../material/grassmaterial.js';
|
|
11
|
+
import '../material/terrainmaterial.js';
|
|
12
|
+
import '../material/pbrmr.js';
|
|
13
|
+
import '../material/pbrsg.js';
|
|
14
|
+
import '../render/renderer.js';
|
|
13
15
|
import { SkyRenderer } from '../render/sky.js';
|
|
14
16
|
import '../render/clipmap.js';
|
|
15
17
|
import { EnvIBL, EnvHemisphericAmbient, EnvConstantAmbient } from '../render/envlight.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"environment.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/graph_node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/mesh.js
CHANGED
|
@@ -2,15 +2,17 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
2
2
|
import { GraphNode } from './graph_node.js';
|
|
3
3
|
import { Application } from '../app.js';
|
|
4
4
|
import { BoxFrameShape } from '../shapes/box.js';
|
|
5
|
-
import
|
|
6
|
-
import '../material/lambert.js';
|
|
5
|
+
import '../material/shader/helper.js';
|
|
6
|
+
import { LambertMaterial } from '../material/lambert.js';
|
|
7
7
|
import '../material/blinn.js';
|
|
8
8
|
import '../material/unlit.js';
|
|
9
|
-
import { LambertLightModel } from '../material/lightmodel.js';
|
|
10
9
|
import '../material/material.js';
|
|
11
|
-
import '
|
|
12
|
-
import '../
|
|
13
|
-
import '../
|
|
10
|
+
import '../material/meshmaterial.js';
|
|
11
|
+
import '../material/grassmaterial.js';
|
|
12
|
+
import '../material/terrainmaterial.js';
|
|
13
|
+
import '../material/pbrmr.js';
|
|
14
|
+
import '../material/pbrsg.js';
|
|
15
|
+
import { QUEUE_OPAQUE } from '../values.js';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Mesh node
|
|
@@ -145,7 +147,7 @@ import '../render/scatteringlut.js';
|
|
|
145
147
|
/**
|
|
146
148
|
* {@inheritDoc Drawable.isBatchable}
|
|
147
149
|
*/ isBatchable() {
|
|
148
|
-
return this._batchable && !this._boneMatrices;
|
|
150
|
+
return this._batchable && !this._boneMatrices && this._material?.isBatchable();
|
|
149
151
|
}
|
|
150
152
|
/** Disposes the mesh node */ dispose() {
|
|
151
153
|
this._primitive = null;
|
|
@@ -153,9 +155,9 @@ import '../render/scatteringlut.js';
|
|
|
153
155
|
super.dispose();
|
|
154
156
|
}
|
|
155
157
|
/**
|
|
156
|
-
* {@inheritDoc Drawable.
|
|
157
|
-
*/
|
|
158
|
-
return
|
|
158
|
+
* {@inheritDoc Drawable.getQueueType}
|
|
159
|
+
*/ getQueueType() {
|
|
160
|
+
return this.material?.getQueueType() ?? QUEUE_OPAQUE;
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
161
163
|
* {@inheritDoc Drawable.isUnlit}
|
|
@@ -204,8 +206,7 @@ import '../render/scatteringlut.js';
|
|
|
204
206
|
/** @internal */ static _defaultBoxFrame = null;
|
|
205
207
|
/** @internal */ static _getDefaultMaterial() {
|
|
206
208
|
if (!this._defaultMaterial) {
|
|
207
|
-
this._defaultMaterial = new
|
|
208
|
-
this._defaultMaterial.lightModel = new LambertLightModel();
|
|
209
|
+
this._defaultMaterial = new LambertMaterial();
|
|
209
210
|
}
|
|
210
211
|
return this._defaultMaterial;
|
|
211
212
|
}
|
package/dist/scene/mesh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mesh.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/scene.js
CHANGED
|
@@ -2,15 +2,17 @@ import { makeEventTarget, Vector4, Vector3, Ray, nextPowerOf2 } from '@zephyr3d/
|
|
|
2
2
|
import { SceneNode } from './scene_node.js';
|
|
3
3
|
import { Octree } from './octree.js';
|
|
4
4
|
import { OctreeUpdateVisitor } from './octree_update_visitor.js';
|
|
5
|
-
import
|
|
6
|
-
import '@zephyr3d/device';
|
|
7
|
-
import '../shaders/framework.js';
|
|
8
|
-
import { Application } from '../app.js';
|
|
9
|
-
import '../render/scatteringlut.js';
|
|
5
|
+
import '../material/shader/helper.js';
|
|
10
6
|
import '../material/lambert.js';
|
|
11
7
|
import '../material/blinn.js';
|
|
12
8
|
import '../material/unlit.js';
|
|
13
|
-
import '../material/
|
|
9
|
+
import { Material } from '../material/material.js';
|
|
10
|
+
import '../material/meshmaterial.js';
|
|
11
|
+
import '../material/grassmaterial.js';
|
|
12
|
+
import '../material/terrainmaterial.js';
|
|
13
|
+
import '../material/pbrmr.js';
|
|
14
|
+
import '../material/pbrsg.js';
|
|
15
|
+
import { Application } from '../app.js';
|
|
14
16
|
import { RaycastVisitor } from './raycast_visitor.js';
|
|
15
17
|
import { Environment } from './environment.js';
|
|
16
18
|
|
|
@@ -36,7 +38,6 @@ import { Environment } from './environment.js';
|
|
|
36
38
|
/** @internal */ _env;
|
|
37
39
|
/** @internal */ _updateEvent;
|
|
38
40
|
/** @internal */ _updateFrame;
|
|
39
|
-
/** @internal */ _worldUnit;
|
|
40
41
|
/** @internal */ _animationSet;
|
|
41
42
|
/** @internal */ _id;
|
|
42
43
|
/**
|
|
@@ -49,7 +50,6 @@ import { Environment } from './environment.js';
|
|
|
49
50
|
this._env = new Environment();
|
|
50
51
|
this._updateEvent = new SceneUpdateEvent(this);
|
|
51
52
|
this._updateFrame = -1;
|
|
52
|
-
this._worldUnit = 1;
|
|
53
53
|
this._animationSet = [];
|
|
54
54
|
this._rootNode = new SceneNode(this);
|
|
55
55
|
}
|
|
@@ -61,12 +61,6 @@ import { Environment } from './environment.js';
|
|
|
61
61
|
*/ get id() {
|
|
62
62
|
return this._id;
|
|
63
63
|
}
|
|
64
|
-
/** How many meters a unit corresponds to. */ get worldUnit() {
|
|
65
|
-
return this._worldUnit;
|
|
66
|
-
}
|
|
67
|
-
set worldUnit(val) {
|
|
68
|
-
this._worldUnit = val;
|
|
69
|
-
}
|
|
70
64
|
/**
|
|
71
65
|
* Gets the root scene node of the scene
|
|
72
66
|
*/ get rootNode() {
|
|
@@ -136,7 +130,9 @@ import { Environment } from './environment.js';
|
|
|
136
130
|
return new Ray(vEye, vDir);
|
|
137
131
|
}
|
|
138
132
|
/** @internal */ invalidateNodePlacement(node) {
|
|
139
|
-
|
|
133
|
+
if (node.isGraphNode() || node.children.length > 0) {
|
|
134
|
+
this._nodePlaceList.add(node);
|
|
135
|
+
}
|
|
140
136
|
}
|
|
141
137
|
/** @internal */ _xformChanged(node) {
|
|
142
138
|
this._nodePlaceList.add(node);
|
package/dist/scene/scene.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scene.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/scene/scene_node.js
CHANGED
|
@@ -47,7 +47,7 @@ import { XForm } from './xform.js';
|
|
|
47
47
|
this._bvDirty = true;
|
|
48
48
|
this._clipMode = SceneNode.CLIP_ENABLED;
|
|
49
49
|
this._boxDrawMode = SceneNode.BBOXDRAW_DISABLED;
|
|
50
|
-
this._visible = SceneNode.
|
|
50
|
+
this._visible = SceneNode.SHOW_INHERITED;
|
|
51
51
|
this._pickMode = SceneNode.PICK_DISABLED;
|
|
52
52
|
if (scene && this !== scene.rootNode) {
|
|
53
53
|
this.reparent(scene.rootNode);
|
|
@@ -210,14 +210,11 @@ import { XForm } from './xform.js';
|
|
|
210
210
|
this._clipMode = val;
|
|
211
211
|
}
|
|
212
212
|
/** Computed value of show state */ get hidden() {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
parent = parent.parent;
|
|
217
|
-
}
|
|
218
|
-
return parent?.hidden ?? false;
|
|
213
|
+
let node = this;
|
|
214
|
+
while(node && node._visible === SceneNode.SHOW_INHERITED){
|
|
215
|
+
node = node.parent;
|
|
219
216
|
}
|
|
220
|
-
return
|
|
217
|
+
return node ? node._visible === SceneNode.SHOW_HIDE : false;
|
|
221
218
|
}
|
|
222
219
|
/** Show state */ get showState() {
|
|
223
220
|
return this._visible;
|
|
@@ -232,14 +229,11 @@ import { XForm } from './xform.js';
|
|
|
232
229
|
}
|
|
233
230
|
}
|
|
234
231
|
/** Computed value of pick mode */ get pickable() {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
parent = parent.parent;
|
|
239
|
-
}
|
|
240
|
-
return parent?.pickable ?? false;
|
|
232
|
+
let node = this;
|
|
233
|
+
while(node && node._pickMode === SceneNode.PICK_INHERITED){
|
|
234
|
+
node = node.parent;
|
|
241
235
|
}
|
|
242
|
-
return
|
|
236
|
+
return node ? node._pickMode === SceneNode.PICK_ENABLED : false;
|
|
243
237
|
}
|
|
244
238
|
/** Pick mode */ get pickMode() {
|
|
245
239
|
return this._pickMode;
|
|
@@ -287,7 +281,7 @@ import { XForm } from './xform.js';
|
|
|
287
281
|
/** @internal */ notifyHiddenChanged() {
|
|
288
282
|
this._visibleChanged();
|
|
289
283
|
for (const child of this._children){
|
|
290
|
-
if (child.
|
|
284
|
+
if (child.showState === SceneNode.SHOW_INHERITED) {
|
|
291
285
|
child.notifyHiddenChanged();
|
|
292
286
|
}
|
|
293
287
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scene_node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { nextPowerOf2, Vector2 } from '@zephyr3d/base';
|
|
2
2
|
import { Primitive } from '../../render/primitive.js';
|
|
3
|
-
import '../../material/material.js';
|
|
4
|
-
import '@zephyr3d/device';
|
|
5
|
-
import '../../shaders/framework.js';
|
|
6
3
|
import { Application } from '../../app.js';
|
|
7
|
-
import '../../render/scatteringlut.js';
|
|
8
|
-
import '../../material/lambert.js';
|
|
9
|
-
import '../../material/blinn.js';
|
|
10
|
-
import '../../material/unlit.js';
|
|
11
|
-
import '../../material/lightmodel.js';
|
|
12
4
|
import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
13
5
|
|
|
14
6
|
class GrassCluster {
|
|
@@ -49,8 +41,8 @@ class GrassCluster {
|
|
|
49
41
|
getSortDistance(camera) {
|
|
50
42
|
return this._terrain.getSortDistance(camera);
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
return this._terrain.grassMaterial.
|
|
44
|
+
getQueueType() {
|
|
45
|
+
return this._terrain.grassMaterial.getQueueType();
|
|
54
46
|
}
|
|
55
47
|
isUnlit() {
|
|
56
48
|
return !this._terrain.grassMaterial.supportLighting();
|
|
@@ -60,10 +52,8 @@ class GrassCluster {
|
|
|
60
52
|
}
|
|
61
53
|
draw(ctx) {
|
|
62
54
|
this._material.alphaToCoverage = Application.instance.device.getFrameBufferSampleCount() > 1;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this._terrain.grassMaterial.endDraw();
|
|
66
|
-
}
|
|
55
|
+
this._material.alphaCutoff = this._material.alphaToCoverage ? 1 : 0.8;
|
|
56
|
+
this._material.draw(this._primitive, ctx, this._numInstances);
|
|
67
57
|
}
|
|
68
58
|
}
|
|
69
59
|
class GrassManager {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { Vector4, Vector3 } from '@zephyr3d/base';
|
|
|
2
2
|
import { BoundingBox } from '../../utility/bounding_volume.js';
|
|
3
3
|
import { Primitive } from '../../render/primitive.js';
|
|
4
4
|
import { Application } from '../../app.js';
|
|
5
|
-
import { RENDER_PASS_TYPE_SHADOWMAP } from '../../values.js';
|
|
5
|
+
import { RENDER_PASS_TYPE_SHADOWMAP, QUEUE_OPAQUE } from '../../values.js';
|
|
6
6
|
|
|
7
7
|
/** @internal */ class TerrainPatch {
|
|
8
8
|
_terrain;
|
|
@@ -108,8 +108,8 @@ import { RENDER_PASS_TYPE_SHADOWMAP } from '../../values.js';
|
|
|
108
108
|
getSortDistance(camera) {
|
|
109
109
|
return this._quadtree.getTerrain().getSortDistance(camera);
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
return
|
|
111
|
+
getQueueType() {
|
|
112
|
+
return QUEUE_OPAQUE;
|
|
113
113
|
}
|
|
114
114
|
isUnlit() {
|
|
115
115
|
return false;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Vector3, Vector4, Vector2 } from '@zephyr3d/base';
|
|
2
2
|
import { Quadtree } from './quadtree.js';
|
|
3
|
-
import { MAX_DETAIL_TEXTURE_LEVELS, TerrainMaterial } from '../../material/terrainmaterial.js';
|
|
4
3
|
import { GraphNode } from '../graph_node.js';
|
|
5
4
|
import { Application } from '../../app.js';
|
|
6
5
|
import { GrassManager } from './grass.js';
|
|
6
|
+
import { TerrainMaterial } from '../../material/terrainmaterial.js';
|
|
7
7
|
import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -22,7 +22,6 @@ import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
|
22
22
|
/** @internal */ _height;
|
|
23
23
|
/** @internal */ _material;
|
|
24
24
|
/** @internal */ _grassMaterial;
|
|
25
|
-
/** @internal */ _maxDetailTextureLevels;
|
|
26
25
|
/** @internal */ _wireframe;
|
|
27
26
|
/** @internal */ _viewPoint;
|
|
28
27
|
/** @internal */ _castShadow;
|
|
@@ -45,7 +44,6 @@ import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
|
45
44
|
this._height = 0;
|
|
46
45
|
this._material = null;
|
|
47
46
|
this._grassMaterial = null;
|
|
48
|
-
this._maxDetailTextureLevels = MAX_DETAIL_TEXTURE_LEVELS;
|
|
49
47
|
this._wireframe = false;
|
|
50
48
|
this._viewPoint = null;
|
|
51
49
|
this._castShadow = true;
|
|
@@ -71,9 +69,6 @@ import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
|
71
69
|
set castShadow(val) {
|
|
72
70
|
this._castShadow = !!val;
|
|
73
71
|
}
|
|
74
|
-
/** The maximum value of detail texture levels */ get maxDetailTextureLevels() {
|
|
75
|
-
return this._maxDetailTextureLevels;
|
|
76
|
-
}
|
|
77
72
|
/** The maximum pixel error for terrain LOD */ get maxPixelError() {
|
|
78
73
|
return this._maxPixelError;
|
|
79
74
|
}
|
|
@@ -148,7 +143,8 @@ import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
|
148
143
|
this._heightFieldScale.set(scale);
|
|
149
144
|
this._width = sizeX;
|
|
150
145
|
this._height = sizeZ;
|
|
151
|
-
this._material.
|
|
146
|
+
this._material.normalTexture = this._quadtree.normalMap;
|
|
147
|
+
this._material.normalTexCoordIndex = -1;
|
|
152
148
|
this._material.terrainInfo = new Vector4(this.scaledWidth, this.scaledHeight, 0, 0);
|
|
153
149
|
this._overridenStateSet = Application.instance.device.createRenderStateSet();
|
|
154
150
|
this._overridenStateSet.useRasterizerState().setCullMode('front');
|
|
@@ -196,9 +192,8 @@ import { GrassMaterial } from '../../material/grassmaterial.js';
|
|
|
196
192
|
this._grassManager = new GrassManager(64, density);
|
|
197
193
|
}
|
|
198
194
|
if (!this._grassMaterial) {
|
|
199
|
-
this._grassMaterial = new GrassMaterial(new Vector2(this.scaledWidth, this.scaledHeight), this._quadtree.normalMap);
|
|
195
|
+
this._grassMaterial = new GrassMaterial(new Vector2(this.scaledWidth, this.scaledHeight), this._quadtree.normalMap, grassTexture);
|
|
200
196
|
}
|
|
201
|
-
this._grassMaterial = new GrassMaterial(new Vector2(this.scaledWidth, this.scaledHeight), this._quadtree.normalMap, grassTexture);
|
|
202
197
|
this._grassMaterial.stateSet.useRasterizerState().setCullMode('none');
|
|
203
198
|
this._grassManager.addGrassLayer(Application.instance.device, this, density, bladeWidth, bladeHeight, offset, grassTexture);
|
|
204
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terrain.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terrain.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Vector4 } from '@zephyr3d/base';
|
|
2
|
-
import { RENDER_PASS_TYPE_SHADOWMAP,
|
|
2
|
+
import { RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_LIGHT, MAX_CLUSTERED_LIGHTS } from '../values.js';
|
|
3
3
|
import { Application } from '../app.js';
|
|
4
4
|
import { ScatteringLut } from '../render/scatteringlut.js';
|
|
5
5
|
|
|
@@ -108,12 +108,12 @@ import { ScatteringLut } from '../render/scatteringlut.js';
|
|
|
108
108
|
lightStruct('light')
|
|
109
109
|
]);
|
|
110
110
|
scope.global = globalStruct().uniform(0);
|
|
111
|
-
} else if (ctx.renderPass.type ===
|
|
111
|
+
} else if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH) {
|
|
112
112
|
const globalStruct = pb.defineStruct([
|
|
113
113
|
cameraStruct('camera')
|
|
114
114
|
]);
|
|
115
115
|
scope.global = globalStruct().uniform(0);
|
|
116
|
-
} else if (ctx.renderPass.type ===
|
|
116
|
+
} else if (ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
117
117
|
const useClusteredLighting = !ctx.currentShadowLight;
|
|
118
118
|
const fogStruct = pb.defineStruct([
|
|
119
119
|
pb.int('fogType'),
|
|
@@ -431,6 +431,20 @@ import { ScatteringLut } from '../render/scatteringlut.js';
|
|
|
431
431
|
return scope.global.camera.viewProjectionMatrix;
|
|
432
432
|
}
|
|
433
433
|
/**
|
|
434
|
+
* Gets the uniform variable of type mat4 which holds the view matrix of current camera
|
|
435
|
+
* @param scope - Current shader scope
|
|
436
|
+
* @returns The view matrix of current camera
|
|
437
|
+
*/ static getViewMatrix(scope) {
|
|
438
|
+
return scope.global.camera.viewMatrix;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Gets the uniform variable of type mat4 which holds the projection matrix of current camera
|
|
442
|
+
* @param scope - Current shader scope
|
|
443
|
+
* @returns The projection matrix of current camera
|
|
444
|
+
*/ static getProjectionMatrix(scope) {
|
|
445
|
+
return scope.global.camera.projectionMatrix;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
434
448
|
* Gets the uniform variable of type mat4 which holds the view projection matrix of current camera
|
|
435
449
|
* @param scope - Current shader scope
|
|
436
450
|
* @returns The view projection matrix of current camera
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"framework.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|