Skip to content

Commit

Permalink
Reorganise for a micro-optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Jul 14, 2023
1 parent fdf9b13 commit bf29ce8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/ammonite/graphics/renderCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ namespace ammonite {

for (unsigned int i = 0; i < drawObjectData->meshes.size(); i++) {
//Set texture for regular shading pass
if (lightIndex == -1 and !depthPass) {
glBindTextureUnit(0, drawObject->textureIds[i]);
if (!depthPass) {
if (lightIndex == -1) {
glBindTextureUnit(0, drawObject->textureIds[i]);
}
}

//Bind vertex attribute buffer
Expand Down Expand Up @@ -732,13 +734,13 @@ namespace ammonite {
glUniform1i(modelShader.lightCountId, activeLights);
drawModels(AMMONITE_RENDER_PASS);

//Get information about light sources to be rendered
//Swap to the light emitting model shader
int lightEmitterCount = ammonite::lighting::internal::getLightEmitterCount();
int lightData[lightEmitterCount * 2];
ammonite::lighting::internal::getLightEmitters(lightData);

//Swap to the light emitting model shader
if (lightEmitterCount > 0) {
//Get information about light sources to be rendered
ammonite::lighting::internal::getLightEmitters(lightData);

glUseProgram(lightShader.shaderId);

//Draw light sources with models attached
Expand Down

0 comments on commit bf29ce8

Please sign in to comment.