Skip to content

Commit

Permalink
[dataflow-rendering] update shader code for envlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Mar 24, 2023
1 parent 51b90e1 commit 974aec1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Dataflow/Rendering/Shaders/EnvLightNode/shader.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ void main() {
vec2 size = textureSize( amb_occ_sampler, 0 ).xy;
vec3 ao = texture( amb_occ_sampler, gl_FragCoord.xy / size ).rgb;
bc.rgb = diffuse;
bc.r *= dot( normalWorld, redShCoeffs * normalWorld );
bc.g *= dot( normalWorld, greenShCoeffs * normalWorld );
bc.b *= dot( normalWorld, blueShCoeffs * normalWorld );
vec3 irradiance = vec3(
dot( normalWorld, redShCoeffs * normalWorld ),
dot( normalWorld, greenShCoeffs * normalWorld ),
dot( normalWorld, blueShCoeffs * normalWorld )
);
bc.rgb *= irradiance / OneOverPi;
// Specular envmap
float cosTi = clamp( dot( rfl, normalWorld.xyz ), 0.001, 1. );
vec3 spec = clamp( specular * cosTi * OneOverPi * 0.5, 0.001, 1. );
Expand Down

0 comments on commit 974aec1

Please sign in to comment.