Added alpha blending option to terrain lightings to allow alpha stencil textures. (#689)
Updated Terrain materials to allow diffuse textures with alpha
This commit is contained in:
parent
c6f1da0602
commit
edd9a78291
@ -160,36 +160,60 @@ varying vec2 texCoord;
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP
|
||||
diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.r *= diffuseColor.a;
|
||||
#endif
|
||||
diffuseColor *= alphaBlend.r;
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_1
|
||||
vec4 diffuseColor1 = texture2D(m_DiffuseMap_1, texCoord * m_DiffuseMap_1_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.g *= diffuseColor1.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor1, alphaBlend.g );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_2
|
||||
vec4 diffuseColor2 = texture2D(m_DiffuseMap_2, texCoord * m_DiffuseMap_2_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.b *= diffuseColor2.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor2, alphaBlend.b );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_3
|
||||
vec4 diffuseColor3 = texture2D(m_DiffuseMap_3, texCoord * m_DiffuseMap_3_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.a *= diffuseColor3.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor3, alphaBlend.a );
|
||||
#endif
|
||||
|
||||
#ifdef ALPHAMAP_1
|
||||
#ifdef DIFFUSEMAP_4
|
||||
vec4 diffuseColor4 = texture2D(m_DiffuseMap_4, texCoord * m_DiffuseMap_4_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.r *= diffuseColor4.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor4, alphaBlend1.r );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_5
|
||||
vec4 diffuseColor5 = texture2D(m_DiffuseMap_5, texCoord * m_DiffuseMap_5_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.g *= diffuseColor5.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor5, alphaBlend1.g );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_6
|
||||
vec4 diffuseColor6 = texture2D(m_DiffuseMap_6, texCoord * m_DiffuseMap_6_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.b *= diffuseColor6.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor6, alphaBlend1.b );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_7
|
||||
vec4 diffuseColor7 = texture2D(m_DiffuseMap_7, texCoord * m_DiffuseMap_7_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.a *= diffuseColor7.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor7, alphaBlend1.a );
|
||||
#endif
|
||||
#endif
|
||||
@ -197,18 +221,30 @@ varying vec2 texCoord;
|
||||
#ifdef ALPHAMAP_2
|
||||
#ifdef DIFFUSEMAP_8
|
||||
vec4 diffuseColor8 = texture2D(m_DiffuseMap_8, texCoord * m_DiffuseMap_8_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.r *= diffuseColor8.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor8, alphaBlend2.r );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_9
|
||||
vec4 diffuseColor9 = texture2D(m_DiffuseMap_9, texCoord * m_DiffuseMap_9_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.g *= diffuseColor9.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor9, alphaBlend2.g );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_10
|
||||
vec4 diffuseColor10 = texture2D(m_DiffuseMap_10, texCoord * m_DiffuseMap_10_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.b *= diffuseColor10.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor10, alphaBlend2.b );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_11
|
||||
vec4 diffuseColor11 = texture2D(m_DiffuseMap_11, texCoord * m_DiffuseMap_11_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.a *= diffuseColor11.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor11, alphaBlend2.a );
|
||||
#endif
|
||||
#endif
|
||||
@ -614,4 +650,4 @@ void main(){
|
||||
SpecularSum.rgb * vec3(light.y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -161,36 +161,60 @@ varying vec3 lightVec;
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP
|
||||
diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.r *= diffuseColor.a;
|
||||
#endif
|
||||
diffuseColor *= alphaBlend.r;
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_1
|
||||
vec4 diffuseColor1 = texture2D(m_DiffuseMap_1, texCoord * m_DiffuseMap_1_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.g *= diffuseColor1.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor1, alphaBlend.g );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_2
|
||||
vec4 diffuseColor2 = texture2D(m_DiffuseMap_2, texCoord * m_DiffuseMap_2_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.b *= diffuseColor2.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor2, alphaBlend.b );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_3
|
||||
vec4 diffuseColor3 = texture2D(m_DiffuseMap_3, texCoord * m_DiffuseMap_3_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend.a *= diffuseColor3.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor3, alphaBlend.a );
|
||||
#endif
|
||||
|
||||
#ifdef ALPHAMAP_1
|
||||
#ifdef DIFFUSEMAP_4
|
||||
vec4 diffuseColor4 = texture2D(m_DiffuseMap_4, texCoord * m_DiffuseMap_4_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.r *= diffuseColor4.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor4, alphaBlend1.r );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_5
|
||||
vec4 diffuseColor5 = texture2D(m_DiffuseMap_5, texCoord * m_DiffuseMap_5_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.g *= diffuseColor5.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor5, alphaBlend1.g );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_6
|
||||
vec4 diffuseColor6 = texture2D(m_DiffuseMap_6, texCoord * m_DiffuseMap_6_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.b *= diffuseColor6.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor6, alphaBlend1.b );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_7
|
||||
vec4 diffuseColor7 = texture2D(m_DiffuseMap_7, texCoord * m_DiffuseMap_7_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend1.a *= diffuseColor7.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor7, alphaBlend1.a );
|
||||
#endif
|
||||
#endif
|
||||
@ -198,18 +222,30 @@ varying vec3 lightVec;
|
||||
#ifdef ALPHAMAP_2
|
||||
#ifdef DIFFUSEMAP_8
|
||||
vec4 diffuseColor8 = texture2D(m_DiffuseMap_8, texCoord * m_DiffuseMap_8_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.r *= diffuseColor8.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor8, alphaBlend2.r );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_9
|
||||
vec4 diffuseColor9 = texture2D(m_DiffuseMap_9, texCoord * m_DiffuseMap_9_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.g *= diffuseColor9.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor9, alphaBlend2.g );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_10
|
||||
vec4 diffuseColor10 = texture2D(m_DiffuseMap_10, texCoord * m_DiffuseMap_10_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.b *= diffuseColor10.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor10, alphaBlend2.b );
|
||||
#endif
|
||||
#ifdef DIFFUSEMAP_11
|
||||
vec4 diffuseColor11 = texture2D(m_DiffuseMap_11, texCoord * m_DiffuseMap_11_scale);
|
||||
#ifdef USE_ALPHA
|
||||
alphaBlend2.a *= diffuseColor11.a;
|
||||
#endif
|
||||
diffuseColor = mix( diffuseColor, diffuseColor11, alphaBlend2.a );
|
||||
#endif
|
||||
#endif
|
||||
@ -616,4 +652,4 @@ void main(){
|
||||
SpecularSum * specularColor * light.y;
|
||||
|
||||
//gl_FragColor.a = alpha;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ MaterialDef Terrain Lighting {
|
||||
|
||||
// Are we rendering TerrainGrid
|
||||
Boolean isTerrainGrid
|
||||
|
||||
// Use diffuse alpha when mixing
|
||||
Boolean useDiffuseAlpha
|
||||
|
||||
// Ambient color
|
||||
Color Ambient
|
||||
@ -160,6 +163,8 @@ MaterialDef Terrain Lighting {
|
||||
DIFFUSEMAP_9_SCALE : DiffuseMap_9_scale
|
||||
DIFFUSEMAP_10_SCALE : DiffuseMap_10_scale
|
||||
DIFFUSEMAP_11_SCALE : DiffuseMap_11_scale
|
||||
|
||||
USE_ALPHA : useDiffuseAlpha
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,6 +228,8 @@ MaterialDef Terrain Lighting {
|
||||
DIFFUSEMAP_9_SCALE : DiffuseMap_9_scale
|
||||
DIFFUSEMAP_10_SCALE : DiffuseMap_10_scale
|
||||
DIFFUSEMAP_11_SCALE : DiffuseMap_11_scale
|
||||
|
||||
USE_ALPHA : useDiffuseAlpha
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,4 +296,4 @@ MaterialDef Terrain Lighting {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user