mirror of https://github.com/AxioDL/metaforce.git
Consistent lighting clamping
This commit is contained in:
parent
cf9062bba5
commit
89906be162
|
@ -77,14 +77,15 @@ FOG_STRUCT_GLSL
|
|||
" {\n"
|
||||
" vec3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = clamp(dot(normalize(delta), 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), mvNormIn), 0.0, 1.0);\n"
|
||||
" ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return clamp(ret, 0.0, 1.0);\n"
|
||||
|
@ -127,31 +128,33 @@ static std::string_view LightingShadowGLSL =
|
|||
" \n"
|
||||
" vec3 delta = mvPosIn - lights[0].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = clamp(dot(normalize(delta), lights[0].dir.xyz), 0.0, 1.0);\n"
|
||||
" vec3 deltaNorm = delta / dist;\n"
|
||||
" float angDot = max(dot(deltaNorm, lights[0].dir.xyz), 0.0);\n"
|
||||
" float att = 1.0 / (lights[0].linAtt[2] * dist * dist +\n"
|
||||
" lights[0].linAtt[1] * dist +\n"
|
||||
" lights[0].linAtt[0]);\n"
|
||||
" float angAtt = lights[0].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[0].angAtt[1] * angDot +\n"
|
||||
" lights[0].angAtt[0];\n"
|
||||
" ret += lights[0].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0) *\n"
|
||||
" ret += lights[0].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0) *\n"
|
||||
" texture(extTex7, shadowUV).r;\n"
|
||||
" \n"
|
||||
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" vec3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = clamp(dot(normalize(delta), 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 * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), 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"sv;
|
||||
|
||||
static std::string_view MainPostGLSL =
|
||||
|
|
|
@ -86,7 +86,7 @@ FOG_STRUCT_HLSL
|
|||
" ret += lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return ret;\n"
|
||||
" return saturate(ret);\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view LightingShadowHLSL =
|
||||
|
|
|
@ -86,7 +86,7 @@ FOG_STRUCT_METAL
|
|||
" ret += lu.lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return ret;\n"
|
||||
" return saturate(ret);\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view LightingShadowMetal =
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue