Shader compatibility fixes for GLSL ES

deque
scrawl 11 years ago
parent 31d058b98c
commit fdc6dd6985

@ -33,7 +33,7 @@
SH_START_PROGRAM SH_START_PROGRAM
{ {
shOutputColour(0) = alphaFade * atmosphereColour + (1.f - alphaFade) * horizonColour; shOutputColour(0) = alphaFade * atmosphereColour + (1.0 - alphaFade) * horizonColour;
} }
#endif #endif

@ -25,7 +25,7 @@
shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition)); shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition));
UV = uv0; UV = uv0;
alphaFade = (shInputPosition.z <= 200.f) ? ((shInputPosition.z <= 100.f) ? 0.0 : 0.25) : 1.0; alphaFade = (shInputPosition.z <= 200.0) ? ((shInputPosition.z <= 100.0) ? 0.0 : 0.25) : 1.0;
} }
#else #else

@ -14,7 +14,7 @@
SH_START_PROGRAM SH_START_PROGRAM
{ {
shOutputPosition = float4(shInputPosition.xyz, 1.f); shOutputPosition = float4(shInputPosition.xyz, 1.0);
#if TEXTURE #if TEXTURE
UV.xy = uv0; UV.xy = uv0;
#endif #endif

@ -210,11 +210,11 @@
#if VERTEXCOLOR_MODE == 2 #if VERTEXCOLOR_MODE == 2
lightResult.xyz += colour.xyz * lightDiffuse[@shIterator].xyz lightResult.xyz += colour.xyz * lightDiffuse[@shIterator].xyz
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d))) * shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
* max(dot(viewNormal.xyz, lightDir), 0); * max(dot(viewNormal.xyz, lightDir), 0.0);
#else #else
lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d))) * shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
* max(dot(viewNormal.xyz, lightDir), 0); * max(dot(viewNormal.xyz, lightDir), 0.0);
#endif #endif
#if @shIterator == 0 #if @shIterator == 0
@ -432,11 +432,11 @@
#if VERTEXCOLOR_MODE == 2 #if VERTEXCOLOR_MODE == 2
lightResult.xyz += colourPassthrough.xyz * lightDiffuse[@shIterator].xyz lightResult.xyz += colourPassthrough.xyz * lightDiffuse[@shIterator].xyz
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d))) * shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
* max(dot(viewNormal.xyz, lightDir), 0); * max(dot(viewNormal.xyz, lightDir), 0.0);
#else #else
lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d))) * shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
* max(dot(viewNormal.xyz, lightDir), 0); * max(dot(viewNormal.xyz, lightDir), 0.0);
#endif #endif
#if @shIterator == 0 #if @shIterator == 0
@ -504,8 +504,8 @@
#if ENV_MAP #if ENV_MAP
// Everything looks better with fresnel // Everything looks better with fresnel
float facing = 1.0 - max(abs(dot(-eyeDir, normal)), 0); float facing = 1.0 - max(abs(dot(-eyeDir, normal)), 0.0);
float envFactor = shSaturate(0.25 + 0.75 * pow(facing, 1)); float envFactor = shSaturate(0.25 + 0.75 * pow(facing, 1.0));
shOutputColour(0).xyz += shSample(envMap, UV.zw).xyz * envFactor * env_map_color; shOutputColour(0).xyz += shSample(envMap, UV.zw).xyz * envFactor * env_map_color;
#endif #endif
@ -513,7 +513,7 @@
#if SPECULAR #if SPECULAR
float3 light0Dir = normalize(lightPosObjSpace0.xyz); float3 light0Dir = normalize(lightPosObjSpace0.xyz);
float NdotL = max(dot(normal, light0Dir), 0); float NdotL = max(dot(normal, light0Dir), 0.0);
float3 halfVec = normalize (light0Dir + eyeDir); float3 halfVec = normalize (light0Dir + eyeDir);
float shininess = matShininess; float shininess = matShininess;
@ -522,7 +522,7 @@
shininess *= (specTex.a); shininess *= (specTex.a);
#endif #endif
float3 specular = pow(max(dot(normal, halfVec), 0), shininess) * lightSpec0 * matSpec; float3 specular = pow(max(dot(normal, halfVec), 0.0), shininess) * lightSpec0 * matSpec;
#if SPEC_MAP #if SPEC_MAP
specular *= specTex.xyz; specular *= specTex.xyz;
#else #else

