Tiny shader optimization

pull/3/head
Hleb Valoshka 2020-01-12 14:34:00 +03:00
parent 87a551ede7
commit 908daf95cf
1 changed files with 2 additions and 1 deletions

View File

@ -1818,13 +1818,14 @@ ShaderManager::buildVertexShader(const ShaderProperties& props)
if (props.hasRingShadows()) if (props.hasRingShadows())
{ {
source += "vec3 ringShadowProj;\n"; source += "vec3 ringShadowProj;\n";
source += "float t = -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w);\n";
for (unsigned int j = 0; j < props.nLights; j++) for (unsigned int j = 0; j < props.nLights; j++)
{ {
if (props.hasRingShadowForLight(j)) if (props.hasRingShadowForLight(j))
{ {
source += "ringShadowProj = gl_Vertex.xyz + " + source += "ringShadowProj = gl_Vertex.xyz + " +
LightProperty(j, "direction") + LightProperty(j, "direction") +
" * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(" + " * max(0.0, t / dot(" +
LightProperty(j, "direction") + ", ringPlane.xyz));\n"; LightProperty(j, "direction") + ", ringPlane.xyz));\n";
source += RingShadowTexCoord(j) + source += RingShadowTexCoord(j) +