increased terrain diffuse texture limit to 12, including normals

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7759 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 14 years ago
parent 619dd39e1c
commit d9c3df086d
  1. 166
      engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.frag
  2. 32
      engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.j3md

@ -38,6 +38,18 @@ varying vec4 vnLightDir;
#ifdef DIFFUSEMAP_7
uniform sampler2D m_DiffuseMap_7;
#endif
#ifdef DIFFUSEMAP_8
uniform sampler2D m_DiffuseMap_8;
#endif
#ifdef DIFFUSEMAP_9
uniform sampler2D m_DiffuseMap_9;
#endif
#ifdef DIFFUSEMAP_10
uniform sampler2D m_DiffuseMap_10;
#endif
#ifdef DIFFUSEMAP_11
uniform sampler2D m_DiffuseMap_11;
#endif
#ifdef DIFFUSEMAP_0_SCALE
@ -64,6 +76,18 @@ varying vec4 vnLightDir;
#ifdef DIFFUSEMAP_7_SCALE
uniform float m_DiffuseMap_7_scale;
#endif
#ifdef DIFFUSEMAP_8_SCALE
uniform float m_DiffuseMap_8_scale;
#endif
#ifdef DIFFUSEMAP_9_SCALE
uniform float m_DiffuseMap_9_scale;
#endif
#ifdef DIFFUSEMAP_10_SCALE
uniform float m_DiffuseMap_10_scale;
#endif
#ifdef DIFFUSEMAP_11_SCALE
uniform float m_DiffuseMap_11_scale;
#endif
#ifdef ALPHAMAP
@ -100,6 +124,18 @@ varying vec4 vnLightDir;
#ifdef NORMALMAP_7
uniform sampler2D m_NormalMap_7;
#endif
#ifdef NORMALMAP_8
uniform sampler2D m_NormalMap_8;
#endif
#ifdef NORMALMAP_9
uniform sampler2D m_NormalMap_9;
#endif
#ifdef NORMALMAP_10
uniform sampler2D m_NormalMap_10;
#endif
#ifdef NORMALMAP_11
uniform sampler2D m_NormalMap_11;
#endif
#ifdef TRI_PLANAR_MAPPING
@ -160,6 +196,9 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
#ifdef ALPHAMAP_1
vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
#endif
#ifdef ALPHAMAP_2
vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
#endif
vec4 diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
diffuseColor *= alphaBlend.r;
@ -185,6 +224,24 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
#ifdef DIFFUSEMAP_7
vec4 diffuseColor7 = texture2D(m_DiffuseMap_7, texCoord * m_DiffuseMap_7_scale);
diffuseColor = mix( diffuseColor, diffuseColor7, alphaBlend1.a );
#ifdef ALPHAMAP_2
#ifdef DIFFUSEMAP_8
vec4 diffuseColor8 = texture2D(m_DiffuseMap_8, texCoord * m_DiffuseMap_8_scale);
diffuseColor = mix( diffuseColor, diffuseColor8, alphaBlend2.r );
#ifdef DIFFUSEMAP_9
vec4 diffuseColor9 = texture2D(m_DiffuseMap_9, texCoord * m_DiffuseMap_9_scale);
diffuseColor = mix( diffuseColor, diffuseColor9, alphaBlend2.g );
#ifdef DIFFUSEMAP_10
vec4 diffuseColor10 = texture2D(m_DiffuseMap_10, texCoord * m_DiffuseMap_10_scale);
diffuseColor = mix( diffuseColor, diffuseColor10, alphaBlend2.b );
#ifdef DIFFUSEMAP_11
vec4 diffuseColor11 = texture2D(m_DiffuseMap_11, texCoord * m_DiffuseMap_11_scale);
diffuseColor = mix( diffuseColor, diffuseColor11, alphaBlend2.a );
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
@ -206,6 +263,9 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
#ifdef ALPHAMAP_1
vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
#endif
#ifdef ALPHAMAP_2
vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
#endif
#ifdef NORMALMAP
normalHeight = texture2D(m_NormalMap, texCoord * m_DiffuseMap_0_scale);
@ -265,7 +325,7 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
#endif
#ifdef NORMALMAP_7
normalHeight = texture2D(m_NormalMap_7, texCoord * m_DiffuseMap_67_scale);
normalHeight = texture2D(m_NormalMap_7, texCoord * m_DiffuseMap_7_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
@ -273,6 +333,40 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
#endif
#endif
#ifdef ALPHAMAP_2
#ifdef NORMALMAP_8
normalHeight = texture2D(m_NormalMap_8, texCoord * m_DiffuseMap_8_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.r;
#endif
#ifdef NORMALMAP_9
normalHeight = texture2D(m_NormalMap_9, texCoord * m_DiffuseMap_9_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.g;
#endif
#ifdef NORMALMAP_10
normalHeight = texture2D(m_NormalMap_10, texCoord * m_DiffuseMap_10_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.b;
#endif
#ifdef NORMALMAP_11
normalHeight = texture2D(m_NormalMap_11, texCoord * m_DiffuseMap_11_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.a;
#endif
#endif
return normalize(normal);
}
@ -329,12 +423,31 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
// blend the results of the 3 planar projections.
vec4 tex7 = getTriPlanarBlend(coords, blending, m_DiffuseMap_7, m_DiffuseMap_7_scale);
#endif
#ifdef DIFFUSEMAP_8
// blend the results of the 3 planar projections.
vec4 tex8 = getTriPlanarBlend(coords, blending, m_DiffuseMap_8, m_DiffuseMap_8_scale);
#endif
#ifdef DIFFUSEMAP_9
// blend the results of the 3 planar projections.
vec4 tex9 = getTriPlanarBlend(coords, blending, m_DiffuseMap_9, m_DiffuseMap_9_scale);
#endif
#ifdef DIFFUSEMAP_10
// blend the results of the 3 planar projections.
vec4 tex10 = getTriPlanarBlend(coords, blending, m_DiffuseMap_10, m_DiffuseMap_10_scale);
#endif
#ifdef DIFFUSEMAP_11
// blend the results of the 3 planar projections.
vec4 tex11 = getTriPlanarBlend(coords, blending, m_DiffuseMap_11, m_DiffuseMap_11_scale);
#endif
vec4 alphaBlend = texture2D( m_AlphaMap, texCoord.xy );
#ifdef ALPHAMAP_1
vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
#endif
#ifdef ALPHAMAP_2
vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
#endif
vec4 diffuseColor = tex0 * alphaBlend.r;
#ifdef DIFFUSEMAP_1
@ -352,6 +465,20 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
diffuseColor = mix( diffuseColor, tex6, alphaBlend1.b );
#ifdef DIFFUSEMAP_7
diffuseColor = mix( diffuseColor, tex7, alphaBlend1.a );
#ifdef ALPHAMAP_2
#ifdef DIFFUSEMAP_8
diffuseColor = mix( diffuseColor, tex8, alphaBlend2.r );
#ifdef DIFFUSEMAP_9
diffuseColor = mix( diffuseColor, tex9, alphaBlend2.g );
#ifdef DIFFUSEMAP_10
diffuseColor = mix( diffuseColor, tex10, alphaBlend2.b );
#ifdef DIFFUSEMAP_11
diffuseColor = mix( diffuseColor, tex11, alphaBlend2.a );
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
@ -379,6 +506,9 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
#ifdef ALPHAMAP_1
vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
#endif
#ifdef ALPHAMAP_2
vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
#endif
vec3 normal = vec3(0,0,1);
vec3 n = vec3(0,0,0);
@ -450,6 +580,40 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
#endif
#endif
#ifdef ALPHAMAP_2
#ifdef NORMALMAP_8
normalHeight = getTriPlanarBlend(coords, blending, m_NormalMap_8, m_DiffuseMap_8_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.r;
#endif
#ifdef NORMALMAP_9
normalHeight = getTriPlanarBlend(coords, blending, m_NormalMap_9, m_DiffuseMap_9_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.g;
#endif
#ifdef NORMALMAP_10
normalHeight = getTriPlanarBlend(coords, blending, m_NormalMap_10, m_DiffuseMap_10_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.b;
#endif
#ifdef NORMALMAP_11
normalHeight = getTriPlanarBlend(coords, blending, m_NormalMap_11, m_DiffuseMap_11_scale);
n = (normalHeight.xyz * vec3(2.0) - vec3(1.0));
n.z = sqrt(1.0 - (n.x * n.x) - (n.y * n.y));
n.y = -n.y;
normal += n * alphaBlend2.a;
#endif
#endif
return normalize(normal);
}
#endif

@ -60,6 +60,26 @@ MaterialDef Terrain Lighting {
Float DiffuseMap_7_scale
Texture2D NormalMap_7
// Texture map #8
Texture2D DiffuseMap_8
Float DiffuseMap_8_scale
Texture2D NormalMap_8
// Texture map #9
Texture2D DiffuseMap_9
Float DiffuseMap_9_scale
Texture2D NormalMap_9
// Texture map #10
Texture2D DiffuseMap_10
Float DiffuseMap_10_scale
Texture2D NormalMap_10
// Texture map #11
Texture2D DiffuseMap_11
Float DiffuseMap_11_scale
Texture2D NormalMap_11
// Specular/gloss map
Texture2D SpecularMap
@ -103,6 +123,10 @@ MaterialDef Terrain Lighting {
DIFFUSEMAP_5 : DiffuseMap_5
DIFFUSEMAP_6 : DiffuseMap_6
DIFFUSEMAP_7 : DiffuseMap_7
DIFFUSEMAP_8 : DiffuseMap_8
DIFFUSEMAP_9 : DiffuseMap_9
DIFFUSEMAP_10 : DiffuseMap_10
DIFFUSEMAP_11 : DiffuseMap_11
NORMALMAP : NormalMap
NORMALMAP_1 : NormalMap_1
NORMALMAP_2 : NormalMap_2
@ -111,6 +135,10 @@ MaterialDef Terrain Lighting {
NORMALMAP_5 : NormalMap_5
NORMALMAP_6 : NormalMap_6
NORMALMAP_7 : NormalMap_7
NORMALMAP_8 : NormalMap_8
NORMALMAP_9 : NormalMap_9
NORMALMAP_10 : NormalMap_10
NORMALMAP_11 : NormalMap_11
SPECULARMAP : SpecularMap
ALPHAMAP : AlphaMap
ALPHAMAP_1 : AlphaMap_1
@ -123,6 +151,10 @@ MaterialDef Terrain Lighting {
DIFFUSEMAP_5_SCALE : DiffuseMap_5_scale
DIFFUSEMAP_6_SCALE : DiffuseMap_6_scale
DIFFUSEMAP_7_SCALE : DiffuseMap_7_scale
DIFFUSEMAP_8_SCALE : DiffuseMap_8_scale
DIFFUSEMAP_9_SCALE : DiffuseMap_9_scale
DIFFUSEMAP_10_SCALE : DiffuseMap_10_scale
DIFFUSEMAP_11_SCALE : DiffuseMap_11_scale
}
}

Loading…
Cancel
Save