@woosh/meep-engine 2.33.36 → 2.33.40
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/core/bvh2/binary/2/BinaryUint32BVH.js +3 -3
- package/core/collection/HashMap.js +19 -12
- package/core/collection/array/typed/typed_array_copy.js +2 -2
- package/core/collection/table/RowFirstTable.js +13 -8
- package/core/collection/table/RowFirstTableSpec.js +6 -0
- package/core/color/Color.js +5 -9
- package/core/color/ColorUtils.js +4 -150
- package/core/color/YCbCr_to_rgb_uint24.js +20 -0
- package/core/color/hsv2rgb.js +54 -0
- package/core/color/int2rgb.js +12 -0
- package/core/color/parseHex.js +18 -0
- package/core/color/rgb2hex.js +16 -0
- package/core/color/rgb2hsv.js +47 -0
- package/core/color/rgb2uint24.js +17 -0
- package/core/color/rgb_to_YCbCr_uint24.js +18 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +1 -1
- package/core/geom/3d/aabb/compute_aabb_from_points.js +28 -0
- package/core/geom/3d/morton/mortonEncode_magicbits.js +7 -6
- package/core/geom/3d/morton/v3_morton_encode_transformed.js +15 -11
- package/core/geom/3d/plane/orient3d_fast.js +51 -0
- package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +5 -0
- package/core/geom/3d/tetrahedra/GetDepthForTetrahedronProbe.glsl +43 -0
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +177 -0
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +66 -0
- package/core/geom/3d/tetrahedra/compute_circumsphere.js +271 -0
- package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.js +50 -0
- package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.spec.js +14 -0
- package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +77 -0
- package/core/geom/3d/tetrahedra/tetrahedra_collection.js +454 -0
- package/core/geom/3d/tetrahedra/tetrahedron_contains_point.js +26 -0
- package/core/geom/Quaternion.js +4 -0
- package/core/math/hash/murmur3_32.js +39 -0
- package/core/process/undo/ActionProcessor.d.ts +2 -0
- package/core/process/undo/ActionProcessor.js +15 -4
- package/editor/tools/FoliagePaintTool.js +1 -1
- package/editor/tools/GridPaintTool.js +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +4 -8
- package/engine/ecs/System.d.ts +24 -1
- package/engine/ecs/foliage/InstancedFoliage.js +45 -0
- package/engine/ecs/foliage/ecs/InstancedMeshLayer.js +4 -0
- package/engine/ecs/storage/BinaryBufferSerializer.js +48 -38
- package/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +1 -1
- package/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
- package/engine/graphics/GraphicsEngine.js +7 -0
- package/engine/graphics/ecs/light/binding/fp/FPLightBinding.js +1 -1
- package/engine/graphics/ecs/mesh/Mesh.js +2 -2
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +13 -0
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +339 -314
- package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -1
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +6 -2
- package/engine/graphics/particles/node-based/rendering/billboard/ParticleBillboardShader.js +1 -1
- package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +20 -24
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +100 -55
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +7 -2
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +1 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -2
- package/engine/graphics/render/buffer/simple-fx/DepthLimitedBlur.js +9 -4
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +7 -1
- package/engine/graphics/render/forward_plus/LightManager.js +295 -51
- package/engine/graphics/render/forward_plus/LightManager.spec.js +1 -1
- package/engine/graphics/render/forward_plus/PointLightData.js +9 -13
- package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +1 -1
- package/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +10 -1
- package/engine/graphics/render/forward_plus/debug/LightClusterVolumeMaterial.js +1 -1
- package/engine/graphics/render/forward_plus/debug/buildLightClusterWidget.js +3 -1
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +31 -18
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +18 -4
- package/engine/graphics/render/forward_plus/model/AbstractLight.js +50 -0
- package/engine/graphics/render/forward_plus/model/Decal.js +68 -0
- package/engine/graphics/render/forward_plus/{PointLight.js → model/PointLight.js} +19 -11
- package/engine/graphics/render/forward_plus/{SpotLight.js → model/SpotLight.js} +20 -12
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +6 -5
- package/engine/graphics/render/forward_plus/{prototypeLightManager.js → prototype/prototypeLightManager.js} +100 -25
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +29 -20
- package/engine/graphics/render/visibility/IncrementalDeltaSet.d.ts +2 -0
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +1 -0
- package/engine/graphics/render/visibility/VisibilityComputer.js +8 -7
- package/engine/graphics/shaders/TerrainShader.js +5 -5
- package/engine/graphics/shadows/testShadowMapRendering.js +192 -0
- package/engine/graphics/texture/atlas/AbstractTextureAtlas.js +19 -0
- package/engine/graphics/texture/atlas/CachingTextureAtlas.js +99 -0
- package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +19 -39
- package/engine/graphics/texture/atlas/ReferencedTextureAtlas.js +75 -0
- package/engine/graphics/texture/atlas/TextureAtlas.js +22 -2
- package/engine/reference/v2/Reference.d.ts +4 -0
- package/engine/reference/v2/Reference.js +3 -1
- package/package.json +2 -1
- package/view/elements/ColorPickerView.js +2 -1
|
@@ -456,7 +456,7 @@ function init() {
|
|
|
456
456
|
|
|
457
457
|
// sample_gltf_sponza();
|
|
458
458
|
// sample_gltf_rts_factory();
|
|
459
|
-
sample_lucy();
|
|
459
|
+
// sample_lucy();
|
|
460
460
|
// sample_gltf_hapro_2();
|
|
461
461
|
// sample_gltf_hapro_1();
|
|
462
462
|
// sample_gltf_broken_isiflow();
|
|
@@ -465,6 +465,9 @@ function init() {
|
|
|
465
465
|
// gltf_sample('data/models/moicon/08-clickable-assets/model.gltf');
|
|
466
466
|
// gltf_sample('data/models/moicon/05-ground-floor/model.gltf');
|
|
467
467
|
// gltf_sample('data/models/moicon/isiflow_Oct_15_21/0/model.gltf');
|
|
468
|
+
// gltf_sample('moicon/29_Dec_2021_Nammo/1/model.gltf');
|
|
469
|
+
// gltf_sample('moicon/29_Dec_2021_Nammo/1-onematerial/model.gltf');
|
|
470
|
+
gltf_sample('moicon/29_Dec_2021_Nammo/2/model.gltf');
|
|
468
471
|
|
|
469
472
|
document.addEventListener("mousemove", onDocumentMouseMove);
|
|
470
473
|
|
|
@@ -122,6 +122,7 @@ export class VGThreeRenderer {
|
|
|
122
122
|
// clear contexts
|
|
123
123
|
const contexts = this.__contexts_array;
|
|
124
124
|
const context_count = contexts.length;
|
|
125
|
+
|
|
125
126
|
for (let i = 0; i < context_count; i++) {
|
|
126
127
|
const ctx = contexts[i];
|
|
127
128
|
|
|
@@ -142,8 +143,11 @@ export class VGThreeRenderer {
|
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
const inputs = this.__inputs;
|
|
147
|
+
const input_count = inputs.length;
|
|
148
|
+
|
|
149
|
+
for (let i = 0; i < input_count; i++) {
|
|
150
|
+
const input_object = inputs[i];
|
|
147
151
|
|
|
148
152
|
input_object.traverse(processObject);
|
|
149
153
|
}
|
|
@@ -2,7 +2,6 @@ import { inverseLerp } from "../../../../../../core/math/inverseLerp.js";
|
|
|
2
2
|
import { assert } from "../../../../../../core/assert.js";
|
|
3
3
|
import { max2 } from "../../../../../../core/math/max2.js";
|
|
4
4
|
import { min2 } from "../../../../../../core/math/min2.js";
|
|
5
|
-
import { mix } from "../../../../../../core/math/mix.js";
|
|
6
5
|
import { ParameterLookupTableFlags } from "./ParameterLookupTableFlags.js";
|
|
7
6
|
import { ParameterLookupTableSerializationAdapter } from "../emitter/serde/ParameterLookupTableSerializationAdapter.js";
|
|
8
7
|
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
@@ -125,7 +124,7 @@ export class ParameterLookupTable {
|
|
|
125
124
|
*/
|
|
126
125
|
sample(position, result) {
|
|
127
126
|
assert.isNumber(position, 'position');
|
|
128
|
-
assert.greaterThanOrEqual(position, 0, 'position');
|
|
127
|
+
// assert.greaterThanOrEqual(position, 0, 'position');
|
|
129
128
|
// assert.ok(position >= 0 && position <= 1, `position must be between 0 and 1, instead was ${position}`);
|
|
130
129
|
|
|
131
130
|
const itemSize = this.itemSize;
|
|
@@ -140,32 +139,28 @@ export class ParameterLookupTable {
|
|
|
140
139
|
let highIndex = lowIndex;
|
|
141
140
|
let fraction = 0;
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
for (i = 0; i < numValues; i++) {
|
|
145
|
-
//NOTE: no complex search is used, since for small data sizes linear scan is typically faster
|
|
146
|
-
const p = positions[i];
|
|
142
|
+
if (position <= positions[0]) {
|
|
147
143
|
|
|
148
|
-
|
|
144
|
+
// special case, seek position is at or before the start of the table
|
|
145
|
+
lowIndex = 0;
|
|
146
|
+
highIndex = 0;
|
|
149
147
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
} else {
|
|
149
|
+
|
|
150
|
+
//find position index
|
|
151
|
+
for (i = 1; i < numValues; i++) {
|
|
152
|
+
//NOTE: no complex search is used, since for small data sizes linear scan is typically faster
|
|
153
|
+
const p = positions[i];
|
|
155
154
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (i === 0) {
|
|
160
|
-
lowIndex = i;
|
|
161
|
-
fraction = 0;
|
|
162
|
-
} else {
|
|
155
|
+
if (p >= position) {
|
|
156
|
+
// next position if over the seek position
|
|
157
|
+
highIndex = i;
|
|
163
158
|
lowIndex = i - 1;
|
|
164
|
-
const prevPosition = positions[lowIndex];
|
|
165
|
-
fraction = inverseLerp(prevPosition, p, position);
|
|
166
|
-
}
|
|
167
159
|
|
|
168
|
-
|
|
160
|
+
fraction = inverseLerp(positions[lowIndex], p, position);
|
|
161
|
+
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
169
164
|
}
|
|
170
165
|
}
|
|
171
166
|
|
|
@@ -177,7 +172,8 @@ export class ParameterLookupTable {
|
|
|
177
172
|
const lowValue = data[low_offset + i];
|
|
178
173
|
const highValue = data[high_offset + i];
|
|
179
174
|
|
|
180
|
-
|
|
175
|
+
// inlined for speed: mix(low, high, fraction)
|
|
176
|
+
const value = lowValue * (1 - fraction) + highValue * fraction;
|
|
181
177
|
|
|
182
178
|
result[i] = value;
|
|
183
179
|
}
|
package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js
CHANGED
|
@@ -17,9 +17,9 @@ const CHUNK_LAMBERT_LIGHTING = `
|
|
|
17
17
|
vec3 diffuse = vec3( 1.0 );
|
|
18
18
|
|
|
19
19
|
GeometricContext geometry;
|
|
20
|
-
geometry.position =
|
|
20
|
+
geometry.position = -vViewPosition;
|
|
21
21
|
geometry.normal = normalize( transformedNormal );
|
|
22
|
-
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -
|
|
22
|
+
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -vViewPosition.xyz );
|
|
23
23
|
|
|
24
24
|
GeometricContext backGeometry;
|
|
25
25
|
backGeometry.position = geometry.position;
|
|
@@ -156,28 +156,11 @@ function make_vertex_shader() {
|
|
|
156
156
|
varying vec2 vRotationMultiplier;
|
|
157
157
|
varying float vBlending;
|
|
158
158
|
|
|
159
|
-
|
|
160
159
|
#if defined(LIGHTS_ENABLED)
|
|
161
|
-
|
|
162
|
-
#include <bsdfs>
|
|
163
|
-
#include <lights_pars_begin>
|
|
164
|
-
|
|
165
|
-
struct LambertMaterial {
|
|
166
|
-
vec3 diffuseColor;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
170
|
-
vec3 irradiance = directLight.color;
|
|
171
|
-
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
175
|
-
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
#define RE_Direct RE_Direct_Lambert
|
|
179
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert
|
|
160
|
+
varying vec3 vViewPosition;
|
|
180
161
|
#endif
|
|
162
|
+
|
|
163
|
+
|
|
181
164
|
|
|
182
165
|
void main() {
|
|
183
166
|
|
|
@@ -194,10 +177,11 @@ function make_vertex_shader() {
|
|
|
194
177
|
|
|
195
178
|
#if defined(LIGHTS_ENABLED)
|
|
196
179
|
vec4 mvPosition = modelViewMatrix * position4;
|
|
197
|
-
|
|
180
|
+
vViewPosition = -mvPosition.xyz;
|
|
198
181
|
|
|
199
182
|
vec3 transformedNormal = vec3(0.0,0.0,1.0);
|
|
200
|
-
|
|
183
|
+
|
|
184
|
+
#include <worldpos_vertex>
|
|
201
185
|
#endif
|
|
202
186
|
|
|
203
187
|
gl_Position = modelViewProjectionMatrix * position4;
|
|
@@ -222,7 +206,6 @@ function make_vertex_shader() {
|
|
|
222
206
|
|
|
223
207
|
}
|
|
224
208
|
#endif
|
|
225
|
-
//
|
|
226
209
|
|
|
227
210
|
vRotationMultiplier = vec2( cos(rotationGlobal),sin(rotationGlobal) );
|
|
228
211
|
|
|
@@ -238,30 +221,6 @@ function make_vertex_shader() {
|
|
|
238
221
|
|
|
239
222
|
gl_PointSize = projected_radius;
|
|
240
223
|
|
|
241
|
-
#if defined(LIGHTS_ENABLED)
|
|
242
|
-
vec3 vLightFront;
|
|
243
|
-
vec3 vIndirectFront;
|
|
244
|
-
|
|
245
|
-
#include <worldpos_vertex>
|
|
246
|
-
${CHUNK_LAMBERT_LIGHTING}
|
|
247
|
-
|
|
248
|
-
LambertMaterial material = LambertMaterial(vColor.rgb);
|
|
249
|
-
|
|
250
|
-
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
251
|
-
vec3 totalEmissiveRadiance = vec3(0.0);
|
|
252
|
-
|
|
253
|
-
reflectedLight.indirectDiffuse += vIndirectFront;
|
|
254
|
-
reflectedLight.indirectDiffuse *= BRDF_Lambert( vColor.rgb );
|
|
255
|
-
|
|
256
|
-
reflectedLight.directDiffuse = vLightFront;
|
|
257
|
-
reflectedLight.directDiffuse *= BRDF_Lambert( vColor.rgb ); // shadowmask goes here
|
|
258
|
-
|
|
259
|
-
//@injection_point FORWARD_PLUS:accumulation
|
|
260
|
-
|
|
261
|
-
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
262
|
-
|
|
263
|
-
vColor.rgb = outgoingLight;
|
|
264
|
-
#endif
|
|
265
224
|
|
|
266
225
|
}`;
|
|
267
226
|
}
|
|
@@ -276,6 +235,10 @@ function make_fragment_shader() {
|
|
|
276
235
|
uniform float cameraFar;
|
|
277
236
|
uniform mat4 modelViewMatrix;
|
|
278
237
|
uniform mat4 projectionMatrix;
|
|
238
|
+
|
|
239
|
+
uniform mat4 uProjectionInverse;
|
|
240
|
+
uniform mat4 uViewInverse;
|
|
241
|
+
|
|
279
242
|
uniform vec2 resolution;
|
|
280
243
|
|
|
281
244
|
varying float vFadeDistance;
|
|
@@ -285,7 +248,6 @@ function make_fragment_shader() {
|
|
|
285
248
|
varying vec2 vRotationMultiplier;
|
|
286
249
|
varying float vBlending;
|
|
287
250
|
|
|
288
|
-
|
|
289
251
|
out highp vec4 pc_fragColor;
|
|
290
252
|
|
|
291
253
|
float depthToLinear( float z ) {
|
|
@@ -334,6 +296,58 @@ function make_fragment_shader() {
|
|
|
334
296
|
return zFade;
|
|
335
297
|
}
|
|
336
298
|
|
|
299
|
+
|
|
300
|
+
#if defined(LIGHTS_ENABLED)
|
|
301
|
+
|
|
302
|
+
vec3 computeWorldPositionFromFragmentPosition(vec3 coord){
|
|
303
|
+
vec4 ndc = vec4(
|
|
304
|
+
(coord.x - 0.5) * 2.0,
|
|
305
|
+
(coord.y - 0.5) * 2.0,
|
|
306
|
+
(coord.z - 0.5) * 2.0,
|
|
307
|
+
1.0);
|
|
308
|
+
|
|
309
|
+
vec4 clip = uProjectionInverse * ndc;
|
|
310
|
+
return (uViewInverse* (clip / clip.w) ).xyz;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
vec3 construct_spherical_normal_from_point_coord(vec2 coord){
|
|
314
|
+
float x = coord.x * 2.0 - 1.0;
|
|
315
|
+
float y = coord.y * 2.0 - 1.0; // note we flip Y
|
|
316
|
+
|
|
317
|
+
float z = sqrt(1.0 - clamp(x*x + y*y, 0.0, 1.0));
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
vec3 position = vec3(x, -y, z);
|
|
321
|
+
|
|
322
|
+
vec3 normal = normalize(position);
|
|
323
|
+
|
|
324
|
+
return normal;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
#include <common>
|
|
328
|
+
#include <bsdfs>
|
|
329
|
+
#include <lights_pars_begin>
|
|
330
|
+
|
|
331
|
+
struct LambertMaterial {
|
|
332
|
+
vec3 diffuseColor;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
336
|
+
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
337
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
338
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
342
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
#define RE_Direct RE_Direct_Lambert
|
|
346
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert
|
|
347
|
+
|
|
348
|
+
varying vec3 vViewPosition;
|
|
349
|
+
#endif
|
|
350
|
+
|
|
337
351
|
void main() {
|
|
338
352
|
float fragmentDepth = gl_FragCoord.z;
|
|
339
353
|
|
|
@@ -365,6 +379,37 @@ function make_fragment_shader() {
|
|
|
365
379
|
|
|
366
380
|
vec4 texel = spriteColor * vColor;
|
|
367
381
|
|
|
382
|
+
#if defined(LIGHTS_ENABLED)
|
|
383
|
+
// compute world position
|
|
384
|
+
vec3 v_world_position = computeWorldPositionFromFragmentPosition(gl_FragCoord.xyz);
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
vec3 vLightFront;
|
|
388
|
+
vec3 vIndirectFront;
|
|
389
|
+
|
|
390
|
+
vec3 transformedNormal = construct_spherical_normal_from_point_coord(gl_PointCoord.xy);
|
|
391
|
+
|
|
392
|
+
${CHUNK_LAMBERT_LIGHTING}
|
|
393
|
+
|
|
394
|
+
LambertMaterial material = LambertMaterial(texel.rgb);
|
|
395
|
+
|
|
396
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
397
|
+
vec3 totalEmissiveRadiance = vec3(0.0);
|
|
398
|
+
|
|
399
|
+
reflectedLight.indirectDiffuse += vIndirectFront;
|
|
400
|
+
reflectedLight.indirectDiffuse *= BRDF_Lambert( texel.rgb );
|
|
401
|
+
|
|
402
|
+
reflectedLight.directDiffuse = vLightFront;
|
|
403
|
+
reflectedLight.directDiffuse *= BRDF_Lambert( texel.rgb ); // shadowmask goes here
|
|
404
|
+
|
|
405
|
+
//@injection_point FORWARD_PLUS:accumulation
|
|
406
|
+
|
|
407
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
408
|
+
|
|
409
|
+
texel.rgb = outgoingLight;
|
|
410
|
+
#endif
|
|
411
|
+
|
|
412
|
+
|
|
368
413
|
// premultiply alpha
|
|
369
414
|
texel.xyz *= texel.a;
|
|
370
415
|
|
|
@@ -379,9 +424,8 @@ function make_fragment_shader() {
|
|
|
379
424
|
texel *= zFade;
|
|
380
425
|
|
|
381
426
|
#endif
|
|
382
|
-
|
|
383
|
-
pc_fragColor = texel;
|
|
384
427
|
|
|
428
|
+
pc_fragColor = texel;
|
|
385
429
|
}`;
|
|
386
430
|
}
|
|
387
431
|
|
|
@@ -426,7 +470,9 @@ export function make_particle_billboard_shader({ lights = false } = {}) {
|
|
|
426
470
|
resolution: {
|
|
427
471
|
type: 'v2',
|
|
428
472
|
value: new ThreeVector2()
|
|
429
|
-
}
|
|
473
|
+
},
|
|
474
|
+
uViewInverse: { type: 'm4', value: new Matrix4() },
|
|
475
|
+
uProjectionInverse: { type: 'm4', value: new Matrix4() },
|
|
430
476
|
};
|
|
431
477
|
|
|
432
478
|
if (lights) {
|
|
@@ -439,8 +485,7 @@ export function make_particle_billboard_shader({ lights = false } = {}) {
|
|
|
439
485
|
DEPTH_READ_ENABLED: true,
|
|
440
486
|
DEPTH_SOFT_ENABLED: true,
|
|
441
487
|
ALIGN_DIRECTION_ENABLED: false,
|
|
442
|
-
LIGHTS_ENABLED: lights
|
|
443
|
-
LIGHTING_VERTEX_ONLY: true
|
|
488
|
+
LIGHTS_ENABLED: lights
|
|
444
489
|
},
|
|
445
490
|
uniforms: uniforms,
|
|
446
491
|
vertexShader: make_vertex_shader(),
|
|
@@ -117,7 +117,7 @@ export class ShaderManager {
|
|
|
117
117
|
generateMipmaps: true,
|
|
118
118
|
minFilter: LinearMipMapLinearFilter,
|
|
119
119
|
magFilter: LinearFilter,
|
|
120
|
-
anisotropy: 0
|
|
120
|
+
anisotropy: 0 // sprites are always facing the screen, anisotropic filtering would be pointless
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
this.spriteTexture.name = 'Sprite sheet';
|
|
@@ -189,7 +189,9 @@ export class ShaderManager {
|
|
|
189
189
|
},
|
|
190
190
|
cameraFar: {
|
|
191
191
|
value: 0
|
|
192
|
-
}
|
|
192
|
+
},
|
|
193
|
+
uViewInverse: { type: 'm4', value: new Matrix4() },
|
|
194
|
+
uProjectionInverse: { type: 'm4', value: new Matrix4() },
|
|
193
195
|
};
|
|
194
196
|
|
|
195
197
|
// debugAtlas(this.spriteAtlas.atlas, { scale: new Vector2(1, 1) });
|
|
@@ -396,6 +398,9 @@ export class ShaderManager {
|
|
|
396
398
|
uniforms.modelViewMatrix.value = modelViewMatrix;
|
|
397
399
|
uniforms.cameraNear.value = cameraNear;
|
|
398
400
|
uniforms.cameraFar.value = cameraFar;
|
|
401
|
+
|
|
402
|
+
uniforms.uProjectionInverse.value.copy(camera.projectionMatrixInverse);
|
|
403
|
+
uniforms.uViewInverse.value.copy(camera.matrixWorld);
|
|
399
404
|
}
|
|
400
405
|
|
|
401
406
|
/**
|
|
@@ -609,8 +609,8 @@ async function main(engine) {
|
|
|
609
609
|
|
|
610
610
|
engine.graphics.renderer.setClearColor('rgba(99,99,99,1)');
|
|
611
611
|
|
|
612
|
-
|
|
613
|
-
await sample_scene_0(engine);
|
|
612
|
+
await sample_scene_nam(engine);
|
|
613
|
+
// await sample_scene_0(engine);
|
|
614
614
|
}
|
|
615
615
|
|
|
616
616
|
/**
|
|
@@ -26,14 +26,16 @@ export class DepthLimitedBlur {
|
|
|
26
26
|
uniforms: UniformsUtils.clone(DepthLimitedBlurShader.uniforms),
|
|
27
27
|
defines: Object.assign({}, DepthLimitedBlurShader.defines),
|
|
28
28
|
vertexShader: DepthLimitedBlurShader.vertexShader,
|
|
29
|
-
fragmentShader: DepthLimitedBlurShader.fragmentShader
|
|
29
|
+
fragmentShader: DepthLimitedBlurShader.fragmentShader,
|
|
30
|
+
blending: NoBlending
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
this.__material_blur_y = new ShaderMaterial({
|
|
33
34
|
uniforms: UniformsUtils.clone(DepthLimitedBlurShader.uniforms),
|
|
34
35
|
defines: Object.assign({}, DepthLimitedBlurShader.defines),
|
|
35
36
|
vertexShader: DepthLimitedBlurShader.vertexShader,
|
|
36
|
-
fragmentShader: DepthLimitedBlurShader.fragmentShader
|
|
37
|
+
fragmentShader: DepthLimitedBlurShader.fragmentShader,
|
|
38
|
+
blending: NoBlending
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
|
|
@@ -97,7 +99,10 @@ export class DepthLimitedBlur {
|
|
|
97
99
|
*/
|
|
98
100
|
execute(renderer) {
|
|
99
101
|
// update intermediate buffer size based on input size
|
|
100
|
-
if (
|
|
102
|
+
if (
|
|
103
|
+
this.__intermediate.width !== this.__rt_output.width
|
|
104
|
+
|| this.__intermediate.height !== this.__rt_output.height
|
|
105
|
+
) {
|
|
101
106
|
this.__intermediate.setSize(this.__rt_output.width, this.__rt_output.height);
|
|
102
107
|
}
|
|
103
108
|
|
|
@@ -118,7 +123,7 @@ export class DepthLimitedBlur {
|
|
|
118
123
|
|
|
119
124
|
renderer.setRenderTarget(this.__rt_output);
|
|
120
125
|
renderer.clearColor();
|
|
121
|
-
|
|
126
|
+
|
|
122
127
|
renderScreenSpace(renderer, my);
|
|
123
128
|
|
|
124
129
|
// restore state
|
|
@@ -286,7 +286,13 @@ export class AmbientOcclusionPostProcessEffect extends EnginePlugin {
|
|
|
286
286
|
|
|
287
287
|
const size = graphics.viewport.size;
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
const target_resolution_x = Math.ceil(size.x * this.__resolution_scale);
|
|
290
|
+
const target_resolution_y = Math.ceil(size.y * this.__resolution_scale);
|
|
291
|
+
|
|
292
|
+
this.__render_target.setSize(
|
|
293
|
+
target_resolution_x,
|
|
294
|
+
target_resolution_y
|
|
295
|
+
);
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
async startup() {
|