Limit the number of light rendered to the maximum set per surface

This commit is contained in:
Emile Belanger 2021-05-05 21:12:56 +01:00
parent e17be2d135
commit 7252f9c3f1
3 changed files with 13 additions and 5 deletions

View file

@ -110,6 +110,17 @@ bool FGLRenderState::ApplyShader()
subLights = (int(lightPtr[2]) - int(lightPtr[1])) / LIGHT_VEC4_NUM;
addLights = (int(lightPtr[3]) - int(lightPtr[2])) / LIGHT_VEC4_NUM;
// Here we limit the number of lights, but dont' change the light data so priority has to be mod, sub then add
if (modLights > gles.maxlights)
modLights = gles.maxlights;
if (modLights + subLights > gles.maxlights)
subLights = gles.maxlights - modLights;
if (modLights + subLights + addLights > gles.maxlights)
addLights = gles.maxlights - modLights - subLights;
// Skip passed the first 4 floats so the upload below only contains light data
lightPtr += 4;
}

View file

@ -169,15 +169,13 @@ namespace OpenGLESRenderer
gles.depthStencilAvailable = CheckExtension("GL_OES_packed_depth_stencil");
gles.npotAvailable = CheckExtension("GL_OES_texture_npot");
gles.maxuniforms = 1024 * 16;
gles.max_texturesize = 1024 * 4;
gles.max_texturesize = 1024 * 2;
#else
gles.depthStencilAvailable = true;
gles.npotAvailable = true;
gles.useMappedBuffers = true;
gles.maxuniforms = 1024 * 16;
gles.max_texturesize = 1024 * 4;
gles.max_texturesize = 1024 * 2;
#endif
gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM);

View file

@ -63,7 +63,6 @@ namespace OpenGLESRenderer
struct RenderContextGLES
{
unsigned int flags;
unsigned int maxuniforms;
unsigned int maxlights;
unsigned int numlightvectors;
bool useMappedBuffers;