Commit c06d633a authored by NiranV's avatar NiranV
Browse files

Fixed: Shininess being broken since EEP. Fix by Drake.

parent 54943693
......@@ -871,10 +871,10 @@ void LLTexUnit::setTextureColorSpace(eTextureColorSpace space)
}
}
else
#endif
{
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
}
#endif
}
LLLightState::LLLightState(S32 index)
......
......@@ -410,6 +410,7 @@ void main()
vec3 light = vec3(0, 0, 0);
final_specular.rgb = srgb_to_linear(final_specular.rgb);
#define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w );
LIGHT_LOOP(1)
......
......@@ -33,10 +33,8 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
......@@ -75,9 +73,7 @@ void main()
vec3 norm = getNorm(frag.xy);
vec4 spec = texture2DRect(specularRect, frag.xy);
spec.rgb = srgb_to_linear(spec.rgb);
vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
diff.rgb = srgb_to_linear(diff.rgb);
float noise = texture2D(noiseMap, frag.xy / 128.0).b;
vec3 npos = normalize(-pos);
......
......@@ -40,9 +40,6 @@ out vec4 frag_color;
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
......@@ -71,7 +68,7 @@ VARYING vec4 vary_fragcoord;
uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
vec3 getNormWithEnvIntensity(vec2 screenpos, out float envIntensity);
vec3 srgb_to_linear(vec3 c);
uniform float global_light_strength;
......@@ -151,8 +148,8 @@ void main()
discard;
}
float envIntensity = texture2DRect(normalMap, frag.xy).z;
vec3 norm = getNorm(frag.xy);
float envIntensity;
vec3 norm = getNormWithEnvIntensity(frag.xy, envIntensity);
float l_dist = -dot(lv, proj_n);
......@@ -184,10 +181,6 @@ void main()
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
// SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space.
// We can't switch to linear here unless we do it everywhere*
// *gbuffer is sRGB, convert to linear whenever sampling from it
diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
vec3 dlit = vec3(0, 0, 0);
......@@ -228,7 +221,6 @@ void main()
vec4 spec = texture2DRect(specularRect, frag.xy);
if (spec.a > 0.0)
{
dlit *= min(da*6.0, 1.0) * dist_atten;
......
......@@ -35,11 +35,8 @@ out vec4 frag_color;
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
uniform sampler2DRect depthMap;
uniform vec3 env_mat[3];
uniform float sun_wash;
......@@ -92,7 +89,6 @@ void main()
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 col = texture2DRect(diffuseRect, frag.xy).rgb;
col.rgb = srgb_to_linear(col.rgb);
float fa = falloff+1.0;
float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
......
......@@ -37,7 +37,6 @@ out vec4 frag_color;
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform sampler2DRect lightMap;
uniform sampler2DRect depthMap;
uniform samplerCube environmentMap;
uniform sampler2D lightFunc;
......@@ -56,7 +55,7 @@ VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
vec3 getNorm(vec2 pos_screen);
vec3 decode_normal(vec2 enc);
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
......@@ -106,7 +105,7 @@ void main()
vec4 pos = getPositionWithDepth(tc, depth);
vec4 norm = texture2DRect(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = getNorm(tc);
norm.xyz = decode_normal(norm.xy);
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
......@@ -115,21 +114,25 @@ void main()
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
vec2 fromCentre = vec2(0.0);
if(chroma_str > 0.0)
{
fromCentre = (tc / screen_res) - vec2(0.5);
float radius = length(fromCentre);
fromCentre = (chroma_str * (radius*radius)) / vec2(1);
diffuse.b= texture2DRect(diffuseRect, tc-fromCentre).b;
diffuse.r= texture2DRect(diffuseRect, tc+fromCentre).r;
diffuse.ga= texture2DRect(diffuseRect, tc).ga;
}
diffuse.b= texture2DRect(diffuseRect, tc-fromCentre).b;
diffuse.r= texture2DRect(diffuseRect, tc+fromCentre).r;
diffuse.ga= texture2DRect(diffuseRect, tc).ga;
//convert to gamma space
diffuse.rgb = linear_to_srgb(diffuse.rgb);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
vec3 color = vec3(0);
float bloom = 0.0;
......@@ -225,7 +228,7 @@ void main()
refapprop = min(refapprop, angleapprop);
float refshad = texture2DRect(lightMap, ref2d).r;
refshad = pow(refshad, light_gamma);
vec3 refn = getNorm(ref2d);
vec3 refn = decode_normal(ref2d);
// darken reflections from points which face away from the reflected ray - our guess was a back-face
//refapprop = min(refapprop, step(dot(refnorm, refn), 0.001));
......
......@@ -72,7 +72,7 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 srgb_to_linear(vec3 cs);
vec3 getNorm(vec2 pos_screen);
vec3 getNormWithEnvIntensity(vec2 screenpos, out float envIntensity);
uniform float global_light_strength;
......@@ -162,13 +162,9 @@ void main()
shadow = clamp(shadow, 0.0, 1.0);
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
float envIntensity;
vec3 norm = getNormWithEnvIntensity(frag.xy, envIntensity);
norm = getNorm(frag.xy);
norm = normalize(norm);
float l_dist = -dot(lv, proj_n);
vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
......@@ -193,11 +189,6 @@ void main()
float da = dot(norm, lv);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
// SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space.
// We can't switch to linear here unless we do it everywhere*
// *gbuffer IS sRGB, convert to linear since this shader outputs linear
diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0);
......
......@@ -56,7 +56,6 @@ VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
vec3 getNorm(vec2 pos_screen);
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
......@@ -66,6 +65,7 @@ vec3 scaleSoftClipFrag(vec3 l);
vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten);
vec3 fullbrightScaleSoftClip(vec3 light);
vec3 decode_normal(vec2 enc);
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
......@@ -106,7 +106,7 @@ void main()
vec4 pos = getPositionWithDepth(tc, depth);
vec4 norm = texture2DRect(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = getNorm(tc);
norm.xyz = decode_normal(norm.xy);
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
......@@ -114,7 +114,6 @@ void main()
da = pow(da, light_gamma);
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 fromCentre = vec2(0.0);
if(chroma_str > 0.0)
......@@ -122,10 +121,16 @@ void main()
fromCentre = (tc / screen_res) - vec2(0.5);
float radius = length(fromCentre);
fromCentre = (chroma_str * (radius*radius)) / vec2(1);
diffuse.b = texture2DRect(diffuseRect, tc-fromCentre).b;
diffuse.r = texture2DRect(diffuseRect, tc+fromCentre).r;
diffuse.ga = texture2DRect(diffuseRect, tc).ga;
}
diffuse.b = texture2DRect(diffuseRect, tc-fromCentre).b;
diffuse.r = texture2DRect(diffuseRect, tc+fromCentre).r;
diffuse.ga = texture2DRect(diffuseRect, tc).ga;
//convert to gamma space
diffuse.rgb = linear_to_srgb(diffuse.rgb);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
......@@ -220,7 +225,7 @@ void main()
refapprop = min(refapprop, angleapprop);
float refshad = texture2DRect(lightMap, ref2d).r;
refshad = pow(refshad, light_gamma);
vec3 refn = getNorm(ref2d);
vec3 refn = decode_normal(ref2d);
// darken reflections from points which face away from the reflected ray - our guess was a back-face
//refapprop = min(refapprop, step(dot(refnorm, refn), 0.001));
......
......@@ -36,9 +36,6 @@ out vec4 frag_color;
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform samplerCube environmentMap;
uniform sampler2DRect lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
......@@ -71,7 +68,7 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
vec3 getNormWithEnvIntensity(vec2 screenpos, out float envIntensity);
vec3 srgb_to_linear(vec3 c);
uniform float global_light_strength;
......@@ -162,11 +159,9 @@ void main()
shadow = clamp(shadow, 0.0, 1.0);
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = getNorm(frag.xy);
norm = normalize(norm);
float envIntensity;
vec3 norm = getNormWithEnvIntensity(frag.xy, envIntensity);
float l_dist = -dot(lv, proj_n);
vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
......@@ -191,7 +186,7 @@ void main()
lv = normalize(lv);
float da = dot(norm, lv);
vec3 diff_tex = srgb_to_linear(texture2DRect(diffuseRect, frag.xy).rgb);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0);
......
......@@ -71,7 +71,7 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
vec3 getNormWithEnvIntensity(vec2 screenpos, out float envIntensity);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
......@@ -151,13 +151,9 @@ void main()
shadow = clamp(shadow, 0.0, 1.0);
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
float envIntensity;
vec3 norm = getNormWithEnvIntensity(frag.xy, envIntensity);
norm = getNorm(frag.xy);
norm = normalize(norm);
float l_dist = -dot(lv, proj_n);
vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
......
......@@ -79,6 +79,8 @@ vec4 getPositionWithDepth(vec2 pos_screen, float depth);
vec4 getPosition(vec2 pos_screen);
vec3 getNorm(vec2 pos_screen);
vec3 decode_normal(vec2 enc);
#ifdef WATER_FOG
vec4 applyWaterFogView(vec3 pos, vec4 color);
#endif
......@@ -90,7 +92,7 @@ void main()
vec3 pos = getPositionWithDepth(tc, depth).xyz;
vec4 norm = texture2DRect(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = getNorm(tc);
norm.xyz = decode_normal(norm.xy);
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
......
......@@ -71,7 +71,7 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
vec3 getNormWithEnvIntensity(vec2 screenpos, out float envIntensity);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
......@@ -151,11 +151,9 @@ void main()
shadow = clamp(shadow, 0.0, 1.0);
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = getNorm(frag.xy);
norm = normalize(norm);
float envIntensity;
vec3 norm = getNormWithEnvIntensity(frag.xy, envIntensity);
float l_dist = -dot(lv, proj_n);
vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment