@plastic-software/three 0.175.0 → 0.175.1

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.
Files changed (36) hide show
  1. package/build/three.cjs +89 -30
  2. package/build/three.core.js +7 -2
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +84 -32
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.webgpu.js +1 -1
  7. package/build/three.webgpu.min.js +1 -1
  8. package/build/three.webgpu.nodes.js +1 -1
  9. package/build/three.webgpu.nodes.min.js +1 -1
  10. package/package.json +1 -1
  11. package/src/constants.js +3 -0
  12. package/src/loaders/ObjectLoader.js +5 -1
  13. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +10 -1
  14. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -1
  15. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +5 -1
  16. package/src/renderers/shaders/ShaderChunk/common.glsl.js +82 -0
  17. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +22 -2
  18. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +12 -1
  19. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +8 -2
  20. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +31 -11
  21. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +5 -1
  22. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +1 -1
  23. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +1 -1
  24. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -1
  25. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -1
  26. package/src/renderers/shaders/ShaderChunk/triplanar_fragment.glsl.js +20 -0
  27. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +52 -7
  28. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +25 -6
  29. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +19 -7
  30. package/src/renderers/shaders/ShaderChunk.js +2 -0
  31. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -0
  32. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  33. package/src/renderers/shaders/UniformsLib.js +5 -1
  34. package/src/renderers/webgl/WebGLMaterials.js +12 -0
  35. package/src/renderers/webgl/WebGLProgram.js +25 -5
  36. package/src/renderers/webgl/WebGLPrograms.js +21 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plastic-software/three",
3
- "version": "0.175.0",
3
+ "version": "0.175.1",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.cjs",
package/src/constants.js CHANGED
@@ -538,6 +538,9 @@ export const EquirectangularRefractionMapping = 304;
538
538
  */
539
539
  export const CubeUVReflectionMapping = 306;
540
540
 
541
+ export const TriPlanarMapping = 307;
542
+ export const CylindricalMapping = 308;
543
+
541
544
  /**
542
545
  * The texture will simply repeat to infinity.
543
546
  *
@@ -5,6 +5,8 @@ import {
5
5
  EquirectangularReflectionMapping,
6
6
  EquirectangularRefractionMapping,
7
7
  CubeUVReflectionMapping,
8
+ TriPlanarMapping,
9
+ CylindricalMapping,
8
10
 
9
11
  RepeatWrapping,
10
12
  ClampToEdgeWrapping,
@@ -1215,7 +1217,9 @@ const TEXTURE_MAPPING = {
1215
1217
  CubeRefractionMapping: CubeRefractionMapping,
1216
1218
  EquirectangularReflectionMapping: EquirectangularReflectionMapping,
1217
1219
  EquirectangularRefractionMapping: EquirectangularRefractionMapping,
1218
- CubeUVReflectionMapping: CubeUVReflectionMapping
1220
+ CubeUVReflectionMapping: CubeUVReflectionMapping,
1221
+ TriPlanarMapping: TriPlanarMapping,
1222
+ CylindricalMapping: CylindricalMapping
1219
1223
  };
1220
1224
 
1221
1225
  const TEXTURE_WRAPPING = {
@@ -1,7 +1,16 @@
1
1
  export default /* glsl */`
2
2
  #ifdef USE_ALPHAMAP
3
+ #ifdef USE_ALPHAMAP_TRIPLANAR
3
4
 
4
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
5
+ diffuseColor.a *= texture2DTriplanar( alphaMap, alphaMapTransform, triplanarCoords, triplanarWeights ).g;
5
6
 
7
+ #else
8
+ #if defined( USE_ALPHAMAP_CYLINDRICAL )
9
+ vec2 vAlphaMapUv = ( alphaMapTransform * vec3( positionBasedUv, 1 ) ).xy;
10
+ #endif
11
+
12
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
13
+
14
+ #endif
6
15
  #endif
7
16
  `;
