No matter what I set cubemode to, the shader gets treated as if the line “If (cubemode>0)” always returns true. The shader evaluates a cubemap for materials that don’t have one, so it fails and those surfaces aren’t drawn. Even if I change it to “If (cubemode=9999)” or any number, it ignores the If statement at line 94:
uniform sampler2D basetexture;
uniform sampler2D lightmap;
uniform sampler2D bumpmap;
uniform sampler2D glowmap;
uniform samplerCube cubemap;
uniform int lightmapenabled;
uniform int bumpmapenabled;
uniform int glowmapenabled;
uniform int cubemode;
uniform float bumpstrength;
varying vec3 ReflectDir;
//varying vec4 VecToCamera;
//varying vec4 normal;
//uniform vec4 cameraposition;
//varying vec4 VecToCamera;
//varying vec3 normal;
void main (void)
{
vec4 diffusecolor;
vec4 lightcolor;
vec4 bumpcolor;
vec4 cubecolor;
vec4 color;
//=================================
//Base Texture
//=================================
diffusecolor=texture2D(basetexture,gl_TexCoord[0].xy);
//=================================
//
//=================================
//=================================
//Lighting
//=================================
if (lightmapenabled==1)
{
lightcolor=texture2D(lightmap, gl_TexCoord[2].xy);
}
else
{
lightcolor=gl_Color;
}
//=================================
//
//=================================
//=================================
//Bumpmap
//=================================
if (bumpmapenabled==1)
{
vec4 bumpmapcolor=texture2D(bumpmap,gl_TexCoord[0].xy);
//bumpcolor=vec4(strength*((bumpmapcolor.r-0.5)*(gl_TexCoord[1].x-0.5)+(bumpmapcolor.g-0.5)*(gl_TexCoord[1].y-0.5)+(0.5/strength)));
bumpcolor=vec4(bumpstrength*((bumpmapcolor.r-0.5)*(gl_TexCoord[1].x-0.5)+(bumpmapcolor.g-0.5)*(gl_TexCoord[1].y-0.5)+(0.5/bumpstrength)));
}
else
{
bumpcolor=vec4(0.5);
}
//=================================
//
//=================================
//=================================
//Mix Base, Light, and Bump Colors
//=================================
color=diffusecolor*lightcolor*bumpcolor*4.0;
color=clamp(color,0.0,1.0);
//=================================
//
//=================================
//=================================
//Cubemap
//=================================
if (cubemode>0)
{
cubecolor=vec4(textureCube(cubemap,ReflectDir));
color=(color*diffusecolor.a)+(cubecolor*(1.0-diffusecolor.a));
}
//cubecolor=vec4(textureCube(cubemap,ReflectDir));
//vec4 DirToCamera = normalize(VecToCamera);
//vec4 nnormal = vec4(normalize(normal).x,normalize(normal).y,normalize(normal).z,1.0);
//vec3 reflectDir = normalize(reflect(DirToCamera, nnormal));
//=================================
//
//=================================
//=================================
//Glowmap
//=================================
if (glowmapenabled==1)
{
color=color+texture2D(glowmap,gl_TexCoord[0].xy);
}
//=================================
//
//=================================
//=================================
//Restore base alpha and clamp final color
//=================================
color.a=diffusecolor.a;
gl_FragColor=clamp(color,0.0,1.0);
//=================================
//
//=================================
}