2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Consistent lighting clamping

This commit is contained in:
Jack Andersen
2019-01-29 10:14:34 -10:00
parent cf9062bba5
commit 89906be162
6 changed files with 18 additions and 14 deletions

View File

@@ -203,17 +203,18 @@ static const char* FS =
" {\n"
" vec3 delta = mvPosIn - lights[i].pos.xyz;\n"
" float dist = length(delta);\n"
" float angDot = clamp(dot(normalize(delta).xyz, lights[i].dir.xyz), 0.0, 1.0);\n"
" vec3 deltaNorm = delta / dist;\n"
" float angDot = max(dot(deltaNorm, lights[i].dir.xyz), 0.0);\n"
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
" lights[i].linAtt[1] * dist +\n"
" lights[i].linAtt[0]);\n"
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n"
" ret += lights[i].color * angAtt * att * clamp(dot(normalize(-delta).xyz, mvNormIn), 0.0, 1.0);\n"
" ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0);\n"
" }\n"
" \n"
" return ret;\n"
" return clamp(ret, 0.0, 1.0);\n"
"}\n"
"\n"
"struct VertToFrag\n"

View File

@@ -249,7 +249,7 @@ static const char* FS =
" ret += lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n"
" \n"
" return ret;\n"
" return saturate(ret);\n"
"}\n"
"\n"
"struct VertToFrag\n"

View File

@@ -233,7 +233,7 @@ static const char* FS =
" ret += lu.lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n"
" \n"
" return ret;\n"
" return saturate(ret);\n"
"}\n"
"\n"
"struct VertToFrag\n"