@@ -2,7 +2,14 @@ export default /* glsl */`
2
2
  #ifdef USE_AOMAP
3
3
 
4
4
  // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
5
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
5
+ #ifdef USE_AOMAP_TRIPLANAR
6
+ float ambientOcclusion = ( texture2DTriplanar( aoMap, aoMapTransform, triplanarCoords, triplanarWeights ).r - 1.0 ) * aoMapIntensity + 1.0;
7
+ #else
8
+ #if defined( USE_AOMAP_CYLINDRICAL )
9
+ vec2 vAoMapUv = ( aoMapTransform * vec3( positionBasedUv, 1 ) ).xy;
10
+ #endif
11
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
12
+ #endif
6
13
 
7
14
  reflectedLight.indirectDiffuse *= ambientOcclusion;
8
15
 
@@ -1,5 +1,9 @@
1
1
  export default /* glsl */`
2
- #ifdef USE_CLEARCOAT_NORMALMAP
2
+ #ifdef USE_CLEARCOAT_NORMALMAP_TRIPLANAR
3
+
4
+ normal = normalize(normalMatrix * transpose(mat3(texture3DMatrix)) * texture2DTriplanarNormal( clearcoatNormalMap, clearcoatNormalMapTransform, clearcoatNormalScale, normalize(mat3(texture3DMatrix) * vModelNormal.xyz), triplanarCoords, triplanarWeights ));
5
+
6
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
3
7
 
4
8
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
5
9
  clearcoatMapN.xy *= clearcoatNormalScale;
@@ -134,4 +134,86 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
134
134
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
135
135
 
136
136
  } // validated
137
+
138
+ #if defined( USE_MAP_TRIPLANAR ) || \
139
+ defined( USE_ALPHAMAP_TRIPLANAR ) || \
140
+ defined( USE_NORMALMAP_TRIPLANAR ) || \
141
+ defined( USE_ROUGHNESSMAP_TRIPLANAR ) || \
142
+ defined( USE_AOMAP_TRIPLANAR ) || \
143
+ defined( USE_METALNESSMAP_TRIPLANAR ) || \
144
+ defined( USE_CLEARCOAT_NORMALMAP_TRIPLANAR )
145
+
146
+ #define USE_TRIPLANAR
147
+
148
+ #endif
149
+
150
+ #if defined( USE_MAP_TRIPLANAR ) || \
151
+ defined( USE_ALPHAMAP_TRIPLANAR ) || \
152
+ defined( USE_ROUGHNESSMAP_TRIPLANAR ) || \
153
+ defined( USE_AOMAP_TRIPLANAR ) || \
154
+ defined( USE_METALNESSMAP_TRIPLANAR )
155
+
156
+ vec4 texture2DTriplanar( sampler2D map, mat3 uvTransform, vec3 coords, vec3 weights ) {
157
+ return weights.x * texture2D( map, (uvTransform * vec3(coords.zy, 1)).xy ) +
158
+ weights.y * texture2D( map, (uvTransform * vec3(coords.xz, 1)).xy ) +
159
+ weights.z * texture2D( map, (uvTransform * vec3(coords.xy, 1)).xy );
160
+
161
+ }
162
+
163
+ #endif
164
+
165
+ #if defined( USE_NORMALMAP_TRIPLANAR ) || defined( USE_CLEARCOAT_NORMALMAP_TRIPLANAR )
166
+
167
+ vec3 texture2DTriplanarNormal( sampler2D normalMap, mat3 uvTransform, vec2 normalMapScale, vec3 normal, vec3 coords, vec3 weights ) {
168
+ // Whiteout blend
169
+
170
+ // Triplanar uvs
171
+ vec2 uvX = coords.zy; // x facing plane
172
+ vec2 uvY = coords.xz; // y facing plane
173
+ vec2 uvZ = coords.xy; // z facing plane
174
+
175
+ // Tangent space normal maps
176
+ vec3 tnormalX = texture2D( normalMap, (uvTransform * vec3(uvX, 1)).xy ).xyz * 2.0 - 1.0;
177
+ vec3 tnormalY = texture2D( normalMap, (uvTransform * vec3(uvY, 1)).xy ).xyz * 2.0 - 1.0;
178
+ vec3 tnormalZ = texture2D( normalMap, (uvTransform * vec3(uvZ, 1)).xy ).xyz * 2.0 - 1.0;
179
+
180
+ tnormalX.xy *= normalMapScale;
181
+ tnormalY.xy *= normalMapScale;
182
+ tnormalZ.xy *= normalMapScale;
183
+
184
+ // Swizzle world normals into tangent space and apply Whiteout blend
185
+ tnormalX = vec3(
186
+ tnormalX.xy + normal.zy,
187
+ abs(tnormalX.z) * normal.x
188
+ );
189
+ tnormalY = vec3(
190
+ tnormalY.xy + normal.xz,
191
+ abs(tnormalY.z) * normal.y
192
+ );
193
+ tnormalZ = vec3(
194
+ tnormalZ.xy + normal.xy,
195
+ abs(tnormalZ.z) * normal.z
196
+ );
197
+
198
+ // Swizzle tangent normals to match world orientation and triblend
199
+ return normalize(
200
+ tnormalX.zyx * weights.x +
201
+ tnormalY.xzy * weights.y +
202
+ tnormalZ.xyz * weights.z
203
+ );
204
+ }
205
+
206
+ #endif
207
+
208
+ #if defined( USE_MAP_CYLINDRICAL ) || \
209
+ defined( USE_ALPHAMAP_CYLINDRICAL ) || \
210
+ defined( USE_NORMALMAP_CYLINDRICAL ) || \
211
+ defined( USE_ROUGHNESSMAP_CYLINDRICAL ) || \
212
+ defined( USE_AOMAP_CYLINDRICAL ) || \
213
+ defined( USE_METALNESSMAP_CYLINDRICAL ) || \
214
+ defined( USE_CLEARCOAT_NORMALMAP_CYLINDRICAL )
215
+
216
+ #define USE_CYLINDRICAL
217
+
218
+ #endif
137
219
  `;
@@ -5,6 +5,11 @@ vec3 transformedNormal = objectNormal;
5
5
 
6
6
  vec3 transformedTangent = objectTangent;
7
7
 
8
+ #endif
9
+ #if defined( USE_TANGENT_FROM_NORMAL ) || defined( USE_NORMALMAP_TRIPLANAR )
10
+
11
+ mat3 tangentMatrix = mat3(1.0);
12
+
8
13
  #endif
9
14
 
10
15
  #ifdef USE_BATCHING
@@ -20,7 +25,12 @@ vec3 transformedNormal = objectNormal;
20
25
 
21
26
  transformedTangent = bm * transformedTangent;
22
27
 
23
- #endif
28
+ #endif
29
+ #if defined( USE_TANGENT_FROM_NORMAL ) || defined( USE_NORMALMAP_TRIPLANAR )
30
+
31
+ tangentMatrix = bm * tangentMatrix;
32
+
33
+ #endif
24
34
 
25
35
  #endif
26
36
 
@@ -37,7 +47,12 @@ vec3 transformedNormal = objectNormal;
37
47
 
38
48
  transformedTangent = im * transformedTangent;
39
49
 
40
- #endif
50
+ #endif
51
+ #if defined( USE_TANGENT_FROM_NORMAL ) || defined( USE_NORMALMAP_TRIPLANAR )
52
+
53
+ tangentMatrix = im * tangentMatrix;
54
+
55
+ #endif
41
56
 
42
57
  #endif
43
58
 
@@ -59,5 +74,10 @@ transformedNormal = normalMatrix * transformedNormal;
59
74
 
60
75
  #endif
61
76
 
77
+ #endif
78
+ #if defined( USE_TANGENT_FROM_NORMAL ) || defined( USE_NORMALMAP_TRIPLANAR )
79
+
80
+ tangentMatrix = mat3( modelViewMatrix ) * tangentMatrix;
81
+
62
82
  #endif
63
83
  `;
