2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-14 06:46:09 +00:00

Working CLight

This commit is contained in:
Jack Andersen
2016-04-03 19:02:09 -10:00
parent dae2621d93
commit 408ce2ca8b
7 changed files with 39 additions and 31 deletions

View File

@@ -1,4 +1,5 @@
#include "CModelShaders.hpp"
#include "hecl/Backend/GLSL.hpp"
namespace urde
{
@@ -27,14 +28,14 @@ static const char* LightingGLSL =
" {\n"
" vec3 delta = mvPosIn.xyz - lights[i].pos.xyz;\n"
" float dist = length(delta);\n"
" float angDot = dot(normalize(delta), lights[i].dir.xyz);\n"
" float angDot = clamp(dot(normalize(delta), lights[i].dir.xyz), 0.0, 1.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 * dot(normalize(-delta), mvNormIn.xyz);\n"
" ret += lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn.xyz), 0.0, 1.0);\n"
" }\n"
" \n"
" return clamp(ret, vec4(0.0,0.0,0.0,0.0), vec4(1.0,1.0,1.0,1.0));\n"
@@ -43,8 +44,11 @@ static const char* LightingGLSL =
hecl::Runtime::ShaderCacheExtensions
CModelShaders::GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat)
{
static const char* BlockNames[] = {HECL_GLSL_VERT_UNIFORM_BLOCK_NAME,
HECL_GLSL_TEXMTX_UNIFORM_BLOCK_NAME,
"LightingUniform"};
hecl::Runtime::ShaderCacheExtensions ext(plat);
ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {});
ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {}, 3, BlockNames);
return ext;
}