Changeset 4985


Ignore:
Timestamp:
02/28/16 14:44:17 (4 years ago)
Author:
beherith
Message:

BAR: deferred_lighting.glsl fix specular highlights

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/BAR/shaders/deferred_lighting.glsl

    r4765 r4985  
    9696        vec3 viewDirection = normalize(vec3(eyePos - mappos4.xyz)); 
    9797         
    98         if (dot(map_normals4.xyz, light_direction) > 0.0) // light source on the wrong side? 
     98        if (dot(map_normals4.xyz, light_direction) > 0.02) // light source on the wrong side? 
    9999        { 
    100                 specularHighlight = specularHighlight * (0.5* pow(max(0.0, dot(reflect( -light_direction, map_normals4.xyz), viewDirection)), 8)); 
     100                vec3 reflection = reflect(-1.0 * light_direction, map_normals4.xyz); 
     101                float highlight = pow(max(0.0, dot( reflection, viewDirection)), 8); 
     102                specularHighlight = specularHighlight * (0.5* highlight); 
     103        }else{ 
     104                specularHighlight = 0.0; 
    101105        } 
    102          
    103106        //OK, our blending func is the following: Rr=Lr*Dr+1*Dr 
    104107        float lightalpha = cosphi * attentuation + attentuation * specularHighlight; 
     
    108111        #ifdef DEBUG 
    109112                gl_FragColor = vec4(map_normals4.xyz, 1); //world normals debugging 
    110                 gl_FragColor = vec4(fract(modelpos4.z * 0.01), 
    111                                                         sign(mappos4.z - modelpos4.z), 0, 1); //world pos debugging, very useful 
     113                gl_FragColor = vec4(fract(modelpos4.z * 0.01),sign(mappos4.z - modelpos4.z), 0, 1); //world pos debugging, very useful 
    112114                if (length(lightcolor.rgb * lightalpha * model_lighting_multiplier) < (1.0 / 256.0)){ //shows light boudaries 
    113115                        gl_FragColor=vec4(vec3(0.5, 0.0, 0.5), 0.0); 
Note: See TracChangeset for help on using the changeset viewer.