Skip to content

Commit 3c5eb5c

Browse files
authored
Update TriPlanarUtils.glsllib
1 parent 24f6bb2 commit 3c5eb5c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

jme3-core/src/main/resources/Common/ShaderLib/TriPlanarUtils.glsllib

+10-12
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,28 @@
4343
vec4 col2 = texture2D( map, coords.xz * scale);
4444
vec4 col3 = texture2D( map, coords.xy * scale);
4545

46-
col1.xyz = col1.xyz * vec3(2.0) - vec3(1.0);
47-
col2.xyz = col2.xyz * vec3(2.0) - vec3(1.0);
48-
col3.xyz = col3.xyz * vec3(2.0) - vec3(1.0);
46+
col1.xyz = col1.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0);
47+
col2.xyz = col2.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0);
48+
col3.xyz = col3.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0);
4949

5050
// blend the results of the 3 planar projections.
5151
vec4 tex = normalize(col1 * triBlending.x + col2 * triBlending.y + col3 * triBlending.z);
52-
tex.y *= NORMAL_TYPE;
5352

5453
return tex;
5554
}
5655

5756
// triplanar blend for Normal maps in a TextureArray:
5857
vec4 getTriPlanarNormalBlendFromTexArray(in vec3 coords, in int idInTexArray, in float scale, in sampler2DArray texArray) {
59-
vec4 col1 = texture2DArray( texArray, vec3((coords.yz * scale), idInTexArray ) );
60-
vec4 col2 = texture2DArray( texArray, vec3((coords.xz * scale), idInTexArray ) );
61-
vec4 col3 = texture2DArray( texArray, vec3((coords.xy * scale), idInTexArray ) );
58+
vec4 col1 = texture2DArray( texArray, vec3((coords.yz * scale), idInTexArray ));
59+
vec4 col2 = texture2DArray( texArray, vec3((coords.xz * scale), idInTexArray ));
60+
vec4 col3 = texture2DArray( texArray, vec3((coords.xy * scale), idInTexArray ));
6261

63-
col1.xyz = col1.xyz * vec3(2.0) - vec3(1.0);
64-
col2.xyz = col2.xyz * vec3(2.0) - vec3(1.0);
65-
col3.xyz = col3.xyz * vec3(2.0) - vec3(1.0);
62+
col1.xyz = col1.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0);
63+
col2.xyz = col2.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0);
64+
col3.xyz = col3.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0);
6665

6766
// blend the results of the 3 planar projections.
68-
vec4 tex = normalize(col1 * triBlending.x + col2 * triBlending.y + col3 * triBlending.z);
69-
tex.y *= NORMAL_TYPE;
67+
vec4 tex = normalize(col1 * triBlending.x + col2 * triBlending.y + col3 * triBlending.z);
7068

7169
return tex;
7270
}

0 commit comments

Comments
 (0)