diff --git a/data/shader/quad.vert b/data/shader/quad.vert index 953048866..59cbe008e 100644 --- a/data/shader/quad.vert +++ b/data/shader/quad.vert @@ -9,6 +9,8 @@ uniform mat4x2 gPos; uniform vec2 gOffsets[TW_MAX_QUADS]; uniform float gRotations[TW_MAX_QUADS]; +uniform int gQuadOffset; + noperspective out vec4 QuadColor; flat out int QuadIndex; #ifdef TW_QUAD_TEXTURED @@ -19,7 +21,7 @@ void main() { vec2 FinalPos = vec2(inVertex.xy); - int TmpQuadIndex = int(gl_VertexID / 4); + int TmpQuadIndex = int(gl_VertexID / 4) - gQuadOffset; if(gRotations[TmpQuadIndex] != 0.0) { diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 5d73902b7..8ddff6f87 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -2348,6 +2348,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand m_pQuadProgram->m_LocColors = m_pQuadProgram->GetUniformLoc("gVertColors"); m_pQuadProgram->m_LocRotations = m_pQuadProgram->GetUniformLoc("gRotations"); m_pQuadProgram->m_LocOffsets = m_pQuadProgram->GetUniformLoc("gOffsets"); + m_pQuadProgram->m_LocQuadOffset = m_pQuadProgram->GetUniformLoc("gQuadOffset"); } { CGLSL VertexShader; @@ -2370,6 +2371,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand m_pQuadProgramTextured->m_LocColors = m_pQuadProgramTextured->GetUniformLoc("gVertColors"); m_pQuadProgramTextured->m_LocRotations = m_pQuadProgramTextured->GetUniformLoc("gRotations"); m_pQuadProgramTextured->m_LocOffsets = m_pQuadProgramTextured->GetUniformLoc("gOffsets"); + m_pQuadProgramTextured->m_LocQuadOffset = m_pQuadProgramTextured->GetUniformLoc("gQuadOffset"); } { CGLSL VertexShader; @@ -3346,6 +3348,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadLayer(const CCommandBuff pProgram->SetUniformVec4(pProgram->m_LocColors, ActualQuadCount, (float *)aColors); pProgram->SetUniformVec2(pProgram->m_LocOffsets, ActualQuadCount, (float *)aOffsets); pProgram->SetUniform(pProgram->m_LocRotations, ActualQuadCount, (float *)aRotations); + pProgram->SetUniform(pProgram->m_LocQuadOffset, (int)QuadOffset); glDrawElements(GL_TRIANGLES, ActualQuadCount * 6, GL_UNSIGNED_INT, (void *)(QuadOffset * 6 * sizeof(unsigned int))); QuadsLeft -= ActualQuadCount; diff --git a/src/engine/client/opengl_sl_program.h b/src/engine/client/opengl_sl_program.h index ab7821682..9d916959e 100644 --- a/src/engine/client/opengl_sl_program.h +++ b/src/engine/client/opengl_sl_program.h @@ -132,6 +132,7 @@ public: int m_LocColors; int m_LocOffsets; int m_LocRotations; + int m_LocQuadOffset; }; class CGLSLTileProgram : public CGLSLTWProgram