@ -175,7 +175,7 @@
lightResult.xyz += lightDiffuse[@shIterator].xyz lightResult.xyz += lightDiffuse[@shIterator].xyz
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d))) * shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
* max(dot(normal.xyz, lightDir), 0); * max(dot(normal.xyz, lightDir), 0.0);
#if @shIterator == 0 #if @shIterator == 0
directionalResult = lightResult.xyz; directionalResult = lightResult.xyz;
@ -310,7 +310,7 @@ shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position)
#if !IS_FIRST_PASS #if !IS_FIRST_PASS
// Opacity the previous passes should have, i.e. 1 - (opacity of this pass) // Opacity the previous passes should have, i.e. 1 - (opacity of this pass)
float previousAlpha = 1.f; float previousAlpha = 1.0;
#endif #endif
@ -334,7 +334,7 @@ float2 blendUV = (UV - 0.5) * (16.0 / (16.0+1.0)) + 0.5;
float4 albedo = float4(0,0,0,1); float4 albedo = float4(0,0,0,1);
float2 layerUV = float2(UV.x, 1.f-UV.y) * 16; // Reverse Y, required to get proper tangents float2 layerUV = float2(UV.x, 1.0-UV.y) * 16.0; // Reverse Y, required to get proper tangents
float2 thisLayerUV; float2 thisLayerUV;
float4 normalTex; float4 normalTex;
float4 diffuseTex; float4 diffuseTex;
@ -349,9 +349,9 @@ float2 blendUV = (UV - 0.5) * (16.0 / (16.0+1.0)) + 0.5;
#if @shPropertyBool(use_normal_map_@shIterator) #if @shPropertyBool(use_normal_map_@shIterator)
normalTex = shSample(normalMap@shIterator, thisLayerUV); normalTex = shSample(normalMap@shIterator, thisLayerUV);
#if @shIterator == 0 && IS_FIRST_PASS #if @shIterator == 0 && IS_FIRST_PASS
TSnormal = normalize(normalTex.xyz * 2 - 1); TSnormal = normalize(normalTex.xyz * 2.0 - 1.0);
#else #else
TSnormal = shLerp(TSnormal, normalTex.xyz * 2 - 1, blendValues@shPropertyString(blendmap_component_@shIterator)); TSnormal = shLerp(TSnormal, normalTex.xyz * 2.0 - 1.0, blendValues@shPropertyString(blendmap_component_@shIterator));
#endif #endif
#endif #endif
@ -361,7 +361,7 @@ float2 blendUV = (UV - 0.5) * (16.0 / (16.0+1.0)) + 0.5;
diffuseTex = shSample(diffuseMap@shIterator, layerUV); diffuseTex = shSample(diffuseMap@shIterator, layerUV);
#if !@shPropertyBool(use_specular_@shIterator) #if !@shPropertyBool(use_specular_@shIterator)
diffuseTex.a = 0; diffuseTex.a = 0.0;
#endif #endif
#if @shIterator == 0 #if @shIterator == 0
@ -371,7 +371,7 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
#endif #endif
#if !IS_FIRST_PASS #if !IS_FIRST_PASS
previousAlpha *= 1.f-blendValues@shPropertyString(blendmap_component_@shIterator); previousAlpha *= 1.0-blendValues@shPropertyString(blendmap_component_@shIterator);
#endif #endif
@ -404,7 +404,7 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
lightResult.xyz += lightDiffuse[@shIterator].xyz lightResult.xyz += lightDiffuse[@shIterator].xyz
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d))) * shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
* max(dot(normal.xyz, lightDir), 0); * max(dot(normal.xyz, lightDir), 0.0);
#if @shIterator == 0 #if @shIterator == 0
float3 directionalResult = lightResult.xyz; float3 directionalResult = lightResult.xyz;
#endif #endif
@ -444,10 +444,10 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
// Specular // Specular
float3 light0Dir = normalize(lightPos0.xyz); float3 light0Dir = normalize(lightPos0.xyz);
float NdotL = max(dot(normal, light0Dir), 0); float NdotL = max(dot(normal, light0Dir), 0.0);
float3 halfVec = normalize (light0Dir + eyeDir); float3 halfVec = normalize (light0Dir + eyeDir);
float3 specular = pow(max(dot(normal, halfVec), 0), 32) * lightSpec0; float3 specular = pow(max(dot(normal, halfVec), 0.0), 32.0) * lightSpec0;
shOutputColour(0).xyz += specular * (albedo.a) * shadow; shOutputColour(0).xyz += specular * (albedo.a) * shadow;
#endif #endif
@ -465,9 +465,9 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0)); shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
#if IS_FIRST_PASS #if IS_FIRST_PASS
shOutputColour(0).a = 1; shOutputColour(0).a = 1.0;
#else #else
shOutputColour(0).a = 1.f-previousAlpha; shOutputColour(0).a = 1.0-previousAlpha;
#endif #endif
} }

Loading…
Cancel
Save