Shader compatibility fixes for GLSL ES

deque
scrawl 11 years ago
parent 31d058b98c
commit fdc6dd6985

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

@ -25,7 +25,7 @@
shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition));
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

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

@ -210,11 +210,11 @@
#if VERTEXCOLOR_MODE == 2
lightResult.xyz += colour.xyz * lightDiffuse[@shIterator].xyz
* 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
lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
* 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
#if @shIterator == 0
@ -432,11 +432,11 @@
#if VERTEXCOLOR_MODE == 2
lightResult.xyz += colourPassthrough.xyz * lightDiffuse[@shIterator].xyz
* 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
lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
* 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
#if @shIterator == 0
@ -504,8 +504,8 @@
#if ENV_MAP
// Everything looks better with fresnel
float facing = 1.0 - max(abs(dot(-eyeDir, normal)), 0);
float envFactor = shSaturate(0.25 + 0.75 * pow(facing, 1));
float facing = 1.0 - max(abs(dot(-eyeDir, normal)), 0.0);
float envFactor = shSaturate(0.25 + 0.75 * pow(facing, 1.0));
shOutputColour(0).xyz += shSample(envMap, UV.zw).xyz * envFactor * env_map_color;
#endif
@ -513,7 +513,7 @@
#if SPECULAR
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);
float shininess = matShininess;
@ -522,7 +522,7 @@
shininess *= (specTex.a);
#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
specular *= specTex.xyz;
#else

@ -175,7 +175,7 @@
lightResult.xyz += lightDiffuse[@shIterator].xyz
* 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
directionalResult = lightResult.xyz;
@ -310,7 +310,7 @@ shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position)
#if !IS_FIRST_PASS
// Opacity the previous passes should have, i.e. 1 - (opacity of this pass)
float previousAlpha = 1.f;
float previousAlpha = 1.0;
#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);
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;
float4 normalTex;
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)
normalTex = shSample(normalMap@shIterator, thisLayerUV);
#if @shIterator == 0 && IS_FIRST_PASS
TSnormal = normalize(normalTex.xyz * 2 - 1);
TSnormal = normalize(normalTex.xyz * 2.0 - 1.0);
#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
@ -361,7 +361,7 @@ float2 blendUV = (UV - 0.5) * (16.0 / (16.0+1.0)) + 0.5;
diffuseTex = shSample(diffuseMap@shIterator, layerUV);
#if !@shPropertyBool(use_specular_@shIterator)
diffuseTex.a = 0;
diffuseTex.a = 0.0;
#endif
#if @shIterator == 0
@ -371,7 +371,7 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
#endif
#if !IS_FIRST_PASS
previousAlpha *= 1.f-blendValues@shPropertyString(blendmap_component_@shIterator);
previousAlpha *= 1.0-blendValues@shPropertyString(blendmap_component_@shIterator);
#endif
@ -404,7 +404,7 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
lightResult.xyz += lightDiffuse[@shIterator].xyz
* 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
float3 directionalResult = lightResult.xyz;
#endif
@ -444,10 +444,10 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
// Specular
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 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;
#endif
@ -465,9 +465,9 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
#if IS_FIRST_PASS
shOutputColour(0).a = 1;
shOutputColour(0).a = 1.0;
#else
shOutputColour(0).a = 1.f-previousAlpha;
shOutputColour(0).a = 1.0-previousAlpha;
#endif
}

Loading…
Cancel
Save