@zephyr3d/scene 0.1.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 +173 -0
- package/dist/animation/animation.js.map +1 -0
- package/dist/animation/animationset.js +95 -0
- package/dist/animation/animationset.js.map +1 -0
- package/dist/animation/animationtrack.js +38 -0
- package/dist/animation/animationtrack.js.map +1 -0
- package/dist/animation/eulerrotationtrack.js +33 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +37 -0
- package/dist/animation/rotationtrack.js.map +1 -0
- package/dist/animation/scaletrack.js +36 -0
- package/dist/animation/scaletrack.js.map +1 -0
- package/dist/animation/skeleton.js +97 -0
- package/dist/animation/skeleton.js.map +1 -0
- package/dist/animation/translationtrack.js +36 -0
- package/dist/animation/translationtrack.js.map +1 -0
- package/dist/animation/usertrack.js +47 -0
- package/dist/animation/usertrack.js.map +1 -0
- package/dist/app.js +173 -0
- package/dist/app.js.map +1 -0
- package/dist/asset/assetmanager.js +476 -0
- package/dist/asset/assetmanager.js.map +1 -0
- package/dist/asset/builtin.js +373 -0
- package/dist/asset/builtin.js.map +1 -0
- package/dist/asset/loaders/dds/dds.js +472 -0
- package/dist/asset/loaders/dds/dds.js.map +1 -0
- package/dist/asset/loaders/dds/dds_loader.js +38 -0
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/asset/loaders/gltf/gltf_loader.js +981 -0
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/asset/loaders/gltf/helpers.js +314 -0
- package/dist/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/asset/loaders/hdr/hdr.js +175 -0
- package/dist/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/asset/loaders/image/tga_Loader.js +117 -0
- package/dist/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/asset/loaders/image/webimage_loader.js +50 -0
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/asset/loaders/loader.js +45 -0
- package/dist/asset/loaders/loader.js.map +1 -0
- package/dist/asset/model.js +264 -0
- package/dist/asset/model.js.map +1 -0
- package/dist/blitter/blitter.js +389 -0
- package/dist/blitter/blitter.js.map +1 -0
- package/dist/blitter/box.js +118 -0
- package/dist/blitter/box.js.map +1 -0
- package/dist/blitter/copy.js +22 -0
- package/dist/blitter/copy.js.map +1 -0
- package/dist/blitter/depthlimitedgaussion.js +166 -0
- package/dist/blitter/depthlimitedgaussion.js.map +1 -0
- package/dist/blitter/gaussianblur.js +229 -0
- package/dist/blitter/gaussianblur.js.map +1 -0
- package/dist/camera/base.js +90 -0
- package/dist/camera/base.js.map +1 -0
- package/dist/camera/camera.js +358 -0
- package/dist/camera/camera.js.map +1 -0
- package/dist/camera/fps.js +246 -0
- package/dist/camera/fps.js.map +1 -0
- package/dist/camera/orbit.js +157 -0
- package/dist/camera/orbit.js.map +1 -0
- package/dist/camera/orthocamera.js +126 -0
- package/dist/camera/orthocamera.js.map +1 -0
- package/dist/camera/perspectivecamera.js +133 -0
- package/dist/camera/perspectivecamera.js.map +1 -0
- package/dist/index.d.ts +8402 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/input/inputmgr.js +242 -0
- package/dist/input/inputmgr.js.map +1 -0
- package/dist/material/blinn.js +75 -0
- package/dist/material/blinn.js.map +1 -0
- package/dist/material/grassmaterial.js +221 -0
- package/dist/material/grassmaterial.js.map +1 -0
- package/dist/material/lambert.js +52 -0
- package/dist/material/lambert.js.map +1 -0
- package/dist/material/lightmodel.js +2074 -0
- package/dist/material/lightmodel.js.map +1 -0
- package/dist/material/lit.js +578 -0
- package/dist/material/lit.js.map +1 -0
- package/dist/material/material.js +458 -0
- package/dist/material/material.js.map +1 -0
- package/dist/material/meshmaterial.js +311 -0
- package/dist/material/meshmaterial.js.map +1 -0
- package/dist/material/mixins/albedocolor.js +130 -0
- package/dist/material/mixins/albedocolor.js.map +1 -0
- package/dist/material/mixins/texture.js +110 -0
- package/dist/material/mixins/texture.js.map +1 -0
- package/dist/material/mixins/vertexcolor.js +45 -0
- package/dist/material/mixins/vertexcolor.js.map +1 -0
- package/dist/material/pbr.js +27 -0
- package/dist/material/pbr.js.map +1 -0
- package/dist/material/standard.js +282 -0
- package/dist/material/standard.js.map +1 -0
- package/dist/material/terrainlightmodel.js +259 -0
- package/dist/material/terrainlightmodel.js.map +1 -0
- package/dist/material/terrainmaterial.js +139 -0
- package/dist/material/terrainmaterial.js.map +1 -0
- package/dist/material/unlit.js +29 -0
- package/dist/material/unlit.js.map +1 -0
- package/dist/posteffect/bloom.js +398 -0
- package/dist/posteffect/bloom.js.map +1 -0
- package/dist/posteffect/compositor.js +264 -0
- package/dist/posteffect/compositor.js.map +1 -0
- package/dist/posteffect/fxaa.js +291 -0
- package/dist/posteffect/fxaa.js.map +1 -0
- package/dist/posteffect/grayscale.js +87 -0
- package/dist/posteffect/grayscale.js.map +1 -0
- package/dist/posteffect/posteffect.js +165 -0
- package/dist/posteffect/posteffect.js.map +1 -0
- package/dist/posteffect/sao.js +327 -0
- package/dist/posteffect/sao.js.map +1 -0
- package/dist/posteffect/tonemap.js +112 -0
- package/dist/posteffect/tonemap.js.map +1 -0
- package/dist/posteffect/water.js +535 -0
- package/dist/posteffect/water.js.map +1 -0
- package/dist/render/clipmap.js +462 -0
- package/dist/render/clipmap.js.map +1 -0
- package/dist/render/cluster_light.js +329 -0
- package/dist/render/cluster_light.js.map +1 -0
- package/dist/render/cull_visitor.js +124 -0
- package/dist/render/cull_visitor.js.map +1 -0
- package/dist/render/depth_pass.js +47 -0
- package/dist/render/depth_pass.js.map +1 -0
- package/dist/render/envlight.js +282 -0
- package/dist/render/envlight.js.map +1 -0
- package/dist/render/forward.js +186 -0
- package/dist/render/forward.js.map +1 -0
- package/dist/render/forward_pass.js +137 -0
- package/dist/render/forward_pass.js.map +1 -0
- package/dist/render/helper.js +38 -0
- package/dist/render/helper.js.map +1 -0
- package/dist/render/primitive.js +246 -0
- package/dist/render/primitive.js.map +1 -0
- package/dist/render/render_queue.js +163 -0
- package/dist/render/render_queue.js.map +1 -0
- package/dist/render/renderpass.js +151 -0
- package/dist/render/renderpass.js.map +1 -0
- package/dist/render/renderscheme.js +61 -0
- package/dist/render/renderscheme.js.map +1 -0
- package/dist/render/scatteringlut.js +634 -0
- package/dist/render/scatteringlut.js.map +1 -0
- package/dist/render/shadowmap_pass.js +70 -0
- package/dist/render/shadowmap_pass.js.map +1 -0
- package/dist/render/sky.js +881 -0
- package/dist/render/sky.js.map +1 -0
- package/dist/render/temporalcache.js +222 -0
- package/dist/render/temporalcache.js.map +1 -0
- package/dist/render/watermesh.js +835 -0
- package/dist/render/watermesh.js.map +1 -0
- package/dist/scene/environment.js +146 -0
- package/dist/scene/environment.js.map +1 -0
- package/dist/scene/graph_node.js +69 -0
- package/dist/scene/graph_node.js.map +1 -0
- package/dist/scene/light.js +436 -0
- package/dist/scene/light.js.map +1 -0
- package/dist/scene/mesh.js +215 -0
- package/dist/scene/mesh.js.map +1 -0
- package/dist/scene/model.js +111 -0
- package/dist/scene/model.js.map +1 -0
- package/dist/scene/octree.js +651 -0
- package/dist/scene/octree.js.map +1 -0
- package/dist/scene/octree_update_visitor.js +16 -0
- package/dist/scene/octree_update_visitor.js.map +1 -0
- package/dist/scene/raycast_visitor.js +72 -0
- package/dist/scene/raycast_visitor.js.map +1 -0
- package/dist/scene/scene.js +225 -0
- package/dist/scene/scene.js.map +1 -0
- package/dist/scene/scene_node.js +299 -0
- package/dist/scene/scene_node.js.map +1 -0
- package/dist/scene/terrain/grass.js +277 -0
- package/dist/scene/terrain/grass.js.map +1 -0
- package/dist/scene/terrain/heightfield.js +391 -0
- package/dist/scene/terrain/heightfield.js.map +1 -0
- package/dist/scene/terrain/patch.js +530 -0
- package/dist/scene/terrain/patch.js.map +1 -0
- package/dist/scene/terrain/quadtree.js +430 -0
- package/dist/scene/terrain/quadtree.js.map +1 -0
- package/dist/scene/terrain/terrain.js +258 -0
- package/dist/scene/terrain/terrain.js.map +1 -0
- package/dist/scene/xform.js +224 -0
- package/dist/scene/xform.js.map +1 -0
- package/dist/shaders/builtins.js +110 -0
- package/dist/shaders/builtins.js.map +1 -0
- package/dist/shaders/framework.js +709 -0
- package/dist/shaders/framework.js.map +1 -0
- package/dist/shaders/lighting.js +335 -0
- package/dist/shaders/lighting.js.map +1 -0
- package/dist/shaders/misc.js +405 -0
- package/dist/shaders/misc.js.map +1 -0
- package/dist/shaders/noise.js +157 -0
- package/dist/shaders/noise.js.map +1 -0
- package/dist/shaders/pbr.js +132 -0
- package/dist/shaders/pbr.js.map +1 -0
- package/dist/shaders/shadow.js +642 -0
- package/dist/shaders/shadow.js.map +1 -0
- package/dist/shaders/water.js +630 -0
- package/dist/shaders/water.js.map +1 -0
- package/dist/shadow/esm.js +235 -0
- package/dist/shadow/esm.js.map +1 -0
- package/dist/shadow/pcf_opt.js +182 -0
- package/dist/shadow/pcf_opt.js.map +1 -0
- package/dist/shadow/pcf_pd.js +190 -0
- package/dist/shadow/pcf_pd.js.map +1 -0
- package/dist/shadow/shadow_impl.js +15 -0
- package/dist/shadow/shadow_impl.js.map +1 -0
- package/dist/shadow/shadowmapper.js +709 -0
- package/dist/shadow/shadowmapper.js.map +1 -0
- package/dist/shadow/ssm.js +194 -0
- package/dist/shadow/ssm.js.map +1 -0
- package/dist/shadow/vsm.js +298 -0
- package/dist/shadow/vsm.js.map +1 -0
- package/dist/shapes/box.js +313 -0
- package/dist/shapes/box.js.map +1 -0
- package/dist/shapes/cylinder.js +74 -0
- package/dist/shapes/cylinder.js.map +1 -0
- package/dist/shapes/plane.js +48 -0
- package/dist/shapes/plane.js.map +1 -0
- package/dist/shapes/shape.js +33 -0
- package/dist/shapes/shape.js.map +1 -0
- package/dist/shapes/sphere.js +91 -0
- package/dist/shapes/sphere.js.map +1 -0
- package/dist/shapes/torus.js +100 -0
- package/dist/shapes/torus.js.map +1 -0
- package/dist/utility/aabbtree.js +390 -0
- package/dist/utility/aabbtree.js.map +1 -0
- package/dist/utility/bounding_volume.js +78 -0
- package/dist/utility/bounding_volume.js.map +1 -0
- package/dist/utility/panorama.js +163 -0
- package/dist/utility/panorama.js.map +1 -0
- package/dist/utility/pmrem.js +345 -0
- package/dist/utility/pmrem.js.map +1 -0
- package/dist/utility/shprojection.js +448 -0
- package/dist/utility/shprojection.js.map +1 -0
- package/dist/values.js +48 -0
- package/dist/values.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Material } from './material.js';
|
|
2
|
+
import { forwardComputeLighting } from '../shaders/lighting.js';
|
|
3
|
+
import { RENDER_PASS_TYPE_FORWARD, RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_DEPTH_ONLY } from '../values.js';
|
|
4
|
+
import { ShaderFramework } from '../shaders/framework.js';
|
|
5
|
+
import { encodeColorOutput, nonLinearDepthToLinearNormalized, encodeNormalizedFloatToRGBA } from '../shaders/misc.js';
|
|
6
|
+
import { Application } from '../app.js';
|
|
7
|
+
import { TerrainLightModel } from './terrainlightmodel.js';
|
|
8
|
+
import { MESH_MATERIAL } from '../shaders/builtins.js';
|
|
9
|
+
|
|
10
|
+
/** @internal */ const MAX_DETAIL_TEXTURE_LEVELS = 8;
|
|
11
|
+
/**
|
|
12
|
+
* The terrain material
|
|
13
|
+
* @public
|
|
14
|
+
*/ class TerrainMaterial extends Material {
|
|
15
|
+
/** @internal */ _lightModel;
|
|
16
|
+
/** @internal */ _terrainInfo;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of TerrainMaterial
|
|
19
|
+
*/ constructor(options){
|
|
20
|
+
super();
|
|
21
|
+
this._terrainInfo = null;
|
|
22
|
+
this._lightModel = new TerrainLightModel(options);
|
|
23
|
+
}
|
|
24
|
+
get lightModel() {
|
|
25
|
+
return this._lightModel;
|
|
26
|
+
}
|
|
27
|
+
get terrainInfo() {
|
|
28
|
+
return this._terrainInfo;
|
|
29
|
+
}
|
|
30
|
+
set terrainInfo(val) {
|
|
31
|
+
this._terrainInfo = val;
|
|
32
|
+
this.optionChanged(false);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* {@inheritDoc Material.isTransparent}
|
|
36
|
+
* @override
|
|
37
|
+
*/ isTransparent() {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* {@inheritDoc Material.supportLighting}
|
|
42
|
+
* @override
|
|
43
|
+
*/ supportLighting() {
|
|
44
|
+
return this._lightModel.supportLighting();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* {@inheritDoc Material.applyUniforms}
|
|
48
|
+
* @override
|
|
49
|
+
*/ applyUniforms(bindGroup, ctx, needUpdate) {
|
|
50
|
+
super.applyUniforms(bindGroup, ctx, needUpdate);
|
|
51
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_FORWARD) {
|
|
52
|
+
this._lightModel.applyUniformsIfOutdated(bindGroup, ctx);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* {@inheritDoc Material._applyUniforms}
|
|
57
|
+
* @override
|
|
58
|
+
*/ _applyUniforms(bindGroup, ctx) {
|
|
59
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_FORWARD) {
|
|
60
|
+
bindGroup.setValue('terrainInfo', this._terrainInfo);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** @internal */ getHash(renderPassType) {
|
|
64
|
+
if (this._hash[renderPassType] === void 0) {
|
|
65
|
+
this._hash[renderPassType] = this.createHash(renderPassType);
|
|
66
|
+
}
|
|
67
|
+
return this._hash[renderPassType];
|
|
68
|
+
}
|
|
69
|
+
/** @internal */ _createHash(renderPassType) {
|
|
70
|
+
return renderPassType === RENDER_PASS_TYPE_FORWARD ? this._lightModel.getHash() : '';
|
|
71
|
+
}
|
|
72
|
+
/** @internal */ _createProgram(pb, ctx) {
|
|
73
|
+
const that = this;
|
|
74
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_SHADOWMAP) {
|
|
75
|
+
const shadowMapParams = ctx.shadowMapInfo.get(ctx.renderPass.light);
|
|
76
|
+
pb.emulateDepthClamp = !!shadowMapParams.depthClampEnabled;
|
|
77
|
+
}
|
|
78
|
+
const program = pb.buildRenderProgram({
|
|
79
|
+
vertex () {
|
|
80
|
+
ShaderFramework.prepareVertexShader(pb, ctx);
|
|
81
|
+
this.$inputs.pos = pb.vec3().attrib('position');
|
|
82
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_FORWARD) {
|
|
83
|
+
this.terrainInfo = pb.vec4().uniform(2);
|
|
84
|
+
this.$inputs.normal = pb.vec3().attrib('normal');
|
|
85
|
+
that._lightModel.setupUniforms(this, ctx);
|
|
86
|
+
}
|
|
87
|
+
pb.main(function() {
|
|
88
|
+
ShaderFramework.ftransform(this);
|
|
89
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_FORWARD) {
|
|
90
|
+
this.$l.uv = pb.div(this.$inputs.pos.xz, this.terrainInfo.xy);
|
|
91
|
+
for(let i = 0; i < Application.instance.device.getDeviceCaps().miscCaps.maxTexCoordIndex; i++){
|
|
92
|
+
if (that._lightModel?.isTexCoordIndexUsed(i)) {
|
|
93
|
+
this.$outputs[`texcoord${i}`] = that._lightModel.calculateTexCoordNoInput(this, i, this.uv);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
fragment () {
|
|
100
|
+
ShaderFramework.prepareFragmentShader(pb, ctx);
|
|
101
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_FORWARD) {
|
|
102
|
+
that._lightModel.setupUniforms(this, ctx);
|
|
103
|
+
this.$outputs.outColor = pb.vec4();
|
|
104
|
+
pb.main(function() {
|
|
105
|
+
this.$l.litColor = forwardComputeLighting(this, that._lightModel, ctx);
|
|
106
|
+
MESH_MATERIAL.DISCARD_IF_CLIPPED(this);
|
|
107
|
+
this.$outputs.outColor = encodeColorOutput(this, this.litColor);
|
|
108
|
+
});
|
|
109
|
+
} else if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH_ONLY) {
|
|
110
|
+
this.$outputs.outColor = pb.vec4();
|
|
111
|
+
pb.main(function() {
|
|
112
|
+
MESH_MATERIAL.DISCARD_IF_CLIPPED(this);
|
|
113
|
+
this.$l.depth = nonLinearDepthToLinearNormalized(this, this.$builtins.fragCoord.z);
|
|
114
|
+
if (Application.instance.device.type === 'webgl') {
|
|
115
|
+
this.$outputs.outColor = encodeNormalizedFloatToRGBA(this, this.depth);
|
|
116
|
+
} else {
|
|
117
|
+
this.$outputs.outColor = pb.vec4(this.depth, 0, 0, 1);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
} else if (ctx.renderPass.type === RENDER_PASS_TYPE_SHADOWMAP) {
|
|
121
|
+
this.$outputs.outColor = pb.vec4();
|
|
122
|
+
pb.main(function() {
|
|
123
|
+
MESH_MATERIAL.DISCARD_IF_CLIPPED(this);
|
|
124
|
+
const shadowMapParams = ctx.shadowMapInfo.get(ctx.renderPass.light);
|
|
125
|
+
this.$outputs.outColor = shadowMapParams.impl.computeShadowMapDepth(shadowMapParams, this);
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
throw new Error(`unknown render pass type: ${ctx.renderPass.type}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
// console.log(program?.getShaderSource('vertex'));
|
|
133
|
+
// console.log(program?.getShaderSource('fragment'));
|
|
134
|
+
return program;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { MAX_DETAIL_TEXTURE_LEVELS, TerrainMaterial };
|
|
139
|
+
//# sourceMappingURL=terrainmaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terrainmaterial.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { applyMaterialMixins, MeshMaterial } from './meshmaterial.js';
|
|
2
|
+
import { mixinAlbedoColor } from './mixins/albedocolor.js';
|
|
3
|
+
import { mixinVertexColor } from './mixins/vertexcolor.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Unlit material
|
|
7
|
+
* @public
|
|
8
|
+
*/ class UnlitMaterial extends applyMaterialMixins(MeshMaterial, mixinVertexColor, mixinAlbedoColor) {
|
|
9
|
+
static FEATURE_VERTEX_COLOR = 'um_vertexcolor';
|
|
10
|
+
constructor(){
|
|
11
|
+
super();
|
|
12
|
+
}
|
|
13
|
+
vertexShader(scope, ctx) {
|
|
14
|
+
super.vertexShader(scope, ctx);
|
|
15
|
+
scope.$inputs.zPos = scope.$builder.vec3().attrib('position');
|
|
16
|
+
this.transformVertexAndNormal(scope);
|
|
17
|
+
}
|
|
18
|
+
fragmentShader(scope, ctx) {
|
|
19
|
+
super.fragmentShader(scope, ctx);
|
|
20
|
+
let color = this.calculateAlbedoColor(scope, ctx);
|
|
21
|
+
if (this.vertexColor) {
|
|
22
|
+
color = scope.$builder.mul(color, this.getVertexColor(scope, ctx));
|
|
23
|
+
}
|
|
24
|
+
this.outputFragmentColor(scope, this.needFragmentColor(ctx) ? color : null, ctx);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { UnlitMaterial };
|
|
29
|
+
//# sourceMappingURL=unlit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlit.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { Application } from '../app.js';
|
|
2
|
+
import { AbstractPostEffect } from './posteffect.js';
|
|
3
|
+
import { Vector4, Vector2 } from '@zephyr3d/base';
|
|
4
|
+
import '../scene/octree.js';
|
|
5
|
+
import '../material/material.js';
|
|
6
|
+
import '@zephyr3d/device';
|
|
7
|
+
import '../shaders/framework.js';
|
|
8
|
+
import '../render/scatteringlut.js';
|
|
9
|
+
import '../material/lambert.js';
|
|
10
|
+
import '../material/blinn.js';
|
|
11
|
+
import '../material/unlit.js';
|
|
12
|
+
import '../material/lightmodel.js';
|
|
13
|
+
import '../render/forward.js';
|
|
14
|
+
import '../render/sky.js';
|
|
15
|
+
import '../render/clipmap.js';
|
|
16
|
+
import { TemporalCache } from '../render/temporalcache.js';
|
|
17
|
+
import '../render/watermesh.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The bloom post effect
|
|
21
|
+
* @public
|
|
22
|
+
*/ class Bloom extends AbstractPostEffect {
|
|
23
|
+
static _nearestSampler = null;
|
|
24
|
+
static _programDownsampleH = null;
|
|
25
|
+
static _programDownsampleV = null;
|
|
26
|
+
static _programUpsample = null;
|
|
27
|
+
static _programFinalCompose = null;
|
|
28
|
+
static _programPrefilter = null;
|
|
29
|
+
static _renderStateAdditive = null;
|
|
30
|
+
_bindgroupDownsampleH;
|
|
31
|
+
_bindgroupDownsampleV;
|
|
32
|
+
_bindgroupUpsample;
|
|
33
|
+
_bindgroupFinalCompose;
|
|
34
|
+
_bindgroupPrefilter;
|
|
35
|
+
_thresholdValue;
|
|
36
|
+
_invTexSize;
|
|
37
|
+
_maxDownsampleLevels;
|
|
38
|
+
_downsampleLimit;
|
|
39
|
+
_threshold;
|
|
40
|
+
_thresholdKnee;
|
|
41
|
+
_intensity;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an instance of tonemap post effect
|
|
44
|
+
*/ constructor(){
|
|
45
|
+
super();
|
|
46
|
+
this._bindgroupDownsampleH = null;
|
|
47
|
+
this._bindgroupDownsampleV = null;
|
|
48
|
+
this._bindgroupUpsample = null;
|
|
49
|
+
this._bindgroupFinalCompose = null;
|
|
50
|
+
this._bindgroupPrefilter = null;
|
|
51
|
+
this._opaque = false;
|
|
52
|
+
this._thresholdValue = new Vector4();
|
|
53
|
+
this._invTexSize = new Vector2();
|
|
54
|
+
this._maxDownsampleLevels = 4;
|
|
55
|
+
this._downsampleLimit = 32;
|
|
56
|
+
this._threshold = 0.8;
|
|
57
|
+
this._thresholdKnee = 0;
|
|
58
|
+
this._intensity = 1;
|
|
59
|
+
}
|
|
60
|
+
/** The maximum downsample levels */ get maxDownsampleLevel() {
|
|
61
|
+
return this._maxDownsampleLevels;
|
|
62
|
+
}
|
|
63
|
+
set maxDownsampleLevel(val) {
|
|
64
|
+
this._maxDownsampleLevels = val;
|
|
65
|
+
}
|
|
66
|
+
/** Downsample resolution limitation */ get downsampleLimit() {
|
|
67
|
+
return this._downsampleLimit;
|
|
68
|
+
}
|
|
69
|
+
set downsampleLimit(val) {
|
|
70
|
+
this._downsampleLimit = val;
|
|
71
|
+
}
|
|
72
|
+
/** Bloom threshold */ get threshold() {
|
|
73
|
+
return this._threshold;
|
|
74
|
+
}
|
|
75
|
+
set threshold(val) {
|
|
76
|
+
this._threshold = val;
|
|
77
|
+
}
|
|
78
|
+
/** Bloom threshold knee */ get thresholdKnee() {
|
|
79
|
+
return this._thresholdKnee;
|
|
80
|
+
}
|
|
81
|
+
set thresholdKnee(val) {
|
|
82
|
+
this._thresholdKnee = val;
|
|
83
|
+
}
|
|
84
|
+
/** Bloom intensity */ get intensity() {
|
|
85
|
+
return this._intensity;
|
|
86
|
+
}
|
|
87
|
+
set intensity(val) {
|
|
88
|
+
this._intensity = val;
|
|
89
|
+
}
|
|
90
|
+
/** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */ requireLinearDepthTexture() {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
/** {@inheritDoc AbstractPostEffect.requireDepthAttachment} */ requireDepthAttachment() {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
/** {@inheritDoc AbstractPostEffect.apply} */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
|
|
97
|
+
const device = Application.instance.device;
|
|
98
|
+
const downsampleFramebuffers = [];
|
|
99
|
+
this._prepare(device, inputColorTexture);
|
|
100
|
+
device.pushDeviceStates();
|
|
101
|
+
const w = Math.max(inputColorTexture.width >> 1, 1);
|
|
102
|
+
const h = Math.max(inputColorTexture.height >> 1, 1);
|
|
103
|
+
const prefilterFramebuffer = TemporalCache.getFramebufferFixedSize(w, h, 1, inputColorTexture.format, null, '2d', null, false);
|
|
104
|
+
this.prefilter(device, inputColorTexture, prefilterFramebuffer);
|
|
105
|
+
this.downsample(device, prefilterFramebuffer.getColorAttachments()[0], downsampleFramebuffers);
|
|
106
|
+
this.upsample(device, downsampleFramebuffers);
|
|
107
|
+
device.popDeviceStates();
|
|
108
|
+
this.finalCompose(device, inputColorTexture, downsampleFramebuffers[0].getColorAttachments()[0]);
|
|
109
|
+
for (const fb of downsampleFramebuffers){
|
|
110
|
+
TemporalCache.releaseFramebuffer(fb);
|
|
111
|
+
}
|
|
112
|
+
TemporalCache.releaseFramebuffer(prefilterFramebuffer);
|
|
113
|
+
}
|
|
114
|
+
/** @internal */ prefilter(device, srcTexture, fb) {
|
|
115
|
+
this._thresholdValue.x = this._threshold * this._threshold;
|
|
116
|
+
this._thresholdValue.y = this._thresholdValue.x * this._thresholdKnee;
|
|
117
|
+
this._thresholdValue.z = 2 * this._thresholdValue.y;
|
|
118
|
+
this._thresholdValue.w = 0.25 / (this._thresholdValue.y + 0.00001);
|
|
119
|
+
this._thresholdValue.y -= this._thresholdValue.x;
|
|
120
|
+
device.setFramebuffer(fb);
|
|
121
|
+
device.setProgram(Bloom._programPrefilter);
|
|
122
|
+
device.setBindGroup(0, this._bindgroupPrefilter);
|
|
123
|
+
this._bindgroupPrefilter.setTexture('tex', srcTexture);
|
|
124
|
+
this._bindgroupPrefilter.setValue('flip', device.type === 'webgpu' ? 1 : 0);
|
|
125
|
+
this._bindgroupPrefilter.setValue('threshold', this._thresholdValue);
|
|
126
|
+
this.drawFullscreenQuad();
|
|
127
|
+
}
|
|
128
|
+
/** @internal */ finalCompose(device, srcTexture, bloomTexture) {
|
|
129
|
+
device.setProgram(Bloom._programFinalCompose);
|
|
130
|
+
device.setBindGroup(0, this._bindgroupFinalCompose);
|
|
131
|
+
this._bindgroupFinalCompose.setTexture('srcTex', srcTexture);
|
|
132
|
+
this._bindgroupFinalCompose.setTexture('bloomTex', bloomTexture);
|
|
133
|
+
this._bindgroupFinalCompose.setValue('intensity', this._intensity);
|
|
134
|
+
this._bindgroupFinalCompose.setValue('flip', device.type === 'webgpu' && device.getFramebuffer() ? 1 : 0);
|
|
135
|
+
this.drawFullscreenQuad();
|
|
136
|
+
}
|
|
137
|
+
/** @internal */ upsample(device, framebuffers) {
|
|
138
|
+
device.setProgram(Bloom._programUpsample);
|
|
139
|
+
device.setBindGroup(0, this._bindgroupUpsample);
|
|
140
|
+
this._bindgroupUpsample.setValue('flip', device.type === 'webgpu' ? 1 : 0);
|
|
141
|
+
for(let i = framebuffers.length - 2; i >= 0; i--){
|
|
142
|
+
this._bindgroupUpsample.setTexture('tex', framebuffers[i + 1].getColorAttachments()[0]);
|
|
143
|
+
device.setFramebuffer(framebuffers[i]);
|
|
144
|
+
this.drawFullscreenQuad(Bloom._renderStateAdditive);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** @internal */ downsample(device, inputColorTexture, framebuffers) {
|
|
148
|
+
const t = Math.max(2, this._downsampleLimit);
|
|
149
|
+
let w = Math.max(t, inputColorTexture.width >> 1);
|
|
150
|
+
let h = Math.max(t, inputColorTexture.height >> 1);
|
|
151
|
+
let maxLevels = Math.max(this._maxDownsampleLevels, 1);
|
|
152
|
+
let sourceTex = inputColorTexture;
|
|
153
|
+
this._bindgroupDownsampleH.setValue('flip', device.type === 'webgpu' ? 1 : 0);
|
|
154
|
+
this._bindgroupDownsampleV.setValue('flip', device.type === 'webgpu' ? 1 : 0);
|
|
155
|
+
while((w >= t || h >= t) && maxLevels > 0){
|
|
156
|
+
const fb = TemporalCache.getFramebufferFixedSize(w, h, 1, inputColorTexture.format, null, '2d', '2d', false);
|
|
157
|
+
const fbMiddle = TemporalCache.getFramebufferFixedSize(w, h, 1, inputColorTexture.format, null, '2d', '2d', false);
|
|
158
|
+
framebuffers.push(fb);
|
|
159
|
+
// horizonal blur
|
|
160
|
+
this._invTexSize.setXY(1 / sourceTex.width, 1 / sourceTex.height);
|
|
161
|
+
device.setFramebuffer(fbMiddle);
|
|
162
|
+
device.setProgram(Bloom._programDownsampleH);
|
|
163
|
+
device.setBindGroup(0, this._bindgroupDownsampleH);
|
|
164
|
+
this._bindgroupDownsampleH.setTexture('tex', sourceTex);
|
|
165
|
+
this._bindgroupDownsampleH.setValue('invTexSize', this._invTexSize);
|
|
166
|
+
this.drawFullscreenQuad();
|
|
167
|
+
// vertical blur
|
|
168
|
+
const midTex = fbMiddle.getColorAttachments()[0];
|
|
169
|
+
this._invTexSize.setXY(1 / midTex.width, 1 / midTex.height);
|
|
170
|
+
device.setFramebuffer(fb);
|
|
171
|
+
device.setProgram(Bloom._programDownsampleV);
|
|
172
|
+
device.setBindGroup(0, this._bindgroupDownsampleV);
|
|
173
|
+
this._bindgroupDownsampleV.setTexture('tex', midTex);
|
|
174
|
+
this._bindgroupDownsampleV.setValue('invTexSize', this._invTexSize);
|
|
175
|
+
this.drawFullscreenQuad();
|
|
176
|
+
maxLevels--;
|
|
177
|
+
w = Math.max(1, w >> 1);
|
|
178
|
+
h = Math.max(1, h >> 1);
|
|
179
|
+
sourceTex = fb.getColorAttachments()[0];
|
|
180
|
+
TemporalCache.releaseFramebuffer(fbMiddle);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** @internal */ _prepare(device, srcTexture) {
|
|
184
|
+
if (!Bloom._programFinalCompose) {
|
|
185
|
+
Bloom._programFinalCompose = device.buildRenderProgram({
|
|
186
|
+
vertex (pb) {
|
|
187
|
+
this.flip = pb.int().uniform(0);
|
|
188
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
189
|
+
this.$outputs.uv = pb.vec2();
|
|
190
|
+
pb.main(function() {
|
|
191
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
192
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
193
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
194
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
fragment (pb) {
|
|
199
|
+
this.srcTex = pb.tex2D().uniform(0);
|
|
200
|
+
this.bloomTex = pb.tex2D().uniform(0);
|
|
201
|
+
this.intensity = pb.float().uniform(0);
|
|
202
|
+
this.$outputs.outColor = pb.vec4();
|
|
203
|
+
pb.main(function() {
|
|
204
|
+
this.$l.srcSample = pb.textureSampleLevel(this.srcTex, this.$inputs.uv, 0);
|
|
205
|
+
this.$l.bloomSample = pb.textureSampleLevel(this.bloomTex, this.$inputs.uv, 0);
|
|
206
|
+
this.$outputs.outColor = pb.vec4(pb.add(this.srcSample.rgb, pb.mul(this.bloomSample.rgb, this.intensity)), 1);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (!this._bindgroupFinalCompose) {
|
|
212
|
+
this._bindgroupFinalCompose = device.createBindGroup(Bloom._programFinalCompose.bindGroupLayouts[0]);
|
|
213
|
+
}
|
|
214
|
+
if (!Bloom._programPrefilter) {
|
|
215
|
+
Bloom._programPrefilter = device.buildRenderProgram({
|
|
216
|
+
vertex (pb) {
|
|
217
|
+
this.flip = pb.int().uniform(0);
|
|
218
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
219
|
+
this.$outputs.uv = pb.vec2();
|
|
220
|
+
pb.main(function() {
|
|
221
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
222
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
223
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
224
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
fragment (pb) {
|
|
229
|
+
this.tex = pb.tex2D().uniform(0);
|
|
230
|
+
this.threshold = pb.vec4().uniform(0);
|
|
231
|
+
this.$outputs.outColor = pb.vec4();
|
|
232
|
+
pb.main(function() {
|
|
233
|
+
this.$l.p = pb.textureSampleLevel(this.tex, this.$inputs.uv, 0);
|
|
234
|
+
this.$l.brightness = pb.max(pb.max(this.p.r, this.p.g), this.p.b);
|
|
235
|
+
this.$l.soft = pb.clamp(pb.add(this.brightness, this.threshold.y), 0, this.threshold.z);
|
|
236
|
+
this.soft = pb.mul(this.soft, this.soft, this.threshold.w);
|
|
237
|
+
this.$l.contrib = pb.div(pb.max(this.soft, pb.sub(this.brightness, this.threshold.x)), pb.max(this.brightness, 0.00001));
|
|
238
|
+
this.$outputs.outColor = pb.vec4(pb.mul(this.p.rgb, this.contrib), 1);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (!this._bindgroupPrefilter) {
|
|
244
|
+
this._bindgroupPrefilter = device.createBindGroup(Bloom._programPrefilter.bindGroupLayouts[0]);
|
|
245
|
+
}
|
|
246
|
+
if (!Bloom._programUpsample) {
|
|
247
|
+
Bloom._programUpsample = device.buildRenderProgram({
|
|
248
|
+
vertex (pb) {
|
|
249
|
+
this.flip = pb.int().uniform(0);
|
|
250
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
251
|
+
this.$outputs.uv = pb.vec2();
|
|
252
|
+
pb.main(function() {
|
|
253
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
254
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
255
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
256
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
fragment (pb) {
|
|
261
|
+
this.tex = pb.tex2D().uniform(0);
|
|
262
|
+
this.$outputs.outColor = pb.vec4();
|
|
263
|
+
pb.main(function() {
|
|
264
|
+
this.$outputs.outColor = pb.textureSampleLevel(this.tex, this.$inputs.uv, 0);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (!this._bindgroupUpsample) {
|
|
270
|
+
this._bindgroupUpsample = device.createBindGroup(Bloom._programUpsample.bindGroupLayouts[0]);
|
|
271
|
+
}
|
|
272
|
+
if (!Bloom._programDownsampleH) {
|
|
273
|
+
const offsets = [
|
|
274
|
+
-4,
|
|
275
|
+
-3,
|
|
276
|
+
-2,
|
|
277
|
+
-1,
|
|
278
|
+
0,
|
|
279
|
+
1,
|
|
280
|
+
2,
|
|
281
|
+
3,
|
|
282
|
+
4
|
|
283
|
+
];
|
|
284
|
+
const weights = [
|
|
285
|
+
0.01621622,
|
|
286
|
+
0.05405405,
|
|
287
|
+
0.12162162,
|
|
288
|
+
0.19459459,
|
|
289
|
+
0.22702703,
|
|
290
|
+
0.19459459,
|
|
291
|
+
0.12162162,
|
|
292
|
+
0.05405405,
|
|
293
|
+
0.01621622
|
|
294
|
+
];
|
|
295
|
+
Bloom._programDownsampleH = device.buildRenderProgram({
|
|
296
|
+
vertex (pb) {
|
|
297
|
+
this.flip = pb.int().uniform(0);
|
|
298
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
299
|
+
this.$outputs.uv = pb.vec2();
|
|
300
|
+
pb.main(function() {
|
|
301
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
302
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
303
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
304
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
fragment (pb) {
|
|
309
|
+
this.invTexSize = pb.vec2().uniform(0);
|
|
310
|
+
this.tex = pb.tex2D().uniform(0);
|
|
311
|
+
this.$outputs.outColor = pb.vec4();
|
|
312
|
+
pb.main(function() {
|
|
313
|
+
this.$l.sum = pb.vec3(0);
|
|
314
|
+
this.$l.offset = pb.float();
|
|
315
|
+
for(let i = 0; i < 9; i++){
|
|
316
|
+
this.offset = pb.mul(this.invTexSize.x, offsets[i] * 2);
|
|
317
|
+
this.sum = pb.add(this.sum, pb.mul(pb.textureSampleLevel(this.tex, pb.add(this.$inputs.uv, pb.vec2(this.offset, 0)), 0).rgb, weights[i]));
|
|
318
|
+
}
|
|
319
|
+
this.$outputs.outColor = pb.vec4(this.sum, 1);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (!this._bindgroupDownsampleH) {
|
|
325
|
+
this._bindgroupDownsampleH = device.createBindGroup(Bloom._programDownsampleH.bindGroupLayouts[0]);
|
|
326
|
+
}
|
|
327
|
+
if (!Bloom._programDownsampleV) {
|
|
328
|
+
const offsets = [
|
|
329
|
+
-3.23076923,
|
|
330
|
+
-1.38461538,
|
|
331
|
+
0.0,
|
|
332
|
+
1.38461538,
|
|
333
|
+
3.23076923
|
|
334
|
+
];
|
|
335
|
+
const weights = [
|
|
336
|
+
0.07027027,
|
|
337
|
+
0.31621622,
|
|
338
|
+
0.22702703,
|
|
339
|
+
0.31621622,
|
|
340
|
+
0.07027027
|
|
341
|
+
];
|
|
342
|
+
Bloom._programDownsampleV = device.buildRenderProgram({
|
|
343
|
+
vertex (pb) {
|
|
344
|
+
this.flip = pb.int().uniform(0);
|
|
345
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
346
|
+
this.$outputs.uv = pb.vec2();
|
|
347
|
+
pb.main(function() {
|
|
348
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
349
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
350
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
351
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
},
|
|
355
|
+
fragment (pb) {
|
|
356
|
+
this.invTexSize = pb.vec2().uniform(0);
|
|
357
|
+
this.tex = pb.tex2D().uniform(0);
|
|
358
|
+
this.$outputs.outColor = pb.vec4();
|
|
359
|
+
pb.main(function() {
|
|
360
|
+
this.$l.sum = pb.vec3(0);
|
|
361
|
+
this.$l.offset = pb.float();
|
|
362
|
+
for(let i = 0; i < 5; i++){
|
|
363
|
+
this.offset = pb.mul(this.invTexSize.y, offsets[i]);
|
|
364
|
+
this.sum = pb.add(this.sum, pb.mul(pb.textureSampleLevel(this.tex, pb.add(this.$inputs.uv, pb.vec2(0, this.offset)), 0).rgb, weights[i]));
|
|
365
|
+
}
|
|
366
|
+
this.$outputs.outColor = pb.vec4(this.sum, 1);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
if (!this._bindgroupDownsampleV) {
|
|
372
|
+
this._bindgroupDownsampleV = device.createBindGroup(Bloom._programDownsampleV.bindGroupLayouts[0]);
|
|
373
|
+
}
|
|
374
|
+
if (!Bloom._nearestSampler) {
|
|
375
|
+
Bloom._nearestSampler = device.createSampler({
|
|
376
|
+
magFilter: 'nearest',
|
|
377
|
+
minFilter: 'nearest',
|
|
378
|
+
mipFilter: 'none',
|
|
379
|
+
addressU: 'clamp',
|
|
380
|
+
addressV: 'clamp'
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
if (!Bloom._renderStateAdditive) {
|
|
384
|
+
Bloom._renderStateAdditive = device.createRenderStateSet();
|
|
385
|
+
Bloom._renderStateAdditive.useRasterizerState().setCullMode('none');
|
|
386
|
+
Bloom._renderStateAdditive.useDepthState().enableTest(false).enableWrite(false);
|
|
387
|
+
Bloom._renderStateAdditive.useBlendingState().enable(true).setBlendFuncRGB('one', 'one').setBlendFuncAlpha('one', 'zero');
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/** {@inheritDoc AbstractPostEffect.dispose} */ dispose() {
|
|
391
|
+
super.dispose();
|
|
392
|
+
this._bindgroupDownsampleH?.dispose();
|
|
393
|
+
this._bindgroupDownsampleH = null;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export { Bloom };
|
|
398
|
+
//# sourceMappingURL=bloom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bloom.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|