@@ -1,7 +1,18 @@
1
1
  export default /* glsl */`
2
2
  #ifdef USE_MAP
3
3
 
4
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
4
+ #ifdef USE_MAP_TRIPLANAR
5
+
6
+ vec4 sampledDiffuseColor = texture2DTriplanar( map, mapTransform, triplanarCoords, triplanarWeights );
7
+
8
+ #else
9
+ #if defined( USE_MAP_CYLINDRICAL )
10
+ vec2 vMapUv = ( mapTransform * vec3( positionBasedUv, 1 ) ).xy;
11
+ #endif
12
+
13
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
14
+
15
+ #endif
5
16
 
6
17
  #ifdef DECODE_VIDEO_TEXTURE
7
18
 
@@ -2,8 +2,14 @@ export default /* glsl */`
2
2
  float metalnessFactor = metalness;
3
3
 
4
4
  #ifdef USE_METALNESSMAP
5
-
6
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
5
+ #ifdef USE_METALNESSMAP_TRIPLANAR
6
+ vec4 texelMetalness = texture2DTriplanar( metalnessMap, metalnessMapTransform, triplanarCoords, triplanarWeights );
7
+ #else
8
+ #if defined( USE_METALNESSMAP_CYLINDRICAL )
9
+ vec2 vMetalnessMapUv = ( metalnessMapTransform * vec3( positionBasedUv, 1 ) ).xy;
10
+ #endif
11
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
12
+ #endif
7
13
 
8
14
  // reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
9
15
  metalnessFactor *= texelMetalness.b;
@@ -21,21 +21,35 @@ float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
21
21
 
22
22
  #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
23
23
 
24
- #ifdef USE_TANGENT
24
+ #if defined( USE_TANGENT )
25
25
 
26
26
  mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
27
27
 
28
+ #elif defined( USE_NORMALMAP_UV )
29
+
30
+ mat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv );
31
+
32
+ #elif defined( USE_NORMALMAP_CYLINDRICAL ) || defined( USE_CLEARCOAT_NORMALMAP_CYLINDRICAL ) || (defined( USE_ANISOTROPY ) && !defined( USE_UV1 ) || !defined( USE_UV2 ) && !defined( USE_UV3 ))
33
+
34
+ #if defined( USE_NORMALMAP_CYLINDRICAL )
35
+ vec2 vNormalMapUv = ( normalMapTransform * vec3( positionBasedUv, 1 ) ).xy;
36
+ #endif
37
+
38
+ #if defined( USE_CLEARCOAT_NORMALMAP_CYLINDRICAL )
39
+ vec2 vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( positionBasedUv, 1 ) ).xy;
40
+ #endif
41
+
42
+ vec3 tangent = normalize(cross(normal, mat3(modelViewMatrix) * transpose(mat3(texture3DMatrix)) * vec3(0, 1, 0)));
43
+ vec3 bitangent = cross(tangent, normal);
44
+ mat3 tbn = mat3(tangent, bitangent, normal);
45
+
46
+ #elif defined( USE_CLEARCOAT_NORMALMAP_UV )
47
+
48
+ mat3 tbn = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
49
+
28
50
  #else
29
51
 
30
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
31
- #if defined( USE_NORMALMAP )
32
- vNormalMapUv
33
- #elif defined( USE_CLEARCOAT_NORMALMAP )
34
- vClearcoatNormalMapUv
35
- #else
36
- vUv
37
- #endif
38
- );
52
+ mat3 tbn = getTangentFrame( - vViewPosition, normal, vUv );
39
53
 
40
54
  #endif
41
55
 
@@ -54,7 +68,13 @@ float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
54
68
 
