Skip to content

Commit

Permalink
fix: normals and changed diffuse falloff
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTroble committed Jan 21, 2024
1 parent 3c6fccf commit 6075ce4
Show file tree
Hide file tree
Showing 6 changed files with 898 additions and 886 deletions.
10 changes: 6 additions & 4 deletions TGEngine/assets/lightPass.frag
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
" vec3 normal = normalize(subpassLoad(NORMAL).rgb);",
" vec3 pos = subpassLoad(POSITION).rgb;",
" vec2 roughnessMetallic = subpassLoad(ROUGHNESS_METALLIC).rg;",
" vec3 multiplier = vec3(0.2f, 0.2f, 0.2f);",
" vec3 multiplier = vec3(0.1f, 0.1f, 0.1f);",
" for(int x = 0; x < lights.lightCount; x++) {",
" Light lightInfo = lights.light[x];",
" vec3 l = normalize(lightInfo.pos);",
" float refl = dot(normal, l);",
" multiplier += abs(lightInfo.color * refl * lightInfo.intensity);",
" vec3 distance = pos - lightInfo.pos;",
" float distanceFallof = 1/dot(distance, distance);",
" vec3 l = normalize(distance);",
" float ratio = max(0, dot(normal, l));",
" multiplier += lightInfo.color * ratio * distanceFallof * lightInfo.intensity;",
" }",
" colorout = vec4(color * multiplier, 1);",
"}"
Expand Down
Loading

0 comments on commit 6075ce4

Please sign in to comment.