@zephyr3d/scene 0.5.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/animationset.js +37 -37
- package/dist/animation/morphtrack.js +7 -5
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +11 -9
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/loaders/gltf/gltf_loader.js +7 -3
- package/dist/asset/loaders/gltf/gltf_loader.js.map +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 +3 -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 +7 -1
- 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 +142 -1
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1178 -745
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +9 -3
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +6 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +3 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +73 -33
- 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 +13 -4
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +13 -4
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +27 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +14 -3
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +14 -3
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +36 -21
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/posteffect/bloom.js +1 -10
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +43 -24
- 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 +44 -24
- 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 +305 -337
- 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 +5 -3
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +17 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +25 -19
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +4 -2
- 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 +35 -3
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +2 -1
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/render_queue.js +72 -52
- 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 +75 -36
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +16 -13
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +6 -0
- 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/scene/batchgroup.js +60 -14
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +2 -2
- package/dist/scene/graph_node.js +0 -5
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +5 -5
- package/dist/scene/mesh.js +34 -18
- 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 +1 -1
- package/dist/scene/scene_node.js +9 -5
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +3 -4
- 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 +3 -4
- package/dist/scene/terrain/patch.js.map +1 -1
- 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/shadowmapper.js +11 -11
- 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/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 +8 -1
- package/dist/values.js.map +1 -1
- package/package.json +4 -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/objectpool.js +0 -295
- package/dist/render/objectpool.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"water.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"water.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -50,8 +50,8 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
50
50
|
shadowMapSize: 1024,
|
|
51
51
|
numCascades: 1,
|
|
52
52
|
splitLambda: 0.5,
|
|
53
|
-
depthBias: 0.
|
|
54
|
-
normalBias: 0.
|
|
53
|
+
depthBias: 0.5,
|
|
54
|
+
normalBias: 0.2,
|
|
55
55
|
nearClip: 1
|
|
56
56
|
};
|
|
57
57
|
this._resourceDirty = true;
|
|
@@ -435,7 +435,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
435
435
|
up.setXYZ(0, 1, 0);
|
|
436
436
|
lightCamera.lookAt(center, target, up);
|
|
437
437
|
lightCamera.position.set(center);
|
|
438
|
-
lightCamera.setOrtho(-radius, radius, -radius, radius, -radius,
|
|
438
|
+
lightCamera.setOrtho(-radius, radius, -radius, radius, -radius, Math.max(Vector3.distance(center, sceneCamera.getWorldPosition()), sceneCamera.getFarPlane()));
|
|
439
439
|
center.setXYZ(0, 0, 0);
|
|
440
440
|
lightCamera.viewProjectionMatrix.transformPointP(center, center);
|
|
441
441
|
if (cropMatrix) {
|
|
@@ -575,11 +575,11 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
575
575
|
}
|
|
576
576
|
return result;
|
|
577
577
|
}
|
|
578
|
-
/** @internal */ calcDepthBiasParams(
|
|
579
|
-
const sizeNear = Math.min(
|
|
580
|
-
const sizeFar = Math.min(
|
|
581
|
-
const scaleFactor = sizeNear / shadowMapSize
|
|
582
|
-
result.setXYZW(depthBias * scaleFactor, normalBias *
|
|
578
|
+
/** @internal */ calcDepthBiasParams(camera, shadowMapSize, depthBias, normalBias, depthScale, result) {
|
|
579
|
+
const sizeNear = Math.min(camera.getProjectionMatrix().getNearPlaneWidth(), camera.getProjectionMatrix().getNearPlaneHeight());
|
|
580
|
+
const sizeFar = Math.min(camera.getProjectionMatrix().getFarPlaneWidth(), camera.getProjectionMatrix().getFarPlaneHeight());
|
|
581
|
+
const scaleFactor = sizeNear / shadowMapSize * 2;
|
|
582
|
+
result.setXYZW(depthBias * scaleFactor, normalBias * 0.0001, depthScale, sizeFar / sizeNear);
|
|
583
583
|
}
|
|
584
584
|
/** @internal */ postRenderShadowMap(shadowMapParams) {
|
|
585
585
|
this._impl.postRenderShadowMap(shadowMapParams);
|
|
@@ -607,7 +607,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
607
607
|
if (this._light.isPointLight()) {
|
|
608
608
|
const shadowMapRenderCamera = ShadowMapper.fetchCameraForScene(scene);
|
|
609
609
|
this.createLightCameraPoint(shadowMapRenderCamera);
|
|
610
|
-
this.calcDepthBiasParams(
|
|
610
|
+
this.calcDepthBiasParams(camera, this._config.shadowMapSize, this._config.depthBias, this._config.normalBias, depthScale, shadowMapParams.depthBiasValues[0]);
|
|
611
611
|
shadowMapParams.cameraParams.setXYZW(shadowMapRenderCamera.getNearPlane(), shadowMapRenderCamera.getFarPlane(), this._config.shadowMapSize, this._shadowDistance);
|
|
612
612
|
device.setFramebuffer(fb);
|
|
613
613
|
shadowMapParams.shadowMatrices.set(Matrix4x4.transpose(shadowMapRenderCamera.viewMatrix));
|
|
@@ -642,7 +642,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
642
642
|
const border = shadowMapParams.impl.getShadowMapBorder(shadowMapParams); //20 / this._config.shadowMapSize;
|
|
643
643
|
this.createLightCameraDirectional(shadowRegion, cascadeCamera, shadowMapRenderCamera, snapMatrix, border);
|
|
644
644
|
this.createLightCameraDirectional(shadowRegion, cascadeCamera, shadowMapCullCamera, null, border);
|
|
645
|
-
this.calcDepthBiasParams(
|
|
645
|
+
this.calcDepthBiasParams(camera, this._config.shadowMapSize, this._config.depthBias, this._config.normalBias, depthScale, shadowMapParams.depthBiasValues[split]);
|
|
646
646
|
shadowMapParams.depthBiasScales[split] = 1;
|
|
647
647
|
// Incorrect calculation
|
|
648
648
|
// shadowMapParams.depthBiasScales[split] = shadowMapParams.depthBiasValues[0].x !== 0 ? shadowMapParams.depthBiasValues[split].x / shadowMapParams.depthBiasValues[0].x : 1;
|
|
@@ -698,7 +698,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
698
698
|
} else {
|
|
699
699
|
this.createLightCameraSpot(shadowMapRenderCamera);
|
|
700
700
|
}
|
|
701
|
-
this.calcDepthBiasParams(
|
|
701
|
+
this.calcDepthBiasParams(camera, this._config.shadowMapSize, this._config.depthBias, this._config.normalBias, depthScale, shadowMapParams.depthBiasValues[0]);
|
|
702
702
|
shadowMapParams.cameraParams.setXYZW(shadowMapRenderCamera.getNearPlane(), shadowMapRenderCamera.getFarPlane(), this._config.shadowMapSize, this._shadowDistance);
|
|
703
703
|
device.setFramebuffer(fb);
|
|
704
704
|
shadowMapRenderCamera.setProjectionMatrix(Matrix4x4.multiply(snapMatrix, shadowMapRenderCamera.getProjectionMatrix()));
|
package/dist/shapes/cylinder.js
CHANGED
|
@@ -14,11 +14,12 @@ import { Shape } from './shape.js';
|
|
|
14
14
|
}
|
|
15
15
|
/** @internal */ createDefaultOptions() {
|
|
16
16
|
const options = super.createDefaultOptions();
|
|
17
|
-
options.topRadius = 1;
|
|
18
17
|
options.bottomRadius = 1;
|
|
18
|
+
options.topRadius = 1;
|
|
19
19
|
options.heightDetail = 1;
|
|
20
20
|
options.radialDetail = 20;
|
|
21
21
|
options.height = 1;
|
|
22
|
+
options.anchor = 0;
|
|
22
23
|
return options;
|
|
23
24
|
}
|
|
24
25
|
/** @internal */ addPatch(x, y, indices) {
|
|
@@ -30,17 +31,17 @@ import { Shape } from './shape.js';
|
|
|
30
31
|
indices.push(lt, lb, rb, lt, rb, rt);
|
|
31
32
|
}
|
|
32
33
|
/** @internal */ _createArrays(vertices, normals, uvs, indices) {
|
|
33
|
-
const slope = (this._options.
|
|
34
|
+
const slope = (this._options.topRadius - this._options.bottomRadius) / this._options.height;
|
|
34
35
|
for(let y = 0; y <= this._options.heightDetail; y++){
|
|
35
36
|
const v = y / this._options.heightDetail;
|
|
36
|
-
const radius = (this._options.
|
|
37
|
+
const radius = (this._options.topRadius - this._options.bottomRadius) * v + this._options.bottomRadius;
|
|
37
38
|
for(let x = 0; x <= this._options.radialDetail; x++){
|
|
38
39
|
const u = x / this._options.radialDetail;
|
|
39
40
|
const theta = u * Math.PI * 2;
|
|
40
41
|
const sinTheta = Math.sin(theta);
|
|
41
42
|
const cosTheta = Math.cos(theta);
|
|
42
43
|
const m = 1 / Math.sqrt(sinTheta * sinTheta + slope * slope + cosTheta * cosTheta);
|
|
43
|
-
vertices.push(radius * sinTheta, (v -
|
|
44
|
+
vertices.push(radius * sinTheta, (v - this._options.anchor) * this._options.height, radius * cosTheta);
|
|
44
45
|
normals.push(sinTheta * m, slope * m, cosTheta * m);
|
|
45
46
|
uvs.push(u, 1 - v);
|
|
46
47
|
if (y < this._options.heightDetail && x < this._options.radialDetail) {
|
|
@@ -60,7 +61,7 @@ import { Shape } from './shape.js';
|
|
|
60
61
|
this.createAndSetVertexBuffer('normal_f32x3', new Float32Array(normals));
|
|
61
62
|
this.createAndSetVertexBuffer('tex0_f32x2', new Float32Array(uvs));
|
|
62
63
|
this.createAndSetIndexBuffer(new Uint16Array(indices));
|
|
63
|
-
const radiusMax = Math.max(this._options.
|
|
64
|
+
const radiusMax = Math.max(this._options.bottomRadius, this._options.topRadius);
|
|
64
65
|
this.setBoundingVolume(new BoundingBox(new Vector3(-radiusMax, 0, -radiusMax), new Vector3(radiusMax, this._options.height, radiusMax)));
|
|
65
66
|
this.indexCount = indices.length;
|
|
66
67
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cylinder.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cylinder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AABB, Frustum, ClipState } from '@zephyr3d/base';
|
|
2
|
-
import { AABBTree } from './aabbtree.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* The bounding box class
|
|
@@ -25,57 +24,6 @@ import { AABBTree } from './aabbtree.js';
|
|
|
25
24
|
return this;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Bounding box tree
|
|
30
|
-
* @public
|
|
31
|
-
*/ class BoundingBoxTree extends AABBTree {
|
|
32
|
-
constructor(arg){
|
|
33
|
-
super(arg);
|
|
34
|
-
}
|
|
35
|
-
/** {@inheritDoc BoundingVolume.clone} */ clone() {
|
|
36
|
-
return new BoundingBoxTree(this);
|
|
37
|
-
}
|
|
38
|
-
/** {@inheritDoc BoundingVolume.transform} */ transform(matrix) {
|
|
39
|
-
const newBV = new BoundingBoxTree(this);
|
|
40
|
-
newBV.transform(matrix);
|
|
41
|
-
return newBV;
|
|
42
|
-
}
|
|
43
|
-
/** {@inheritDoc BoundingVolume.behindPlane} */ behindPlane(plane) {
|
|
44
|
-
return this.toAABB().behindPlane(plane);
|
|
45
|
-
}
|
|
46
|
-
/** {@inheritDoc BoundingVolume.outsideFrustum} */ outsideFrustum(frustum) {
|
|
47
|
-
const aabb = this.getTopLevelAABB();
|
|
48
|
-
if (aabb) {
|
|
49
|
-
return (frustum instanceof Frustum ? aabb.getClipStateWithFrustum(frustum) : aabb.getClipState(frustum)) === ClipState.NOT_CLIPPED;
|
|
50
|
-
} else {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** {@inheritDoc BoundingVolume.toAABB} */ toAABB() {
|
|
55
|
-
return this.getTopLevelAABB();
|
|
56
|
-
}
|
|
57
|
-
} /*
|
|
58
|
-
export class BoundingFrustum implements BoundingVolume {
|
|
59
|
-
protected _frustum: Frustum;
|
|
60
|
-
constructor ();
|
|
61
|
-
constructor (other: BoundingFrustum|Frustum|Matrix4x4);
|
|
62
|
-
constructor (arg0?: BoundingFrustum|Frustum|Matrix4x4) {
|
|
63
|
-
if (arg0 instanceof BoundingFrustum) {
|
|
64
|
-
this._frustum = arg0._frustum ? new Frustum (arg0._frustum) : null;
|
|
65
|
-
} else if (arg0 instanceof Frustum) {
|
|
66
|
-
this._frustum = new Frustum (arg0);
|
|
67
|
-
} else if (arg0 instanceof Matrix4x4) {
|
|
68
|
-
this._frustum = new Frustum (arg0);
|
|
69
|
-
} else {
|
|
70
|
-
this._frustum = null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
clone (): BoundingVolume {
|
|
74
|
-
return new BoundingFrustum (this);
|
|
75
|
-
}
|
|
76
|
-
transform (matrix: Matrix4x4)
|
|
77
|
-
}
|
|
78
|
-
*/
|
|
79
27
|
|
|
80
|
-
export { BoundingBox
|
|
28
|
+
export { BoundingBox };
|
|
81
29
|
//# sourceMappingURL=bounding_volume.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounding_volume.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bounding_volume.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Application } from '../app.js';
|
|
2
|
+
import '@zephyr3d/base';
|
|
3
|
+
import '@zephyr3d/device';
|
|
4
|
+
import { CopyBlitter } from '../blitter/copy.js';
|
|
5
|
+
|
|
6
|
+
const samplerOptions = {
|
|
7
|
+
clamp_linear: {
|
|
8
|
+
addressU: 'clamp',
|
|
9
|
+
addressV: 'clamp',
|
|
10
|
+
magFilter: 'linear',
|
|
11
|
+
minFilter: 'linear',
|
|
12
|
+
mipFilter: 'linear'
|
|
13
|
+
},
|
|
14
|
+
clamp_linear_nomip: {
|
|
15
|
+
addressU: 'clamp',
|
|
16
|
+
addressV: 'clamp',
|
|
17
|
+
magFilter: 'linear',
|
|
18
|
+
minFilter: 'linear',
|
|
19
|
+
mipFilter: 'none'
|
|
20
|
+
},
|
|
21
|
+
clamp_nearest: {
|
|
22
|
+
addressU: 'clamp',
|
|
23
|
+
addressV: 'clamp',
|
|
24
|
+
magFilter: 'nearest',
|
|
25
|
+
minFilter: 'nearest',
|
|
26
|
+
mipFilter: 'nearest'
|
|
27
|
+
},
|
|
28
|
+
clamp_nearest_nomip: {
|
|
29
|
+
addressU: 'clamp',
|
|
30
|
+
addressV: 'clamp',
|
|
31
|
+
magFilter: 'nearest',
|
|
32
|
+
minFilter: 'nearest',
|
|
33
|
+
mipFilter: 'none'
|
|
34
|
+
},
|
|
35
|
+
repeat_linear: {
|
|
36
|
+
addressU: 'repeat',
|
|
37
|
+
addressV: 'repeat',
|
|
38
|
+
magFilter: 'linear',
|
|
39
|
+
minFilter: 'linear',
|
|
40
|
+
mipFilter: 'linear'
|
|
41
|
+
},
|
|
42
|
+
repeat_linear_nomip: {
|
|
43
|
+
addressU: 'repeat',
|
|
44
|
+
addressV: 'repeat',
|
|
45
|
+
magFilter: 'linear',
|
|
46
|
+
minFilter: 'linear',
|
|
47
|
+
mipFilter: 'none'
|
|
48
|
+
},
|
|
49
|
+
repeat_nearest: {
|
|
50
|
+
addressU: 'repeat',
|
|
51
|
+
addressV: 'repeat',
|
|
52
|
+
magFilter: 'nearest',
|
|
53
|
+
minFilter: 'nearest',
|
|
54
|
+
mipFilter: 'nearest'
|
|
55
|
+
},
|
|
56
|
+
repeat_nearest_nomip: {
|
|
57
|
+
addressU: 'repeat',
|
|
58
|
+
addressV: 'repeat',
|
|
59
|
+
magFilter: 'nearest',
|
|
60
|
+
minFilter: 'nearest',
|
|
61
|
+
mipFilter: 'none'
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const samplers = {};
|
|
65
|
+
let copyBlitter = null;
|
|
66
|
+
let defaultCopyRenderState = null;
|
|
67
|
+
function fetchSampler(type) {
|
|
68
|
+
let sampler = samplers[type];
|
|
69
|
+
if (!sampler) {
|
|
70
|
+
const opt = samplerOptions[type];
|
|
71
|
+
if (opt) {
|
|
72
|
+
sampler = Application.instance.device.createSampler(opt);
|
|
73
|
+
samplers[type] = sampler;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return sampler;
|
|
77
|
+
}
|
|
78
|
+
function copyTexture(src, dest, sampler = null, renderState = null, layer = 0, srgbOut = false) {
|
|
79
|
+
if (!renderState && !defaultCopyRenderState) {
|
|
80
|
+
defaultCopyRenderState = src.device.createRenderStateSet();
|
|
81
|
+
defaultCopyRenderState.useDepthState().enableTest(false).enableWrite(false);
|
|
82
|
+
defaultCopyRenderState.useRasterizerState().setCullMode('none');
|
|
83
|
+
}
|
|
84
|
+
if (!copyBlitter) {
|
|
85
|
+
copyBlitter = new CopyBlitter();
|
|
86
|
+
}
|
|
87
|
+
copyBlitter.renderStates = renderState ?? defaultCopyRenderState;
|
|
88
|
+
copyBlitter.srgbOut = srgbOut;
|
|
89
|
+
copyBlitter.blit(src, dest, layer, sampler);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { copyTexture, fetchSampler };
|
|
93
|
+
//# sourceMappingURL=misc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { Application } from '../app.js';
|
|
|
3
3
|
import { Blitter } from '../blitter/blitter.js';
|
|
4
4
|
import '@zephyr3d/device';
|
|
5
5
|
import { CopyBlitter } from '../blitter/copy.js';
|
|
6
|
+
import { fetchSampler } from './misc.js';
|
|
6
7
|
|
|
7
8
|
class ReduceBlitter extends Blitter {
|
|
8
9
|
_width;
|
|
@@ -277,13 +278,7 @@ async function doProjectCubemap(srcTexture, coeff) {
|
|
|
277
278
|
device.setFramebuffer(null);
|
|
278
279
|
framebuffer.dispose();
|
|
279
280
|
const blitter = new ReduceBlitter();
|
|
280
|
-
const sampler =
|
|
281
|
-
addressU: 'clamp',
|
|
282
|
-
addressV: 'clamp',
|
|
283
|
-
magFilter: 'nearest',
|
|
284
|
-
minFilter: 'nearest',
|
|
285
|
-
mipFilter: 'none'
|
|
286
|
-
});
|
|
281
|
+
const sampler = fetchSampler('clamp_nearest_nomip');
|
|
287
282
|
for(let i = 1; i < tmpTextures.length; i++){
|
|
288
283
|
blitter.width = tmpTextures[i - 1].width;
|
|
289
284
|
blitter.blit(tmpTextures[i - 1], tmpTextures[i], sampler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shprojection.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shprojection.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { Application } from '../../app.js';
|
|
2
|
+
|
|
3
|
+
const ggxLut = new Map();
|
|
4
|
+
function getGGXLUT(size) {
|
|
5
|
+
let lut = ggxLut.get(size);
|
|
6
|
+
if (!lut) {
|
|
7
|
+
lut = createGGXLUT(size);
|
|
8
|
+
ggxLut.set(size, lut);
|
|
9
|
+
}
|
|
10
|
+
return lut;
|
|
11
|
+
}
|
|
12
|
+
function createGGXLUT(size) {
|
|
13
|
+
const device = Application.instance.device;
|
|
14
|
+
const program = device.buildRenderProgram({
|
|
15
|
+
vertex (pb) {
|
|
16
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
17
|
+
this.$outputs.uv = pb.vec2();
|
|
18
|
+
pb.main(function() {
|
|
19
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
20
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
21
|
+
if (device.type === 'webgpu') {
|
|
22
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
fragment (pb) {
|
|
27
|
+
this.$outputs.color = pb.vec4();
|
|
28
|
+
const SAMPLE_COUNT = 1024;
|
|
29
|
+
if (device.type === 'webgl') {
|
|
30
|
+
pb.func('radicalInverse_VdC', [
|
|
31
|
+
pb.int('bits')
|
|
32
|
+
], function() {
|
|
33
|
+
this.$l.rand = pb.float(0);
|
|
34
|
+
this.$l.denom = pb.float(1);
|
|
35
|
+
this.$l.invBase = pb.float(0.5);
|
|
36
|
+
this.$l.n = this.bits;
|
|
37
|
+
this.$for(pb.int('i'), 0, 32, function() {
|
|
38
|
+
this.denom = pb.mul(this.denom, 2);
|
|
39
|
+
this.rand = pb.add(this.rand, pb.div(pb.mod(pb.float(this.n), 2), this.denom));
|
|
40
|
+
this.n = pb.div(this.n, 2);
|
|
41
|
+
this.$if(pb.equal(this.n, 0), function() {
|
|
42
|
+
this.$break();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
this.$return(this.rand);
|
|
46
|
+
});
|
|
47
|
+
pb.func('hammersley2d', [
|
|
48
|
+
pb.int('i'),
|
|
49
|
+
pb.int('N')
|
|
50
|
+
], function() {
|
|
51
|
+
this.$return(pb.vec2(pb.div(pb.float(this.i), pb.float(this.N)), this.radicalInverse_VdC(this.i)));
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
pb.func('radicalInverse_VdC', [
|
|
55
|
+
pb.uint('bits')
|
|
56
|
+
], function() {
|
|
57
|
+
this.$l.n = this.bits;
|
|
58
|
+
this.n = pb.compOr(pb.sal(this.n, 16), pb.sar(this.n, 16));
|
|
59
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x55555555), 1), pb.sar(pb.compAnd(this.n, 0xaaaaaaaa), 1));
|
|
60
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x33333333), 2), pb.sar(pb.compAnd(this.n, 0xcccccccc), 2));
|
|
61
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x0f0f0f0f), 4), pb.sar(pb.compAnd(this.n, 0xf0f0f0f0), 4));
|
|
62
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x00ff00ff), 8), pb.sar(pb.compAnd(this.n, 0xff00ff00), 8));
|
|
63
|
+
this.$return(pb.mul(pb.float(this.n), 2.3283064365386963e-10));
|
|
64
|
+
});
|
|
65
|
+
pb.func('hammersley2d', [
|
|
66
|
+
pb.int('i'),
|
|
67
|
+
pb.int('N')
|
|
68
|
+
], function() {
|
|
69
|
+
this.$return(pb.vec2(pb.div(pb.float(this.i), pb.float(this.N)), this.radicalInverse_VdC(pb.uint(this.i))));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
pb.func('generateTBN', [
|
|
73
|
+
pb.vec3('normal')
|
|
74
|
+
], function() {
|
|
75
|
+
this.$l.bitangent = pb.vec3(0, 1, 0);
|
|
76
|
+
this.$l.NoU = this.normal.y;
|
|
77
|
+
this.$l.epsl = 0.0000001;
|
|
78
|
+
this.$if(pb.lessThanEqual(pb.sub(1, pb.abs(this.normal.y)), this.epsl), function() {
|
|
79
|
+
this.bitangent = this.$choice(pb.greaterThan(this.normal.y, 0), pb.vec3(0, 0, 1), pb.vec3(0, 0, -1));
|
|
80
|
+
});
|
|
81
|
+
this.$l.tangent = pb.normalize(pb.cross(this.bitangent, this.normal));
|
|
82
|
+
this.bitangent = pb.cross(this.normal, this.tangent);
|
|
83
|
+
this.$return(pb.mat3(this.tangent, this.bitangent, this.normal));
|
|
84
|
+
});
|
|
85
|
+
pb.func('D_Charlie', [
|
|
86
|
+
pb.float('sheenRoughness'),
|
|
87
|
+
pb.float('NdotH')
|
|
88
|
+
], function() {
|
|
89
|
+
this.$l.roughness = pb.max(this.sheenRoughness, 0.000001);
|
|
90
|
+
this.$l.invR = pb.div(1, this.roughness);
|
|
91
|
+
this.$l.cos2h = pb.mul(this.NdotH, this.NdotH);
|
|
92
|
+
this.$l.sin2h = pb.sub(1, this.cos2h);
|
|
93
|
+
this.$return(pb.div(pb.mul(pb.add(this.invR, 2), pb.pow(this.sin2h, pb.mul(this.invR, 0.5))), Math.PI * 2));
|
|
94
|
+
});
|
|
95
|
+
pb.func('smithGGXCorrelated', [
|
|
96
|
+
pb.float('NoV'),
|
|
97
|
+
pb.float('NoL'),
|
|
98
|
+
pb.float('roughness')
|
|
99
|
+
], function() {
|
|
100
|
+
this.$l.a2 = pb.mul(this.roughness, this.roughness, this.roughness, this.roughness);
|
|
101
|
+
this.$l.GGXV = pb.mul(this.NoL, pb.sqrt(pb.add(pb.mul(this.NoV, this.NoV, pb.sub(1, this.a2)), this.a2)));
|
|
102
|
+
this.$l.GGXL = pb.mul(this.NoV, pb.sqrt(pb.add(pb.mul(this.NoL, this.NoL, pb.sub(1, this.a2)), this.a2)));
|
|
103
|
+
this.$return(pb.div(0.5, pb.add(this.GGXV, this.GGXL)));
|
|
104
|
+
});
|
|
105
|
+
pb.func('V_Ashikhmin', [
|
|
106
|
+
pb.float('NdotL'),
|
|
107
|
+
pb.float('NdotV')
|
|
108
|
+
], function() {
|
|
109
|
+
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));
|
|
110
|
+
});
|
|
111
|
+
pb.func('importanceSample', [
|
|
112
|
+
pb.vec2('xi'),
|
|
113
|
+
pb.vec3('normal'),
|
|
114
|
+
pb.float('roughness'),
|
|
115
|
+
pb.vec3('ggx').out(),
|
|
116
|
+
pb.vec3('charlie').out()
|
|
117
|
+
], function() {
|
|
118
|
+
this.$l.alphaRoughness = pb.mul(this.roughness, this.roughness);
|
|
119
|
+
this.$l.cosTheta = pb.clamp(pb.sqrt(pb.div(pb.sub(1, this.xi.y), pb.add(1, pb.mul(pb.sub(pb.mul(this.alphaRoughness, this.alphaRoughness), 1), this.xi.y)))), 0, 1);
|
|
120
|
+
this.$l.sinTheta = pb.sqrt(pb.sub(1, pb.mul(this.cosTheta, this.cosTheta)));
|
|
121
|
+
this.$l.phi = pb.mul(this.xi.x, Math.PI * 2);
|
|
122
|
+
this.$l.TBN = this.generateTBN(this.normal);
|
|
123
|
+
this.$l.localSpaceDir = pb.normalize(pb.vec3(pb.mul(this.sinTheta, pb.cos(this.phi)), pb.mul(this.sinTheta, pb.sin(this.phi)), this.cosTheta));
|
|
124
|
+
this.ggx = pb.mul(this.TBN, this.localSpaceDir);
|
|
125
|
+
this.sinTheta = pb.pow(this.xi.y, pb.div(this.alphaRoughness, pb.add(pb.mul(this.alphaRoughness, 2), 1)));
|
|
126
|
+
this.cosTheta = pb.sqrt(pb.sub(1, pb.mul(this.sinTheta, this.sinTheta)));
|
|
127
|
+
this.localSpaceDir = pb.normalize(pb.vec3(pb.mul(this.sinTheta, pb.cos(this.phi)), pb.mul(this.sinTheta, pb.sin(this.phi)), this.cosTheta));
|
|
128
|
+
this.charlie = pb.mul(this.TBN, this.localSpaceDir);
|
|
129
|
+
});
|
|
130
|
+
pb.func('integrateBRDF', [
|
|
131
|
+
pb.float('NoV'),
|
|
132
|
+
pb.float('roughness')
|
|
133
|
+
], function() {
|
|
134
|
+
this.$l.V = pb.vec3(pb.sub(1, pb.mul(this.NoV, this.NoV)), 0, this.NoV);
|
|
135
|
+
this.$l.a = pb.float(0);
|
|
136
|
+
this.$l.b = pb.float(0);
|
|
137
|
+
this.$l.c = pb.float(0);
|
|
138
|
+
this.$l.n = pb.vec3(0, 0, 1);
|
|
139
|
+
this.$for(pb.int('i'), 0, SAMPLE_COUNT, function() {
|
|
140
|
+
this.$l.xi = this.hammersley2d(this.i, SAMPLE_COUNT);
|
|
141
|
+
this.$l.ggxSample = pb.vec3();
|
|
142
|
+
this.$l.charlieSample = pb.vec3();
|
|
143
|
+
this.importanceSample(this.xi, this.n, this.roughness, this.ggxSample, this.charlieSample);
|
|
144
|
+
this.$l.ggxL = pb.normalize(pb.reflect(pb.neg(this.V), this.ggxSample.xyz));
|
|
145
|
+
this.$l.ggxNoL = pb.clamp(this.ggxL.z, 0, 1);
|
|
146
|
+
this.$l.ggxNoH = pb.clamp(this.ggxSample.z, 0, 1);
|
|
147
|
+
this.$l.ggxVoH = pb.clamp(pb.dot(this.V, this.ggxSample.xyz), 0, 1);
|
|
148
|
+
this.$l.charlieL = pb.normalize(pb.reflect(pb.neg(this.V), this.charlieSample.xyz));
|
|
149
|
+
this.$l.charlieNoL = pb.clamp(this.charlieL.z, 0, 1);
|
|
150
|
+
this.$l.charlieNoH = pb.clamp(this.charlieSample.z, 0, 1);
|
|
151
|
+
this.$l.charlieVoH = pb.clamp(pb.dot(this.V, this.charlieSample.xyz), 0, 1);
|
|
152
|
+
this.$if(pb.greaterThan(this.ggxNoL, 0), function() {
|
|
153
|
+
this.$l.pdf = pb.div(pb.mul(this.smithGGXCorrelated(this.NoV, this.ggxNoL, this.roughness), this.ggxVoH, this.ggxNoL), this.ggxNoH);
|
|
154
|
+
this.$l.Fc = pb.pow(pb.sub(1, this.ggxVoH), 5);
|
|
155
|
+
this.a = pb.add(this.a, pb.mul(pb.sub(1, this.Fc), this.pdf));
|
|
156
|
+
this.b = pb.add(this.b, pb.mul(this.Fc, this.pdf));
|
|
157
|
+
});
|
|
158
|
+
this.$if(pb.greaterThan(this.charlieNoL, 0), function() {
|
|
159
|
+
this.$l.sheenDistribution = this.D_Charlie(this.roughness, this.charlieNoH);
|
|
160
|
+
this.$l.sheenVis = this.V_Ashikhmin(this.charlieNoL, this.NoV);
|
|
161
|
+
this.c = pb.add(this.c, pb.mul(this.sheenVis, this.sheenDistribution, this.charlieNoL, this.charlieVoH));
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
this.$return(pb.div(pb.vec3(pb.mul(this.a, 4), pb.mul(this.b, 4), pb.mul(this.c, 8 * Math.PI)), SAMPLE_COUNT));
|
|
165
|
+
});
|
|
166
|
+
pb.main(function() {
|
|
167
|
+
this.$outputs.color = pb.vec4(this.integrateBRDF(this.$inputs.uv.x, this.$inputs.uv.y), 1);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
const vertexLayout = device.createVertexLayout({
|
|
172
|
+
vertexBuffers: [
|
|
173
|
+
{
|
|
174
|
+
buffer: device.createVertexBuffer('position_f32x2', new Float32Array([
|
|
175
|
+
-1,
|
|
176
|
+
-1,
|
|
177
|
+
1,
|
|
178
|
+
-1,
|
|
179
|
+
-1,
|
|
180
|
+
1,
|
|
181
|
+
1,
|
|
182
|
+
1
|
|
183
|
+
]))
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
});
|
|
187
|
+
const rs = device.createRenderStateSet();
|
|
188
|
+
rs.useRasterizerState().setCullMode('none');
|
|
189
|
+
rs.useDepthState().enableTest(false).enableWrite(false);
|
|
190
|
+
const tex = device.createTexture2D('rgba8unorm', size, size, {
|
|
191
|
+
samplerOptions: {
|
|
192
|
+
mipFilter: 'none'
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
tex.name = 'GGXLUT';
|
|
196
|
+
const fb = device.createFrameBuffer([
|
|
197
|
+
tex
|
|
198
|
+
], null);
|
|
199
|
+
device.pushDeviceStates();
|
|
200
|
+
device.setProgram(program);
|
|
201
|
+
device.setVertexLayout(vertexLayout);
|
|
202
|
+
device.setRenderStates(rs);
|
|
203
|
+
device.setFramebuffer(fb);
|
|
204
|
+
device.draw('triangle-strip', 0, 4);
|
|
205
|
+
device.popDeviceStates();
|
|
206
|
+
fb.dispose();
|
|
207
|
+
vertexLayout.dispose();
|
|
208
|
+
program.dispose();
|
|
209
|
+
return tex;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { getGGXLUT };
|
|
213
|
+
//# sourceMappingURL=ggxlut.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ggxlut.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { drawFullscreenQuad } from '../../render/fullscreenquad.js';
|
|
2
|
+
import '@zephyr3d/device';
|
|
3
|
+
import { perlinNoise3D } from '../../shaders/noise.js';
|
|
4
|
+
import '../../app.js';
|
|
5
|
+
|
|
6
|
+
let gradientNoiseProgram = null;
|
|
7
|
+
let gradientNoiseBindGroup = null;
|
|
8
|
+
/** @internal */ function createGradientNoiseTexture(device, size, uvscale, mono = false, seed = 0) {
|
|
9
|
+
if (!gradientNoiseProgram) {
|
|
10
|
+
gradientNoiseProgram = device.buildRenderProgram({
|
|
11
|
+
vertex (pb) {
|
|
12
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
13
|
+
this.$outputs.uv = pb.vec2();
|
|
14
|
+
pb.main(function() {
|
|
15
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
16
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
17
|
+
if (device.type === 'webgpu') {
|
|
18
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
fragment (pb) {
|
|
23
|
+
this.$outputs.color = pb.vec4();
|
|
24
|
+
this.uvScale = pb.float().uniform(0);
|
|
25
|
+
this.seed = pb.float().uniform(0);
|
|
26
|
+
this.mono = pb.int().uniform(0);
|
|
27
|
+
pb.main(function() {
|
|
28
|
+
this.$l.p = pb.vec3(pb.mul(this.$inputs.uv, this.uvScale), this.seed);
|
|
29
|
+
this.$l.r = perlinNoise3D(this, this.p);
|
|
30
|
+
//this.$l.r = gradient(this, this.p.xy, this.p.z).x;
|
|
31
|
+
this.$if(pb.notEqual(this.mono, 0), function() {
|
|
32
|
+
this.$outputs.color = pb.vec4(pb.vec3(this.r), 1);
|
|
33
|
+
}).$else(function() {
|
|
34
|
+
this.$l.g = perlinNoise3D(this, pb.vec3(pb.mul(this.$inputs.uv, this.uvScale), pb.add(this.seed, 1.9)));
|
|
35
|
+
this.$l.b = perlinNoise3D(this, pb.vec3(pb.mul(this.$inputs.uv, this.uvScale), pb.add(this.seed, 2.3)));
|
|
36
|
+
this.$outputs.color = pb.vec4(this.r, this.g, this.b, 1);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
gradientNoiseBindGroup = device.createBindGroup(gradientNoiseProgram.bindGroupLayouts[0]);
|
|
42
|
+
}
|
|
43
|
+
const tex = device.createTexture2D('rgba8unorm', size, size);
|
|
44
|
+
const fb = device.createFrameBuffer([
|
|
45
|
+
tex
|
|
46
|
+
], null);
|
|
47
|
+
gradientNoiseBindGroup.setValue('uvScale', uvscale);
|
|
48
|
+
gradientNoiseBindGroup.setValue('seed', seed);
|
|
49
|
+
gradientNoiseBindGroup.setValue('mono', mono ? 1 : 0);
|
|
50
|
+
device.pushDeviceStates();
|
|
51
|
+
device.setFramebuffer(fb);
|
|
52
|
+
device.setProgram(gradientNoiseProgram);
|
|
53
|
+
device.setBindGroup(0, gradientNoiseBindGroup);
|
|
54
|
+
drawFullscreenQuad();
|
|
55
|
+
device.popDeviceStates();
|
|
56
|
+
fb.dispose();
|
|
57
|
+
return tex;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { createGradientNoiseTexture };
|
|
61
|
+
//# sourceMappingURL=gradientnoise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradientnoise.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { drawFullscreenQuad } from '../../render/fullscreenquad.js';
|
|
2
|
+
|
|
3
|
+
let randomNoiseProgram = null;
|
|
4
|
+
/** @internal */ function createRandomNoiseTexture(device, size) {
|
|
5
|
+
if (!randomNoiseProgram) {
|
|
6
|
+
randomNoiseProgram = device.buildRenderProgram({
|
|
7
|
+
vertex (pb) {
|
|
8
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
9
|
+
this.$outputs.uv = pb.vec2();
|
|
10
|
+
pb.main(function() {
|
|
11
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
12
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
13
|
+
if (device.type === 'webgpu') {
|
|
14
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
fragment (pb) {
|
|
19
|
+
this.$outputs.color = pb.vec4();
|
|
20
|
+
pb.main(function() {
|
|
21
|
+
this.$l.noise = pb.fract(pb.mul(pb.sin(pb.dot(this.$inputs.uv, pb.vec2(12.9898, 78.233))), 43758.5453));
|
|
22
|
+
this.$outputs.color = pb.vec4(pb.vec3(this.noise), 1);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const tex = device.createTexture2D('rgba8unorm', size, size);
|
|
28
|
+
const fb = device.createFrameBuffer([
|
|
29
|
+
tex
|
|
30
|
+
], null);
|
|
31
|
+
device.pushDeviceStates();
|
|
32
|
+
device.setFramebuffer(fb);
|
|
33
|
+
device.setProgram(randomNoiseProgram);
|
|
34
|
+
drawFullscreenQuad();
|
|
35
|
+
device.popDeviceStates();
|
|
36
|
+
fb.dispose();
|
|
37
|
+
return tex;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { createRandomNoiseTexture };
|
|
41
|
+
//# sourceMappingURL=randomnoise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomnoise.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/values.js
CHANGED
|
@@ -63,6 +63,13 @@
|
|
|
63
63
|
/** @internal */ const MAX_MORPH_TARGETS = 256;
|
|
64
64
|
/** @internal */ const MORPH_WEIGHTS_VECTOR_COUNT = MAX_MORPH_TARGETS + 3 >> 2;
|
|
65
65
|
/** @internal */ const MORPH_ATTRIBUTE_VECTOR_COUNT = MAX_MORPH_ATTRIBUTES + 3 >> 2;
|
|
66
|
+
var MaterialVaryingFlags;
|
|
67
|
+
(function(MaterialVaryingFlags) {
|
|
68
|
+
MaterialVaryingFlags[MaterialVaryingFlags["MORPH_ANIMATION"] = 1] = "MORPH_ANIMATION";
|
|
69
|
+
MaterialVaryingFlags[MaterialVaryingFlags["SKIN_ANIMATION"] = 2] = "SKIN_ANIMATION";
|
|
70
|
+
MaterialVaryingFlags[MaterialVaryingFlags["INSTANCING"] = 4] = "INSTANCING";
|
|
71
|
+
MaterialVaryingFlags[MaterialVaryingFlags["SSR_STORE_ROUGHNESS"] = 8] = "SSR_STORE_ROUGHNESS";
|
|
72
|
+
})(MaterialVaryingFlags || (MaterialVaryingFlags = {}));
|
|
66
73
|
|
|
67
|
-
export { BUILTIN_ASSET_TEST_CUBEMAP, BUILTIN_ASSET_TEXTURE_SHEEN_LUT, LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_NONE, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT, MAX_CLUSTERED_LIGHTS, MAX_MORPH_ATTRIBUTES, MAX_MORPH_TARGETS, MORPH_ATTRIBUTE_VECTOR_COUNT, MORPH_TARGET_COLOR, MORPH_TARGET_NORMAL, MORPH_TARGET_POSITION, MORPH_TARGET_TANGENT, MORPH_TARGET_TEX0, MORPH_TARGET_TEX1, MORPH_TARGET_TEX2, MORPH_TARGET_TEX3, MORPH_WEIGHTS_VECTOR_COUNT, QUEUE_OPAQUE, QUEUE_TRANSPARENT, RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_LIGHT, RENDER_PASS_TYPE_OBJECT_COLOR, RENDER_PASS_TYPE_SHADOWMAP };
|
|
74
|
+
export { BUILTIN_ASSET_TEST_CUBEMAP, BUILTIN_ASSET_TEXTURE_SHEEN_LUT, LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_NONE, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT, MAX_CLUSTERED_LIGHTS, MAX_MORPH_ATTRIBUTES, MAX_MORPH_TARGETS, MORPH_ATTRIBUTE_VECTOR_COUNT, MORPH_TARGET_COLOR, MORPH_TARGET_NORMAL, MORPH_TARGET_POSITION, MORPH_TARGET_TANGENT, MORPH_TARGET_TEX0, MORPH_TARGET_TEX1, MORPH_TARGET_TEX2, MORPH_TARGET_TEX3, MORPH_WEIGHTS_VECTOR_COUNT, MaterialVaryingFlags, QUEUE_OPAQUE, QUEUE_TRANSPARENT, RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_LIGHT, RENDER_PASS_TYPE_OBJECT_COLOR, RENDER_PASS_TYPE_SHADOWMAP };
|
|
68
75
|
//# sourceMappingURL=values.js.map
|