Skip to content

Commit

Permalink
Updated lighting formula
Browse files Browse the repository at this point in the history
(cherry picked from commit 1970bcd)
  • Loading branch information
XorDev authored and leo60228 committed Jan 2, 2023
1 parent 4502e82 commit c712044
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shaders/gbuffers_textured.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void main()
//Use flat for flat "blocks" or world space normal for solid blocks.
normal = (mc_Entity==1.) ? vec3(0,1,0) : (gbufferModelViewInverse * vec4(normal,0)).xyz;

//Calculate simple lighting. Note: This as close as I (XorDev) could get, but it's not perfect!
float light = .8-.25*abs(normal.x*.9+normal.z*.3)+normal.y*.2;
//Calculate simple lighting. Thanks to @PepperCode1
float light = min(normal.x * normal.x * 0.6f + normal.y * normal.y * 0.25f * (3.0f + normal.y) + normal.z * normal.z * 0.8f, 1.0f);

//Output color with lighting to fragment shader.
color = vec4(gl_Color.rgb * light, gl_Color.a);
Expand Down

0 comments on commit c712044

Please sign in to comment.