55
69
  mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
56
70
 
57
- #else
71
+ #elif defined( USE_CLEARCOAT_NORMALMAP_CYLINDRICAL )
72
+
73
+ vec3 tangent2 = normalize(cross(normal, mat3(modelViewMatrix) * transpose(mat3(texture3DMatrix)) * vec3(0, 1, 0)));
74
+ vec3 bitangent2 = cross(tangent2, normal);
75
+ mat3 tbn2 = mat3(tangent2, bitangent2, normal);
76
+
77
+ #elif defined( USE_CLEARCOAT_NORMALMAP_UV )
58
78
 
59
79
  mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
60
80
 
@@ -1,6 +1,10 @@
1
1
  export default /* glsl */`
2
2
 
3
- #ifdef USE_NORMALMAP_OBJECTSPACE
3
+ #ifdef USE_NORMALMAP_TRIPLANAR
4
+
5
+ normal = normalize(normalMatrix * transpose(mat3(texture3DMatrix)) * texture2DTriplanarNormal( normalMap, normalMapTransform, normalScale, normalize(mat3(texture3DMatrix) * vModelNormal.xyz), triplanarCoords, triplanarWeights ));
6
+
7
+ #elif defined( USE_NORMALMAP_OBJECTSPACE )
4
8
 
5
9
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals
6
10
 
@@ -3,7 +3,7 @@ export default /* glsl */`
3
3
 
4
4
  varying vec3 vNormal;
5
5
 
6
- #ifdef USE_TANGENT
6
+ #if defined( USE_TANGENT )
7
7
 
8
8
  varying vec3 vTangent;
9
9
  varying vec3 vBitangent;
@@ -3,7 +3,7 @@ export default /* glsl */`
3
3
 
4
4
  varying vec3 vNormal;
5
5
 
6
- #ifdef USE_TANGENT
6
+ #if defined( USE_TANGENT )
7
7
 
8
8
  varying vec3 vTangent;
9
9
  varying vec3 vBitangent;
@@ -16,7 +16,7 @@ export default /* glsl */`
16
16
 
17
17
  // Normal Mapping Without Precomputed Tangents
18
18
  // http://www.thetenthplanet.de/archives/1180
19
-
19
+
20
20
  mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
21
21
 
22
22
  vec3 q0 = dFdx( eye_pos.xyz );
@@ -40,4 +40,5 @@ export default /* glsl */`
40
40
  }
41
41
 
42
42
  #endif
43
+
43
44
  `;
@@ -1,7 +1,18 @@
1
1
  export default /* glsl */`
2
2
  float roughnessFactor = roughness;
3
3
 
4
- #ifdef USE_ROUGHNESSMAP
4
+ #ifdef USE_ROUGHNESSMAP_TRIPLANAR
5
+
6
+ vec4 texelRoughness = texture2DTriplanar( roughnessMap, roughnessMapTransform, triplanarCoords, triplanarWeights );
7
+
8
+ // reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
9
+ roughnessFactor *= texelRoughness.g;
10
+
11
+ #elif defined( USE_ROUGHNESSMAP )
12
+
13
+ #if defined( USE_ROUGHNESSMAP_CYLINDRICAL )
14
+ vec2 vRoughnessMapUv = ( roughnessMapTransform * vec3( positionBasedUv, 1 ) ).xy;
15
+ #endif
5
16
 
6
17
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
7
18
 
@@ -0,0 +1,20 @@
1
+ export default /* glsl */`
2
+ #ifdef USE_TRIPLANAR
3
+
4
+ vec3 triplanarWeights = pow(abs(mat3(texture3DMatrix) * vModelNormal), vec3(triplanarHardness, triplanarHardness, triplanarHardness));
5
+ triplanarWeights /= dot(triplanarWeights, vec3(1.0, 1.0, 1.0));
6
+ vec3 triplanarCoords = vModelPosition.xyz;
7
+
8
+ #endif
9
+
10
+ #ifdef USE_CYLINDRICAL
11
+
12
+ // Cylindrical and toroidal parameterizations without vertex seams
13
+ // DOI:10.1080/2151237X.2012.654054
14
+ float positionBasedU1 = fract(atan(vModelPosition.z, vModelPosition.x) * RECIPROCAL_PI2);
15
+ float positionBasedU2 = fract(positionBasedU1 + 0.5) - 0.5;
16
+ vec2 positionBasedUv = vec2(fwidth(positionBasedU1) < fwidth(positionBasedU2) - 1e-3 ? positionBasedU1 : positionBasedU2, vModelPosition.y);
17
+
18
+ #endif
19
+
20
+ `;
@@ -4,12 +4,37 @@ export default /* glsl */`
4
4
  varying vec2 vUv;
