diff options
author | Dave Houlton <euclid@lindenlab.com> | 2020-02-07 22:46:46 +0000 |
---|---|---|
committer | Dave Houlton <euclid@lindenlab.com> | 2020-02-07 22:46:46 +0000 |
commit | 90e3974b165b8baa2e0b76fe7469910852d77624 (patch) | |
tree | ebc861920c2955a10e308a5d5087484c7d442015 /indra | |
parent | 3adbc44a072bbce9be08ea863cdea336ddb55444 (diff) | |
parent | 8e0d5f463edc24101ecdcb420c05f6d5b0e6b6c0 (diff) |
Merged in SL-12682 (pull request #8)
Fixes for SL-12682 and SL-12592
Approved-by: Michael Pohoreski
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 8a6b2b7066..d28fc128b6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -249,24 +249,25 @@ void main() vec4 spec = vec4(specular_color.rgb, 1.0); #endif - vec4 norm = vec4(0,0,0,1.0); - vec3 tnorm; + vec3 norm = vec3(0); + float bmap_specular = 1.0; #ifdef HAS_NORMAL_MAP - norm = texture2D(bumpMap, vary_texcoord1.xy); - norm.xyz = norm.xyz * 2 - 1; - - // tangent space norm - tnorm = vec3(dot(norm.xyz,vary_mat0), - dot(norm.xyz,vary_mat1), - dot(norm.xyz,vary_mat2)); + vec4 bump_sample = texture2D(bumpMap, vary_texcoord1.xy); + norm = (bump_sample.xyz * 2) - vec3(1); + bmap_specular = bump_sample.w; + + // convert sampled normal to tangent space normal + norm = vec3(dot(norm, vary_mat0), + dot(norm, vary_mat1), + dot(norm, vary_mat2)); #else - tnorm = vary_normal; + norm = vary_normal; #endif - norm.xyz = normalize(tnorm.xyz); + norm = normalize(norm); - vec2 abnormal = encode_normal(norm.xyz); + vec2 abnormal = encode_normal(norm); vec4 final_color = vec4(diffuse_linear.rgb, 0.0); @@ -311,13 +312,13 @@ void main() final_specular.a = specular_color.a; #ifdef HAS_SPECULAR_MAP - final_specular.a *= norm.a; + final_specular.a *= bmap_specular; final_normal.z *= spec.a; #endif #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - if (emissive_brightness < 1.0) + if (emissive_brightness <= 1.0) { //forward rendering, output just lit RGBA vec3 pos = vary_position; @@ -325,7 +326,7 @@ void main() float shadow = 1.0f; #ifdef HAS_SUN_SHADOW - shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, pos_screen); + shadow = sampleDirectionalShadow(pos.xyz, norm, pos_screen); #endif spec = final_specular; @@ -342,18 +343,17 @@ void main() calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - + vec3 refnormpersp = normalize(reflect(pos.xyz, norm)); - float da = dot(norm.xyz, normalize(light_dir.xyz)); - float final_da = clamp(da, 0.0, 1.0); + float da = dot(norm, normalize(light_dir)); + da = clamp(da, 0.0, 1.0); // No negative light contributions float ambient = da; ambient *= 0.5; ambient *= ambient; ambient = (1.0 - ambient); - vec3 sun_contrib = min(final_da, shadow) * sunlit; + vec3 sun_contrib = min(da, shadow) * sunlit; // vec3 debug_sun_contrib = sun_contrib; @@ -383,8 +383,8 @@ void main() //vec3 ref = dot(pos+lv, norm); vec3 h = normalize(light_dir.xyz+npos); - float nh = dot(norm.xyz, h); - float nv = dot(norm.xyz, npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); float vh = dot(npos, h); float sa = nh; float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; @@ -435,7 +435,7 @@ void main() vec3 light = vec3(0,0,0); -#define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.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 ); +#define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.rgb, final_specular, pos.xyz, norm, 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) LIGHT_LOOP(2) @@ -461,7 +461,7 @@ void main() //color.rgb = vec3(ambient); //color.rgb = sunlit; //color.rgb = debug_post_ambient; -//color.rgb = vec3(final_da); +//color.rgb = vec3(da); //color.rgb = debug_sun_contrib; //color.rgb = debug_post_sunlight; //color.rgb = diffuse_srgb.rgb; |