babylon.quarks 0.17.4 → 0.17.7
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/CHANGELOG.md +103 -0
- package/LICENSE +21 -21
- package/README.md +169 -33
- package/dist/babylon.quarks.cjs +1 -1
- package/dist/babylon.quarks.cjs.map +1 -1
- package/dist/babylon.quarks.esm.js +1 -1
- package/dist/babylon.quarks.esm.js.map +1 -1
- package/dist/babylon.quarks.umd.min.js +2 -0
- package/dist/babylon.quarks.umd.min.js.map +1 -0
- package/dist/types/index.d.ts +2829 -19
- package/package.json +62 -60
- package/src/BatchedParticleRenderer.ts +3 -3
- package/src/BatchedRenderer.ts +228 -227
- package/src/MeshSurfaceEmitter.ts +137 -137
- package/src/ParticleEmitter.ts +86 -86
- package/src/ParticleSystem.ts +1322 -1285
- package/src/QuarksLoader.ts +529 -510
- package/src/QuarksPrefab.ts +307 -307
- package/src/QuarksUtil.ts +66 -66
- package/src/SpriteBatch.ts +403 -404
- package/src/TrailBatch.ts +420 -419
- package/src/VFXBatch.ts +108 -108
- package/src/geometryUtil.ts +15 -15
- package/src/index.ts +59 -52
- package/src/materials/ParticleMaterials.ts +23 -23
- package/src/materials/index.ts +1 -1
- package/src/shaders/chunks/index.ts +1 -1
- package/src/shaders/chunks/register-shader-chunks.ts +32 -32
- package/src/shaders/chunks/soft_fragment.glsl.ts +13 -13
- package/src/shaders/chunks/soft_pars_fragment.glsl.ts +20 -20
- package/src/shaders/chunks/soft_pars_vertex.glsl.ts +6 -6
- package/src/shaders/chunks/soft_vertex.glsl.ts +6 -6
- package/src/shaders/chunks/tile_fragment.glsl.ts +9 -9
- package/src/shaders/chunks/tile_pars_fragment.glsl.ts +9 -9
- package/src/shaders/chunks/tile_pars_vertex.glsl.ts +28 -28
- package/src/shaders/chunks/tile_vertex.glsl.ts +18 -18
- package/src/shaders/index.ts +9 -9
- package/src/shaders/local_particle_physics_vert.glsl.ts +79 -79
- package/src/shaders/local_particle_vert.glsl.ts +50 -50
- package/src/shaders/particle_frag.glsl.ts +61 -61
- package/src/shaders/particle_physics_frag.glsl.ts +67 -67
- package/src/shaders/particle_vert.glsl.ts +85 -85
- package/src/shaders/stretched_bb_particle_vert.glsl.ts +76 -74
- package/src/shaders/trail_frag.glsl.ts +21 -21
- package/src/shaders/trail_vert.glsl.ts +58 -58
- package/dist/types/BatchedParticleRenderer.d.ts +0 -2
- package/dist/types/BatchedRenderer.d.ts +0 -59
- package/dist/types/MeshSurfaceEmitter.d.ts +0 -19
- package/dist/types/ParticleEmitter.d.ts +0 -16
- package/dist/types/ParticleSystem.d.ts +0 -234
- package/dist/types/QuarksLoader.d.ts +0 -28
- package/dist/types/QuarksPrefab.d.ts +0 -48
- package/dist/types/QuarksUtil.d.ts +0 -14
- package/dist/types/SpriteBatch.d.ts +0 -33
- package/dist/types/TrailBatch.d.ts +0 -28
- package/dist/types/VFXBatch.d.ts +0 -51
- package/dist/types/geometryUtil.d.ts +0 -2
- package/dist/types/materials/ParticleMaterials.d.ts +0 -12
- package/dist/types/materials/index.d.ts +0 -1
- package/dist/types/shaders/chunks/index.d.ts +0 -1
- package/dist/types/shaders/chunks/register-shader-chunks.d.ts +0 -3
- package/dist/types/shaders/chunks/soft_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/soft_pars_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/soft_pars_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/soft_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_pars_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_pars_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/index.d.ts +0 -9
- package/dist/types/shaders/local_particle_physics_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/local_particle_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/particle_frag.glsl.d.ts +0 -2
- package/dist/types/shaders/particle_physics_frag.glsl.d.ts +0 -2
- package/dist/types/shaders/particle_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/stretched_bb_particle_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/trail_frag.glsl.d.ts +0 -2
- package/dist/types/shaders/trail_vert.glsl.d.ts +0 -2
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#ifdef UV_TILE
|
|
3
|
-
attribute float uvTile;
|
|
4
|
-
uniform vec2 tileCount;
|
|
5
|
-
|
|
6
|
-
mat3 makeTileTransform(float tileIndex) {
|
|
7
|
-
float col = mod(tileIndex, tileCount.x);
|
|
8
|
-
float row = (tileCount.y - floor(tileIndex / tileCount.x) - 1.0);
|
|
9
|
-
return mat3(
|
|
10
|
-
1.0 / tileCount.x, 0.0, 0.0,
|
|
11
|
-
0.0, 1.0 / tileCount.y, 0.0,
|
|
12
|
-
col / tileCount.x, row / tileCount.y, 1.0
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
#else
|
|
16
|
-
mat3 makeTileTransform(float tileIndex) {
|
|
17
|
-
return mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
|
|
18
|
-
}
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
#if defined(USE_UV)
|
|
22
|
-
varying vec2 vUv;
|
|
23
|
-
#ifdef TILE_BLEND
|
|
24
|
-
varying vec2 vUvNext;
|
|
25
|
-
varying float vUvBlend;
|
|
26
|
-
#endif
|
|
27
|
-
#endif
|
|
28
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#ifdef UV_TILE
|
|
3
|
+
attribute float uvTile;
|
|
4
|
+
uniform vec2 tileCount;
|
|
5
|
+
|
|
6
|
+
mat3 makeTileTransform(float tileIndex) {
|
|
7
|
+
float col = mod(tileIndex, tileCount.x);
|
|
8
|
+
float row = (tileCount.y - floor(tileIndex / tileCount.x) - 1.0);
|
|
9
|
+
return mat3(
|
|
10
|
+
1.0 / tileCount.x, 0.0, 0.0,
|
|
11
|
+
0.0, 1.0 / tileCount.y, 0.0,
|
|
12
|
+
col / tileCount.x, row / tileCount.y, 1.0
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
#else
|
|
16
|
+
mat3 makeTileTransform(float tileIndex) {
|
|
17
|
+
return mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
|
|
18
|
+
}
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#if defined(USE_UV)
|
|
22
|
+
varying vec2 vUv;
|
|
23
|
+
#ifdef TILE_BLEND
|
|
24
|
+
varying vec2 vUvNext;
|
|
25
|
+
varying float vUvBlend;
|
|
26
|
+
#endif
|
|
27
|
+
#endif
|
|
28
|
+
`;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#ifdef UV_TILE
|
|
3
|
-
mat3 tileTransform = makeTileTransform(floor(uvTile));
|
|
4
|
-
#ifdef TILE_BLEND
|
|
5
|
-
mat3 nextTileTransform = makeTileTransform(ceil(uvTile));
|
|
6
|
-
vUvBlend = fract(uvTile);
|
|
7
|
-
#endif
|
|
8
|
-
#else
|
|
9
|
-
mat3 tileTransform = makeTileTransform(0.0);
|
|
10
|
-
#endif
|
|
11
|
-
|
|
12
|
-
#if defined(USE_UV)
|
|
13
|
-
vUv = (tileTransform * vec3(uv, 1.0)).xy;
|
|
14
|
-
#if defined(TILE_BLEND) && defined(UV_TILE)
|
|
15
|
-
vUvNext = (nextTileTransform * vec3(uv, 1.0)).xy;
|
|
16
|
-
#endif
|
|
17
|
-
#endif
|
|
18
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#ifdef UV_TILE
|
|
3
|
+
mat3 tileTransform = makeTileTransform(floor(uvTile));
|
|
4
|
+
#ifdef TILE_BLEND
|
|
5
|
+
mat3 nextTileTransform = makeTileTransform(ceil(uvTile));
|
|
6
|
+
vUvBlend = fract(uvTile);
|
|
7
|
+
#endif
|
|
8
|
+
#else
|
|
9
|
+
mat3 tileTransform = makeTileTransform(0.0);
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#if defined(USE_UV)
|
|
13
|
+
vUv = (tileTransform * vec3(uv, 1.0)).xy;
|
|
14
|
+
#if defined(TILE_BLEND) && defined(UV_TILE)
|
|
15
|
+
vUvNext = (nextTileTransform * vec3(uv, 1.0)).xy;
|
|
16
|
+
#endif
|
|
17
|
+
#endif
|
|
18
|
+
`;
|
package/src/shaders/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './chunks';
|
|
2
|
-
export {default as particleVertShader} from './particle_vert.glsl';
|
|
3
|
-
export {default as particleFragShader} from './particle_frag.glsl';
|
|
4
|
-
export {default as localParticleVertShader} from './local_particle_vert.glsl';
|
|
5
|
-
export {default as localParticlePhysicsVertShader} from './local_particle_physics_vert.glsl';
|
|
6
|
-
export {default as particlePhysicsFragShader} from './particle_physics_frag.glsl';
|
|
7
|
-
export {default as stretchedBillboardVertShader} from './stretched_bb_particle_vert.glsl';
|
|
8
|
-
export {default as trailVertShader} from './trail_vert.glsl';
|
|
9
|
-
export {default as trailFragShader} from './trail_frag.glsl';
|
|
1
|
+
export * from './chunks';
|
|
2
|
+
export {default as particleVertShader} from './particle_vert.glsl';
|
|
3
|
+
export {default as particleFragShader} from './particle_frag.glsl';
|
|
4
|
+
export {default as localParticleVertShader} from './local_particle_vert.glsl';
|
|
5
|
+
export {default as localParticlePhysicsVertShader} from './local_particle_physics_vert.glsl';
|
|
6
|
+
export {default as particlePhysicsFragShader} from './particle_physics_frag.glsl';
|
|
7
|
+
export {default as stretchedBillboardVertShader} from './stretched_bb_particle_vert.glsl';
|
|
8
|
+
export {default as trailVertShader} from './trail_vert.glsl';
|
|
9
|
+
export {default as trailFragShader} from './trail_frag.glsl';
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
attribute vec3 position;
|
|
3
|
-
attribute vec2 uv;
|
|
4
|
-
attribute vec3 normal;
|
|
5
|
-
attribute vec3 offset;
|
|
6
|
-
attribute vec4 color;
|
|
7
|
-
attribute vec3 size;
|
|
8
|
-
attribute vec4 rotation;
|
|
9
|
-
attribute float uvTile;
|
|
10
|
-
|
|
11
|
-
uniform mat4 world;
|
|
12
|
-
uniform mat4 view;
|
|
13
|
-
uniform mat4 projection;
|
|
14
|
-
|
|
15
|
-
#ifdef UV_TILE
|
|
16
|
-
uniform float tileCountX;
|
|
17
|
-
uniform float tileCountY;
|
|
18
|
-
#endif
|
|
19
|
-
|
|
20
|
-
varying vec2 vUV;
|
|
21
|
-
varying vec4 vColor;
|
|
22
|
-
varying vec3 vNormal;
|
|
23
|
-
varying vec3 vWorldPos;
|
|
24
|
-
|
|
25
|
-
#ifdef TILE_BLEND
|
|
26
|
-
varying vec2 vUV2;
|
|
27
|
-
varying float vTileBlend;
|
|
28
|
-
#endif
|
|
29
|
-
|
|
30
|
-
#ifdef SOFT_PARTICLES
|
|
31
|
-
varying vec4 projPosition;
|
|
32
|
-
varying float linearDepth;
|
|
33
|
-
#endif
|
|
34
|
-
|
|
35
|
-
vec3 applyQuaternion(vec3 v, vec4 q) {
|
|
36
|
-
vec3 qVec = q.xyz;
|
|
37
|
-
float qW = q.w;
|
|
38
|
-
vec3 t = 2.0 * cross(qVec, v);
|
|
39
|
-
return v + qW * t + cross(qVec, t);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
void main() {
|
|
43
|
-
vec3 scaledPosition = position * size;
|
|
44
|
-
vec3 rotatedPosition = applyQuaternion(scaledPosition, rotation);
|
|
45
|
-
vec3 rotatedNormal = normalize(applyQuaternion(normal, rotation));
|
|
46
|
-
vec3 localPos = rotatedPosition + offset;
|
|
47
|
-
|
|
48
|
-
vec4 worldPos = world * vec4(localPos, 1.0);
|
|
49
|
-
vec4 viewPos = view * worldPos;
|
|
50
|
-
gl_Position = projection * viewPos;
|
|
51
|
-
|
|
52
|
-
vWorldPos = worldPos.xyz;
|
|
53
|
-
vNormal = normalize((world * vec4(rotatedNormal, 0.0)).xyz);
|
|
54
|
-
|
|
55
|
-
#ifdef SOFT_PARTICLES
|
|
56
|
-
projPosition = gl_Position;
|
|
57
|
-
linearDepth = -viewPos.z;
|
|
58
|
-
#endif
|
|
59
|
-
|
|
60
|
-
#ifdef UV_TILE
|
|
61
|
-
vec2 tc = vec2(tileCountX, tileCountY);
|
|
62
|
-
float baseTile = floor(uvTile);
|
|
63
|
-
float tileU = mod(baseTile, tc.x) / tc.x;
|
|
64
|
-
float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
65
|
-
vUV = uv / tc + vec2(tileU, tileV);
|
|
66
|
-
#ifdef TILE_BLEND
|
|
67
|
-
float nextTile = ceil(uvTile);
|
|
68
|
-
float nextU = mod(nextTile, tc.x) / tc.x;
|
|
69
|
-
float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
70
|
-
vUV2 = uv / tc + vec2(nextU, nextV);
|
|
71
|
-
vTileBlend = fract(uvTile);
|
|
72
|
-
#endif
|
|
73
|
-
#else
|
|
74
|
-
vUV = uv;
|
|
75
|
-
#endif
|
|
76
|
-
|
|
77
|
-
vColor = color;
|
|
78
|
-
}
|
|
79
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
attribute vec3 position;
|
|
3
|
+
attribute vec2 uv;
|
|
4
|
+
attribute vec3 normal;
|
|
5
|
+
attribute vec3 offset;
|
|
6
|
+
attribute vec4 color;
|
|
7
|
+
attribute vec3 size;
|
|
8
|
+
attribute vec4 rotation;
|
|
9
|
+
attribute float uvTile;
|
|
10
|
+
|
|
11
|
+
uniform mat4 world;
|
|
12
|
+
uniform mat4 view;
|
|
13
|
+
uniform mat4 projection;
|
|
14
|
+
|
|
15
|
+
#ifdef UV_TILE
|
|
16
|
+
uniform float tileCountX;
|
|
17
|
+
uniform float tileCountY;
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
varying vec2 vUV;
|
|
21
|
+
varying vec4 vColor;
|
|
22
|
+
varying vec3 vNormal;
|
|
23
|
+
varying vec3 vWorldPos;
|
|
24
|
+
|
|
25
|
+
#ifdef TILE_BLEND
|
|
26
|
+
varying vec2 vUV2;
|
|
27
|
+
varying float vTileBlend;
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#ifdef SOFT_PARTICLES
|
|
31
|
+
varying vec4 projPosition;
|
|
32
|
+
varying float linearDepth;
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
vec3 applyQuaternion(vec3 v, vec4 q) {
|
|
36
|
+
vec3 qVec = q.xyz;
|
|
37
|
+
float qW = q.w;
|
|
38
|
+
vec3 t = 2.0 * cross(qVec, v);
|
|
39
|
+
return v + qW * t + cross(qVec, t);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void main() {
|
|
43
|
+
vec3 scaledPosition = position * size;
|
|
44
|
+
vec3 rotatedPosition = applyQuaternion(scaledPosition, rotation);
|
|
45
|
+
vec3 rotatedNormal = normalize(applyQuaternion(normal, rotation));
|
|
46
|
+
vec3 localPos = rotatedPosition + offset;
|
|
47
|
+
|
|
48
|
+
vec4 worldPos = world * vec4(localPos, 1.0);
|
|
49
|
+
vec4 viewPos = view * worldPos;
|
|
50
|
+
gl_Position = projection * viewPos;
|
|
51
|
+
|
|
52
|
+
vWorldPos = worldPos.xyz;
|
|
53
|
+
vNormal = normalize((world * vec4(rotatedNormal, 0.0)).xyz);
|
|
54
|
+
|
|
55
|
+
#ifdef SOFT_PARTICLES
|
|
56
|
+
projPosition = gl_Position;
|
|
57
|
+
linearDepth = -viewPos.z;
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#ifdef UV_TILE
|
|
61
|
+
vec2 tc = vec2(tileCountX, tileCountY);
|
|
62
|
+
float baseTile = floor(uvTile);
|
|
63
|
+
float tileU = mod(baseTile, tc.x) / tc.x;
|
|
64
|
+
float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
65
|
+
vUV = uv / tc + vec2(tileU, tileV);
|
|
66
|
+
#ifdef TILE_BLEND
|
|
67
|
+
float nextTile = ceil(uvTile);
|
|
68
|
+
float nextU = mod(nextTile, tc.x) / tc.x;
|
|
69
|
+
float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
70
|
+
vUV2 = uv / tc + vec2(nextU, nextV);
|
|
71
|
+
vTileBlend = fract(uvTile);
|
|
72
|
+
#endif
|
|
73
|
+
#else
|
|
74
|
+
vUV = uv;
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
vColor = color;
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
// Per-vertex attributes
|
|
3
|
-
attribute vec3 position;
|
|
4
|
-
attribute vec2 uv;
|
|
5
|
-
|
|
6
|
-
// Per-instance attributes
|
|
7
|
-
attribute vec3 offset;
|
|
8
|
-
attribute vec4 color;
|
|
9
|
-
attribute vec3 size;
|
|
10
|
-
attribute vec4 rotation;
|
|
11
|
-
attribute float uvTile;
|
|
12
|
-
|
|
13
|
-
// Uniforms
|
|
14
|
-
uniform mat4 worldViewProjection;
|
|
15
|
-
|
|
16
|
-
#ifdef UV_TILE
|
|
17
|
-
uniform float tileCountX;
|
|
18
|
-
uniform float tileCountY;
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
// Varyings
|
|
22
|
-
varying vec2 vUV;
|
|
23
|
-
varying vec4 vColor;
|
|
24
|
-
|
|
25
|
-
vec3 applyQuaternion(vec3 v, vec4 q) {
|
|
26
|
-
vec3 qVec = q.xyz;
|
|
27
|
-
float qW = q.w;
|
|
28
|
-
vec3 t = 2.0 * cross(qVec, v);
|
|
29
|
-
return v + qW * t + cross(qVec, t);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
void main() {
|
|
33
|
-
vec3 rotatedPosition = applyQuaternion(position * size, rotation);
|
|
34
|
-
vec3 worldPos = rotatedPosition + offset;
|
|
35
|
-
|
|
36
|
-
gl_Position = worldViewProjection * vec4(worldPos, 1.0);
|
|
37
|
-
|
|
38
|
-
#ifdef UV_TILE
|
|
39
|
-
vec2 tc = vec2(tileCountX, tileCountY);
|
|
40
|
-
float baseTile = floor(uvTile);
|
|
41
|
-
float tileU = mod(baseTile, tc.x) / tc.x;
|
|
42
|
-
float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
43
|
-
vUV = uv / tc + vec2(tileU, tileV);
|
|
44
|
-
#else
|
|
45
|
-
vUV = uv;
|
|
46
|
-
#endif
|
|
47
|
-
|
|
48
|
-
vColor = color;
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
// Per-vertex attributes
|
|
3
|
+
attribute vec3 position;
|
|
4
|
+
attribute vec2 uv;
|
|
5
|
+
|
|
6
|
+
// Per-instance attributes
|
|
7
|
+
attribute vec3 offset;
|
|
8
|
+
attribute vec4 color;
|
|
9
|
+
attribute vec3 size;
|
|
10
|
+
attribute vec4 rotation;
|
|
11
|
+
attribute float uvTile;
|
|
12
|
+
|
|
13
|
+
// Uniforms
|
|
14
|
+
uniform mat4 worldViewProjection;
|
|
15
|
+
|
|
16
|
+
#ifdef UV_TILE
|
|
17
|
+
uniform float tileCountX;
|
|
18
|
+
uniform float tileCountY;
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Varyings
|
|
22
|
+
varying vec2 vUV;
|
|
23
|
+
varying vec4 vColor;
|
|
24
|
+
|
|
25
|
+
vec3 applyQuaternion(vec3 v, vec4 q) {
|
|
26
|
+
vec3 qVec = q.xyz;
|
|
27
|
+
float qW = q.w;
|
|
28
|
+
vec3 t = 2.0 * cross(qVec, v);
|
|
29
|
+
return v + qW * t + cross(qVec, t);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void main() {
|
|
33
|
+
vec3 rotatedPosition = applyQuaternion(position * size, rotation);
|
|
34
|
+
vec3 worldPos = rotatedPosition + offset;
|
|
35
|
+
|
|
36
|
+
gl_Position = worldViewProjection * vec4(worldPos, 1.0);
|
|
37
|
+
|
|
38
|
+
#ifdef UV_TILE
|
|
39
|
+
vec2 tc = vec2(tileCountX, tileCountY);
|
|
40
|
+
float baseTile = floor(uvTile);
|
|
41
|
+
float tileU = mod(baseTile, tc.x) / tc.x;
|
|
42
|
+
float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
43
|
+
vUV = uv / tc + vec2(tileU, tileV);
|
|
44
|
+
#else
|
|
45
|
+
vUV = uv;
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
vColor = color;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
varying vec2 vUV;
|
|
3
|
-
varying vec4 vColor;
|
|
4
|
-
|
|
5
|
-
#ifdef TILE_BLEND
|
|
6
|
-
varying vec2 vUV2;
|
|
7
|
-
varying float vTileBlend;
|
|
8
|
-
#endif
|
|
9
|
-
|
|
10
|
-
#ifdef USE_MAP
|
|
11
|
-
uniform sampler2D map;
|
|
12
|
-
#endif
|
|
13
|
-
|
|
14
|
-
#ifdef SOFT_PARTICLES
|
|
15
|
-
uniform sampler2D depthTexture;
|
|
16
|
-
uniform vec2 softParams;
|
|
17
|
-
uniform vec4 projParams;
|
|
18
|
-
varying vec4 projPosition;
|
|
19
|
-
varying float linearDepth;
|
|
20
|
-
#endif
|
|
21
|
-
|
|
22
|
-
#ifdef USE_ALPHATEST
|
|
23
|
-
uniform float alphaTest;
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
|
-
void main() {
|
|
27
|
-
vec4 baseColor = vColor;
|
|
28
|
-
|
|
29
|
-
#ifdef USE_MAP
|
|
30
|
-
vec4 texColor = texture2D(map, vUV);
|
|
31
|
-
#ifdef TILE_BLEND
|
|
32
|
-
vec4 texColor2 = texture2D(map, vUV2);
|
|
33
|
-
texColor = mix(texColor, texColor2, vTileBlend);
|
|
34
|
-
#endif
|
|
35
|
-
baseColor *= texColor;
|
|
36
|
-
#endif
|
|
37
|
-
|
|
38
|
-
#ifdef USE_COLOR_AS_ALPHA
|
|
39
|
-
baseColor.a *= (baseColor.r + baseColor.g + baseColor.b) / 3.0;
|
|
40
|
-
#endif
|
|
41
|
-
|
|
42
|
-
#ifdef USE_ALPHATEST
|
|
43
|
-
if (baseColor.a < alphaTest) discard;
|
|
44
|
-
#else
|
|
45
|
-
if (baseColor.a < 0.01) discard;
|
|
46
|
-
#endif
|
|
47
|
-
|
|
48
|
-
gl_FragColor = baseColor;
|
|
49
|
-
|
|
50
|
-
#ifdef SOFT_PARTICLES
|
|
51
|
-
vec2 p2 = projPosition.xy / projPosition.w;
|
|
52
|
-
p2 = 0.5 * p2 + 0.5;
|
|
53
|
-
float readDepth = texture2D(depthTexture, p2.xy).r;
|
|
54
|
-
float zNear = projParams.x;
|
|
55
|
-
float zFar = projParams.y;
|
|
56
|
-
float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));
|
|
57
|
-
float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);
|
|
58
|
-
gl_FragColor *= fade;
|
|
59
|
-
#endif
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
varying vec2 vUV;
|
|
3
|
+
varying vec4 vColor;
|
|
4
|
+
|
|
5
|
+
#ifdef TILE_BLEND
|
|
6
|
+
varying vec2 vUV2;
|
|
7
|
+
varying float vTileBlend;
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#ifdef USE_MAP
|
|
11
|
+
uniform sampler2D map;
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#ifdef SOFT_PARTICLES
|
|
15
|
+
uniform sampler2D depthTexture;
|
|
16
|
+
uniform vec2 softParams;
|
|
17
|
+
uniform vec4 projParams;
|
|
18
|
+
varying vec4 projPosition;
|
|
19
|
+
varying float linearDepth;
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
#ifdef USE_ALPHATEST
|
|
23
|
+
uniform float alphaTest;
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
void main() {
|
|
27
|
+
vec4 baseColor = vColor;
|
|
28
|
+
|
|
29
|
+
#ifdef USE_MAP
|
|
30
|
+
vec4 texColor = texture2D(map, vUV);
|
|
31
|
+
#ifdef TILE_BLEND
|
|
32
|
+
vec4 texColor2 = texture2D(map, vUV2);
|
|
33
|
+
texColor = mix(texColor, texColor2, vTileBlend);
|
|
34
|
+
#endif
|
|
35
|
+
baseColor *= texColor;
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#ifdef USE_COLOR_AS_ALPHA
|
|
39
|
+
baseColor.a *= (baseColor.r + baseColor.g + baseColor.b) / 3.0;
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#ifdef USE_ALPHATEST
|
|
43
|
+
if (baseColor.a < alphaTest) discard;
|
|
44
|
+
#else
|
|
45
|
+
if (baseColor.a < 0.01) discard;
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
gl_FragColor = baseColor;
|
|
49
|
+
|
|
50
|
+
#ifdef SOFT_PARTICLES
|
|
51
|
+
vec2 p2 = projPosition.xy / projPosition.w;
|
|
52
|
+
p2 = 0.5 * p2 + 0.5;
|
|
53
|
+
float readDepth = texture2D(depthTexture, p2.xy).r;
|
|
54
|
+
float zNear = projParams.x;
|
|
55
|
+
float zFar = projParams.y;
|
|
56
|
+
float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));
|
|
57
|
+
float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);
|
|
58
|
+
gl_FragColor *= fade;
|
|
59
|
+
#endif
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
varying vec2 vUV;
|
|
3
|
-
varying vec4 vColor;
|
|
4
|
-
varying vec3 vNormal;
|
|
5
|
-
|
|
6
|
-
uniform vec3 lightDirection;
|
|
7
|
-
uniform vec3 lightColor;
|
|
8
|
-
uniform vec3 ambientColor;
|
|
9
|
-
|
|
10
|
-
#ifdef TILE_BLEND
|
|
11
|
-
varying vec2 vUV2;
|
|
12
|
-
varying float vTileBlend;
|
|
13
|
-
#endif
|
|
14
|
-
|
|
15
|
-
#ifdef USE_MAP
|
|
16
|
-
uniform sampler2D map;
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
#ifdef SOFT_PARTICLES
|
|
20
|
-
uniform sampler2D depthTexture;
|
|
21
|
-
uniform vec2 softParams;
|
|
22
|
-
uniform vec4 projParams;
|
|
23
|
-
varying vec4 projPosition;
|
|
24
|
-
varying float linearDepth;
|
|
25
|
-
#endif
|
|
26
|
-
|
|
27
|
-
#ifdef USE_ALPHATEST
|
|
28
|
-
uniform float alphaTest;
|
|
29
|
-
#endif
|
|
30
|
-
|
|
31
|
-
void main() {
|
|
32
|
-
vec4 baseColor = vColor;
|
|
33
|
-
|
|
34
|
-
#ifdef USE_MAP
|
|
35
|
-
vec4 texColor = texture2D(map, vUV);
|
|
36
|
-
#ifdef TILE_BLEND
|
|
37
|
-
vec4 texColor2 = texture2D(map, vUV2);
|
|
38
|
-
texColor = mix(texColor, texColor2, vTileBlend);
|
|
39
|
-
#endif
|
|
40
|
-
baseColor *= texColor;
|
|
41
|
-
#endif
|
|
42
|
-
|
|
43
|
-
#ifdef USE_ALPHATEST
|
|
44
|
-
if (baseColor.a < alphaTest) discard;
|
|
45
|
-
#else
|
|
46
|
-
if (baseColor.a < 0.01) discard;
|
|
47
|
-
#endif
|
|
48
|
-
|
|
49
|
-
vec3 N = normalize(vNormal);
|
|
50
|
-
vec3 L = normalize(-lightDirection);
|
|
51
|
-
float NdotL = max(dot(N, L), 0.0);
|
|
52
|
-
vec3 litColor = ambientColor + lightColor * NdotL;
|
|
53
|
-
|
|
54
|
-
gl_FragColor = vec4(baseColor.rgb * litColor, baseColor.a);
|
|
55
|
-
|
|
56
|
-
#ifdef SOFT_PARTICLES
|
|
57
|
-
vec2 p2 = projPosition.xy / projPosition.w;
|
|
58
|
-
p2 = 0.5 * p2 + 0.5;
|
|
59
|
-
float readDepth = texture2D(depthTexture, p2.xy).r;
|
|
60
|
-
float zNear = projParams.x;
|
|
61
|
-
float zFar = projParams.y;
|
|
62
|
-
float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));
|
|
63
|
-
float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);
|
|
64
|
-
gl_FragColor *= fade;
|
|
65
|
-
#endif
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
varying vec2 vUV;
|
|
3
|
+
varying vec4 vColor;
|
|
4
|
+
varying vec3 vNormal;
|
|
5
|
+
|
|
6
|
+
uniform vec3 lightDirection;
|
|
7
|
+
uniform vec3 lightColor;
|
|
8
|
+
uniform vec3 ambientColor;
|
|
9
|
+
|
|
10
|
+
#ifdef TILE_BLEND
|
|
11
|
+
varying vec2 vUV2;
|
|
12
|
+
varying float vTileBlend;
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
#ifdef USE_MAP
|
|
16
|
+
uniform sampler2D map;
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#ifdef SOFT_PARTICLES
|
|
20
|
+
uniform sampler2D depthTexture;
|
|
21
|
+
uniform vec2 softParams;
|
|
22
|
+
uniform vec4 projParams;
|
|
23
|
+
varying vec4 projPosition;
|
|
24
|
+
varying float linearDepth;
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
#ifdef USE_ALPHATEST
|
|
28
|
+
uniform float alphaTest;
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
void main() {
|
|
32
|
+
vec4 baseColor = vColor;
|
|
33
|
+
|
|
34
|
+
#ifdef USE_MAP
|
|
35
|
+
vec4 texColor = texture2D(map, vUV);
|
|
36
|
+
#ifdef TILE_BLEND
|
|
37
|
+
vec4 texColor2 = texture2D(map, vUV2);
|
|
38
|
+
texColor = mix(texColor, texColor2, vTileBlend);
|
|
39
|
+
#endif
|
|
40
|
+
baseColor *= texColor;
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
#ifdef USE_ALPHATEST
|
|
44
|
+
if (baseColor.a < alphaTest) discard;
|
|
45
|
+
#else
|
|
46
|
+
if (baseColor.a < 0.01) discard;
|
|
47
|
+
#endif
|
|
48
|
+
|
|
49
|
+
vec3 N = normalize(vNormal);
|
|
50
|
+
vec3 L = normalize(-lightDirection);
|
|
51
|
+
float NdotL = max(dot(N, L), 0.0);
|
|
52
|
+
vec3 litColor = ambientColor + lightColor * NdotL;
|
|
53
|
+
|
|
54
|
+
gl_FragColor = vec4(baseColor.rgb * litColor, baseColor.a);
|
|
55
|
+
|
|
56
|
+
#ifdef SOFT_PARTICLES
|
|
57
|
+
vec2 p2 = projPosition.xy / projPosition.w;
|
|
58
|
+
p2 = 0.5 * p2 + 0.5;
|
|
59
|
+
float readDepth = texture2D(depthTexture, p2.xy).r;
|
|
60
|
+
float zNear = projParams.x;
|
|
61
|
+
float zFar = projParams.y;
|
|
62
|
+
float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));
|
|
63
|
+
float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);
|
|
64
|
+
gl_FragColor *= fade;
|
|
65
|
+
#endif
|
|
66
|
+
}
|
|
67
|
+
`;
|