5
5
 
6
6
  #endif
7
- #ifdef USE_MAP
7
+ #if defined( USE_TRIPLANAR )
8
+
9
+ uniform float triplanarHardness;
10
+
11
+ #endif
12
+ #if defined( USE_TRIPLANAR ) || defined( USE_CYLINDRICAL )
13
+
14
+ varying vec3 vModelPosition;
15
+
16
+ #endif
17
+ #if defined( USE_TRIPLANAR ) || defined( USE_CYLINDRICAL ) || (defined(USE_ANISOTROPY) && !defined(USE_UV1) && !defined(USE_UV2) && !defined(USE_UV3))
18
+
19
+ varying vec3 vModelNormal;
20
+ uniform mat4 texture3DMatrix;
21
+ uniform mat4 invTexture3DMatrix;
22
+
23
+ #endif
24
+ #if defined( USE_MAP_CYLINDRICAL ) || defined( USE_MAP_TRIPLANAR )
25
+
26
+ uniform mat3 mapTransform;
27
+
28
+ #elif defined( USE_MAP_UV )
8
29
 
9
30
  varying vec2 vMapUv;
10
31
 
11
32
  #endif
12
- #ifdef USE_ALPHAMAP
33
+ #if defined( USE_ALPHAMAP_CYLINDRICAL ) || defined( USE_ALPHAMAP_TRIPLANAR )
34
+
35
+ uniform mat3 alphaMapTransform;
36
+
37
+ #elif defined( USE_ALPHAMAP_UV )
13
38
 
14
39
  varying vec2 vAlphaMapUv;
15
40
 
@@ -19,7 +44,11 @@ export default /* glsl */`
19
44
  varying vec2 vLightMapUv;
20
45
 
21
46
  #endif
22
- #ifdef USE_AOMAP
47
+ #if defined( USE_AOMAP_CYLINDRICAL ) || defined( USE_AOMAP_TRIPLANAR )
48
+
49
+ uniform mat3 aoMapTransform;
50
+
51
+ #elif defined( USE_AOMAP_UV )
23
52
 
24
53
  varying vec2 vAoMapUv;
25
54
 
@@ -29,7 +58,11 @@ export default /* glsl */`
29
58
  varying vec2 vBumpMapUv;
30
59
 
31
60
  #endif
32
- #ifdef USE_NORMALMAP
61
+ #if defined( USE_NORMALMAP_CYLINDRICAL ) || defined( USE_NORMALMAP_TRIPLANAR )
62
+
63
+ uniform mat3 normalMapTransform;
64
+
65
+ #elif defined( USE_NORMALMAP_UV )
33
66
 
34
67
  varying vec2 vNormalMapUv;
35
68
 
@@ -39,12 +72,20 @@ export default /* glsl */`
39
72
  varying vec2 vEmissiveMapUv;
40
73
 
41
74
  #endif
42
- #ifdef USE_METALNESSMAP
75
+ #if defined( USE_METALNESSMAP_CYLINDRICAL ) || defined( USE_METALNESSMAP_TRIPLANAR )
76
+
77
+ uniform mat3 metalnessMapTransform;
78
+
79
+ #elif defined( USE_METALNESSMAP_UV )
43
80
 
44
81
  varying vec2 vMetalnessMapUv;
45
82
 
46
83
  #endif
47
- #ifdef USE_ROUGHNESSMAP
84
+ #if defined( USE_ROUGHNESSMAP_CYLINDRICAL ) || defined( USE_ROUGHNESSMAP_TRIPLANAR )
85
+
86
+ uniform mat3 roughnessMapTransform;
87
+
88
+ #elif defined( USE_ROUGHNESSMAP_UV )
48
89
 
49
90
  varying vec2 vRoughnessMapUv;
50
91
 
@@ -59,7 +100,11 @@ export default /* glsl */`
59
100
  varying vec2 vClearcoatMapUv;
60
101
 
61
102
  #endif
62
- #ifdef USE_CLEARCOAT_NORMALMAP
103
+ #if defined( USE_CLEARCOAT_NORMALMAP_CYLINDRICAL ) || defined( USE_CLEARCOAT_NORMALMAP_TRIPLANAR )
104
+
105
+ uniform mat3 clearcoatNormalMapTransform;
106
+
107
+ #elif defined( USE_CLEARCOAT_NORMALMAP_UV )
63
108
 
64
109
  varying vec2 vClearcoatNormalMapUv;
65
110
 
@@ -4,13 +4,31 @@ export default /* glsl */`
4
4
  varying vec2 vUv;
5
5
 
6
6
  #endif
7
- #ifdef USE_MAP
7
+ #if defined( USE_TRIPLANAR ) || defined( USE_CYLINDRICAL ) || ( defined(USE_ANISOTROPY) && !defined(USE_UV1) && !defined(USE_UV2) && !defined(USE_UV3) )
8
+
9
+ uniform mat4 texture3DMatrix;
10
+
11
+ #endif
12
+ #if defined( USE_TRIPLANAR ) || defined( USE_CYLINDRICAL )
13
+
14
+ varying vec3 vModelPosition;
15
+
16
+ #endif
17
+ #if defined( USE_TRIPLANAR ) || ( defined(USE_ANISOTROPY) && !defined(USE_UV1) && !defined(USE_UV2) && !defined(USE_UV3) )
18
+
19
+ varying vec3 vModelNormal;
20
+
21
+ #endif
22
+ #if defined( USE_CYLINDRICAL )
23
+
24
+ #endif
25
+ #if defined( USE_MAP_UV )
8
26
 
9
27
  uniform mat3 mapTransform;
10
28
  varying vec2 vMapUv;
11
29
 
12
30
  #endif
13
- #ifdef USE_ALPHAMAP
31
+ #if defined( USE_ALPHAMAP_UV )
14
32
 
15
33
  uniform mat3 alphaMapTransform;
16
34
  varying vec2 vAlphaMapUv;
@@ -22,7 +40,7 @@ export default /* glsl */`
22
40
  varying vec2 vLightMapUv;
23
41
 
24
42
  #endif
25
- #ifdef USE_AOMAP
43
+ #if defined( USE_AOMAP_UV )
26
44
 
27
45
  uniform mat3 aoMapTransform;
28
46
  varying vec2 vAoMapUv;
@@ -34,7 +52,7 @@ export default /* glsl */`
34
52
  varying vec2 vBumpMapUv;
35
53
 
36
54
  #endif
37
- #ifdef USE_NORMALMAP
55
+ #if defined( USE_NORMALMAP_UV )
38
56
 
39
57
  uniform mat3 normalMapTransform;
40
58
  varying vec2 vNormalMapUv;
@@ -52,13 +70,13 @@ export default /* glsl */`
52
70
  varying vec2 vEmissiveMapUv;
53
71
 
54
72
  #endif
55
- #ifdef USE_METALNESSMAP
73
+ #if defined( USE_METALNESSMAP_UV )
56
74
 
