fixes for shaders glsles

deque
sylar 10 years ago
parent 4c46da79de
commit 3a625c567d

@ -47,7 +47,7 @@
// Scroll in y direction
float2 scrolledUV = UV + float2(0,1) * cloudAnimationTimer * 0.003;
float4 albedo = shSample(diffuseMap1, scrolledUV) * (1-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor;
float4 albedo = shSample(diffuseMap1, scrolledUV) * (1.0-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor;
shOutputColour(0) = float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity * alphaFade);
}

@ -45,8 +45,8 @@ shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix)
shOutputColour(0).a = shSample(alphaMap, UV).a * materialDiffuse.a;
shOutputColour(0).rgb += (1-tex.a) * shOutputColour(0).a * atmosphereColour.rgb; //fill dark side of moon with atmosphereColour
shOutputColour(0).rgb += (1-materialDiffuse.a) * atmosphereColour.rgb; //fade bump
shOutputColour(0).rgb += (1.0-tex.a) * shOutputColour(0).a * atmosphereColour.rgb; //fill dark side of moon with atmosphereColour
shOutputColour(0).rgb += (1.0-materialDiffuse.a) * atmosphereColour.rgb; //fade bump
}

@ -21,7 +21,7 @@
depth.y = shOutputPosition.w;
// clamp z to zero. seem to do the trick. :-/
shOutputPosition.z = max(shOutputPosition.z, 0);
shOutputPosition.z = max(shOutputPosition.z, 0.0);
#if ALPHA
UV = uv0;
@ -49,7 +49,7 @@
discard;
#endif
shOutputColour(0) = float4(finalDepth, finalDepth, finalDepth, 1);
shOutputColour(0) = float4(finalDepth, finalDepth, finalDepth, 1.0);
}
#endif

@ -14,19 +14,19 @@
{
float4x4 worldviewFixed = worldview;
#if !SH_GLSL
worldviewFixed[0][3] = 0;
worldviewFixed[1][3] = 0;
worldviewFixed[2][3] = 0;
worldviewFixed[0][3] = 0.0;
worldviewFixed[1][3] = 0.0;
worldviewFixed[2][3] = 0.0;
#else
worldviewFixed[3][0] = 0;
worldviewFixed[3][1] = 0;
worldviewFixed[3][2] = 0;
worldviewFixed[3][0] = 0.0;
worldviewFixed[3][1] = 0.0;
worldviewFixed[3][2] = 0.0;
#endif
shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition));
UV = uv0;
fade = (shInputPosition.z > 50) ? 1 : 0;
fade = (shInputPosition.z > 50.0) ? 1.0 : 0.0;
}
#else

@ -102,10 +102,10 @@
#if !SH_GLSL
float4x4 scalemat = float4x4( 0.5, 0, 0, 0.5,
0, -0.5, 0, 0.5,
0, 0, 0.5, 0.5,
0, 0, 0, 1 );
float4x4 scalemat = float4x4( 0.5, 0.0, 0.0, 0.5,
0.0, -0.5, 0.0, 0.5,
0.0, 0.0, 0.5, 0.5,
0.0, 0.0, 0.0, 1.0 );
#else
mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0,
0.0, -0.5, 0.0, 0.0,
@ -148,7 +148,7 @@
#define SMALL_WAVES_Y 0.1
#define WAVE_CHOPPYNESS 0.15 // wave choppyness
#define WAVE_SCALE 75 // overall wave scale
#define WAVE_SCALE 75.0 // overall wave scale
#define BUMP 1.5 // overall water surface bumpiness
#define REFL_BUMP 0.08 // reflection distortion amount
@ -159,7 +159,7 @@
#define SUN_EXT float3(0.45, 0.55, 0.68) //sunlight extinction
#define SPEC_HARDNESS 256 // specular highlights hardness
#define SPEC_HARDNESS 256.0 // specular highlights hardness
// ---------------------------------------------------------------
@ -260,7 +260,7 @@
#if SHADOWS || SHADOWS_PSSM
float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y;
float fade = 1-((depthPassthrough - shadowFar_fadeStart.y) / fadeRange);
float fade = 1.0-((depthPassthrough - shadowFar_fadeStart.y) / fadeRange);
shadow = (depthPassthrough > shadowFar_fadeStart.x) ? 1.0 : ((depthPassthrough > shadowFar_fadeStart.y) ? 1.0-((1.0-shadow)*fade) : shadow);
#endif
@ -270,9 +270,9 @@
float2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
screenCoords.y = (1-shSaturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
screenCoords.y = (1.0-shSaturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
float2 nCoord = float2(0,0);
float2 nCoord = float2(0.0,0.0);
nCoord = UV * (WAVE_SCALE * 0.05) + WIND_DIR * waterTimer * (WIND_SPEED*0.04);
float3 normal0 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.015,-waterTimer*0.005)).rgb - 1.0;
@ -297,7 +297,7 @@
float4 worldPosition = shMatrixMult(wMat, float4(position.xyz, 1));
float2 relPos = (worldPosition.xy - rippleCenter.xy) / rippleAreaLength + 0.5;
float3 normal_ripple = normalize(shSample(rippleNormalMap, relPos.xy).xyz * 2 - 1);
float3 normal_ripple = normalize(shSample(rippleNormalMap, relPos.xy).xyz * 2.0 - 1.0);
//normal = normalize(normal + normal_ripple);
normal = normalize(float3(normal.x * BUMP + normal_ripple.x, normal.y * BUMP + normal_ripple.y, normal.z));
@ -315,7 +315,7 @@
float3 vVec = normalize(position.xyz - cameraPos.xyz);
float isUnderwater = (cameraPos.z > 0) ? 0.0 : 1.0;
float isUnderwater = (cameraPos.z > 0.0) ? 0.0 : 1.0;
// sunlight scattering
float3 pNormal = float3(0,0,1);
@ -327,7 +327,7 @@
float3 scatterColour = shLerp(float3(SCATTER_COLOUR)*float3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
// fresnel
float ior = (cameraPos.z>0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
float ior = (cameraPos.z>0.0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
float fresnel = fresnel_dielectric(-vVec, normal, ior);
fresnel = shSaturate(fresnel);
@ -342,7 +342,7 @@
float3 refraction = shSample(refractionMap, (screenCoords-(normal.xy*REFR_BUMP))*1.0).rgb;
// brighten up the refraction underwater
refraction = (cameraPos.z < 0) ? shSaturate(refraction * 1.5) : refraction;
refraction = (cameraPos.z < 0.0) ? shSaturate(refraction * 1.5) : refraction;
#endif
// specular
@ -358,9 +358,9 @@
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue);
#if REFRACTION
shOutputColour(0).w = 1;
shOutputColour(0).w = 1.0;
#else
shOutputColour(0).w = shSaturate(fresnel*2 + specular);
shOutputColour(0).w = shSaturate(fresnel*2.0 + specular);
#endif
}

Loading…
Cancel
Save