Skip to content

Commit df76532

Browse files
author
Rémy Bouquet
committed
Fixed warnings in Terrain shader.
Fixed the use of the first diffuse map Fixed the camera positioning in the TestSpotLightTerrain
1 parent d1b125e commit df76532

File tree

4 files changed

+11
-29
lines changed

4 files changed

+11
-29
lines changed

jme3-examples/src/main/java/jme3test/light/TestSpotLightTerrain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void simpleInitApp() {
9898
ambLight.setColor(ColorRGBA.Black);
9999
rootNode.addLight(ambLight);
100100

101-
cam.setLocation(new Vector3f(-41.219646f, -84.8363f, -171.67267f));
101+
cam.setLocation(new Vector3f(-41.219646f, 0.8363f, -171.67267f));
102102
cam.setRotation(new Quaternion(-0.04562731f, 0.89917684f, -0.09668826f, -0.4243236f));
103103
sl.setDirection(cam.getDirection());
104104
sl.setPosition(cam.getLocation());

jme3-terrain/src/main/resources/Common/MatDefs/Terrain/SPTerrainLighting.frag

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,18 @@ varying vec2 texCoord;
150150

151151
vec4 calculateDiffuseBlend(in vec2 texCoord) {
152152
vec4 alphaBlend = texture2D( m_AlphaMap, texCoord.xy );
153+
vec4 diffuseColor = vec4(1.0);
153154

154155
#ifdef ALPHAMAP_1
155156
vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
156157
#endif
157158
#ifdef ALPHAMAP_2
158159
vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
159160
#endif
160-
161-
vec4 diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
162-
diffuseColor *= alphaBlend.r;
161+
#ifdef DIFFUSEMAP
162+
diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
163+
diffuseColor *= alphaBlend.r;
164+
#endif
163165
#ifdef DIFFUSEMAP_1
164166
vec4 diffuseColor1 = texture2D(m_DiffuseMap_1, texCoord * m_DiffuseMap_1_scale);
165167
diffuseColor = mix( diffuseColor, diffuseColor1, alphaBlend.g );

jme3-terrain/src/main/resources/Common/MatDefs/Terrain/TerrainLighting.frag

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,18 @@ varying vec3 lightVec;
151151

152152
vec4 calculateDiffuseBlend(in vec2 texCoord) {
153153
vec4 alphaBlend = texture2D( m_AlphaMap, texCoord.xy );
154+
vec4 diffuseColor = vec4(1.0);
154155

155156
#ifdef ALPHAMAP_1
156157
vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
157158
#endif
158159
#ifdef ALPHAMAP_2
159160
vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
160161
#endif
161-
162-
vec4 diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
163-
diffuseColor *= alphaBlend.r;
162+
#ifdef DIFFUSEMAP
163+
diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
164+
diffuseColor *= alphaBlend.r;
165+
#endif
164166
#ifdef DIFFUSEMAP_1
165167
vec4 diffuseColor1 = texture2D(m_DiffuseMap_1, texCoord * m_DiffuseMap_1_scale);
166168
diffuseColor = mix( diffuseColor, diffuseColor1, alphaBlend.g );

jme3-terrain/src/main/resources/Common/MatDefs/Terrain/TerrainLighting.j3md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -272,29 +272,7 @@ MaterialDef Terrain Lighting {
272272

273273
}
274274

275-
Technique GBuf {
276275

277-
VertexShader GLSL100: Common/MatDefs/Light/GBuf.vert
278-
FragmentShader GLSL100: Common/MatDefs/Light/GBuf.frag
279-
280-
WorldParameters {
281-
WorldViewProjectionMatrix
282-
WorldMatrix
283-
}
284-
285-
Defines {
286-
VERTEX_COLOR : UseVertexColor
287-
MATERIAL_COLORS : UseMaterialColors
288-
V_TANGENT : VTangent
289-
MINNAERT : Minnaert
290-
WARDISO : WardIso
291-
292-
DIFFUSEMAP : DiffuseMap
293-
NORMALMAP : NormalMap
294-
SPECULARMAP : SpecularMap
295-
PARALLAXMAP : ParallaxMap
296-
}
297-
}
298276

299277
Technique Glow {
300278

0 commit comments

Comments
 (0)