57
75
  uniform mat3 metalnessMapTransform;
58
76
  varying vec2 vMetalnessMapUv;
59
77
 
60
78
  #endif
61
- #ifdef USE_ROUGHNESSMAP
79
+ #if defined( USE_ROUGHNESSMAP_UV )
62
80
 
63
81
  uniform mat3 roughnessMapTransform;
64
82
  varying vec2 vRoughnessMapUv;
@@ -142,4 +160,5 @@ export default /* glsl */`
142
160
  varying vec2 vThicknessMapUv;
143
161
 
144
162
  #endif
163
+
145
164
  `;
@@ -1,15 +1,27 @@
1
1
  export default /* glsl */`
2
2
  #if defined( USE_UV ) || defined( USE_ANISOTROPY )
3
3
 
4
- vUv = vec3( uv, 1 ).xy;
4
+ #if defined( USE_UV1 ) || defined( USE_UV2 ) || defined( USE_UV3 )
5
+ vUv = vec3( uv, 1 ).xy;
6
+ #endif
5
7
 
6
8
  #endif
7
- #ifdef USE_MAP
9
+ #if defined( USE_TRIPLANAR ) || defined( USE_CYLINDRICAL )
10
+
11
+ vModelPosition = (texture3DMatrix * vec4(position.xyz, 1)).xyz;
12
+
13
+ #endif
14
+ #if defined( USE_TRIPLANAR )
15
+
16
+ vModelNormal = normal.xyz;
17
+
18
+ #endif
19
+ #if defined( USE_MAP_UV )
8
20
 
9
21
  vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
10
22
 
11
23
  #endif
12
- #ifdef USE_ALPHAMAP
24
+ #if defined( USE_ALPHAMAP_UV )
13
25
 
14
26
  vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
15
27
 
@@ -19,7 +31,7 @@ export default /* glsl */`
19
31
  vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
20
32
 
21
33
  #endif
22
- #ifdef USE_AOMAP
34
+ #if defined( USE_AOMAP_UV )
23
35
 
24
36
  vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
25
37
 
@@ -29,7 +41,7 @@ export default /* glsl */`
29
41
  vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
30
42
 
31
43
  #endif
32
- #ifdef USE_NORMALMAP
44
+ #if defined( USE_NORMALMAP_UV )
33
45
 
34
46
  vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
35
47
 
@@ -44,12 +56,12 @@ export default /* glsl */`
44
56
  vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
45
57
 
46
58
  #endif
47
- #ifdef USE_METALNESSMAP
59
+ #if defined( USE_METALNESSMAP_UV )
48
60
 
49
61
  vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
50
62
 
51
63
  #endif
52
- #ifdef USE_ROUGHNESSMAP
64
+ #if defined( USE_ROUGHNESSMAP_UV )
53
65
 
54
66
  vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
55
67
 
@@ -59,6 +59,7 @@ import logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.g
59
59
  import logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js';
60
60
  import logdepthbuf_vertex from './ShaderChunk/logdepthbuf_vertex.glsl.js';
61
61
  import map_fragment from './ShaderChunk/map_fragment.glsl.js';
62
+ import triplanar_fragment from './ShaderChunk/triplanar_fragment.glsl.js';
62
63
  import map_pars_fragment from './ShaderChunk/map_pars_fragment.glsl.js';
63
64
  import map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';
64
65
  import map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';
@@ -186,6 +187,7 @@ export const ShaderChunk = {
186
187
  logdepthbuf_pars_vertex: logdepthbuf_pars_vertex,
187
188
  logdepthbuf_vertex: logdepthbuf_vertex,
188
189
  map_fragment: map_fragment,
190
+ triplanar_fragment: triplanar_fragment,
189
191
  map_pars_fragment: map_pars_fragment,
190
192
  map_particle_fragment: map_particle_fragment,
191
193
  map_particle_pars_fragment: map_particle_pars_fragment,