diff --git a/data/shaders/drawimage.frag b/data/shaders/drawimage.frag index 87a96aa1eb..c4ae8ce042 100644 --- a/data/shaders/drawimage.frag +++ b/data/shaders/drawimage.frag @@ -6,8 +6,9 @@ uniform usampler2DArray uTexture; flat in ivec4 fClip; flat in int fFlags; in vec4 fColour; -flat in int fTexAtlasIndex; +flat in int fTexColourAtlas; in vec2 fTexColourCoords; +flat in int fTexMaskAtlas; in vec2 fTexMaskCoords; flat in int fMask; @@ -24,8 +25,8 @@ void main() discard; } - vec4 mask = uPalette[texture(uTexture, vec3(fTexMaskCoords, float(fTexAtlasIndex))).r]; - vec4 texel = uPalette[texture(uTexture, vec3(fTexColourCoords, float(fTexAtlasIndex))).r]; + vec4 texel = uPalette[texture(uTexture, vec3(fTexColourCoords, float(fTexColourAtlas))).r]; + vec4 mask = uPalette[texture(uTexture, vec3(fTexMaskCoords, float(fTexMaskAtlas))).r]; if (fMask != 0) { diff --git a/data/shaders/drawimage.vert b/data/shaders/drawimage.vert index 0ff5c67588..064a5e3e56 100644 --- a/data/shaders/drawimage.vert +++ b/data/shaders/drawimage.vert @@ -3,8 +3,9 @@ uniform ivec2 uScreenSize; in ivec4 ivClip; -in int ivTexAtlasIndex; +in int ivTexColourAtlas; in vec4 ivTexColourBounds; +in int ivTexMaskAtlas; in vec4 ivTexMaskBounds; in int ivFlags; in vec4 ivColour; @@ -18,8 +19,9 @@ out vec2 fPosition; flat out ivec4 fClip; flat out int fFlags; out vec4 fColour; -flat out int fTexAtlasIndex; +flat out int fTexColourAtlas; out vec2 fTexColourCoords; +flat out int fTexMaskAtlas; out vec2 fTexMaskCoords; flat out int fMask; @@ -60,7 +62,8 @@ void main() fFlags = ivFlags; fColour = ivColour; fMask = ivMask; - fTexAtlasIndex = ivTexAtlasIndex; + fTexColourAtlas = ivTexColourAtlas; + fTexMaskAtlas = ivTexMaskAtlas; gl_Position = vec4(pos, 0.0, 1.0); } diff --git a/src/drawing/engines/opengl/DrawImageShader.cpp b/src/drawing/engines/opengl/DrawImageShader.cpp index 7d2b3b1d81..69c6b8d6ba 100644 --- a/src/drawing/engines/opengl/DrawImageShader.cpp +++ b/src/drawing/engines/opengl/DrawImageShader.cpp @@ -36,8 +36,9 @@ DrawImageShader::DrawImageShader() : OpenGLShaderProgram("drawimage") glBindBuffer(GL_ARRAY_BUFFER, _vboInstances); glVertexAttribIPointer(vClip, 4, GL_INT, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, clip)); - glVertexAttribIPointer(vTexAtlasIndex, 1, GL_INT, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, texAtlasIndex)); + glVertexAttribIPointer(vTexColourAtlas, 1, GL_INT, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, texColourAtlas)); glVertexAttribPointer(vTexColourBounds, 4, GL_FLOAT, GL_FALSE, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, texColourBounds)); + glVertexAttribIPointer(vTexMaskAtlas, 1, GL_INT, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, texMaskAtlas)); glVertexAttribPointer(vTexMaskBounds, 4, GL_FLOAT, GL_FALSE, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, texMaskBounds)); glVertexAttribIPointer(vFlags, 1, GL_INT, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, flags)); glVertexAttribPointer(vColour, 4, GL_FLOAT, GL_FALSE, sizeof(DrawImageInstance), (void*) offsetof(DrawImageInstance, colour)); @@ -46,8 +47,9 @@ DrawImageShader::DrawImageShader() : OpenGLShaderProgram("drawimage") glEnableVertexAttribArray(vIndex); glEnableVertexAttribArray(vClip); - glEnableVertexAttribArray(vTexAtlasIndex); + glEnableVertexAttribArray(vTexColourAtlas); glEnableVertexAttribArray(vTexColourBounds); + glEnableVertexAttribArray(vTexMaskAtlas); glEnableVertexAttribArray(vTexMaskBounds); glEnableVertexAttribArray(vFlags); glEnableVertexAttribArray(vColour); @@ -55,8 +57,9 @@ DrawImageShader::DrawImageShader() : OpenGLShaderProgram("drawimage") glEnableVertexAttribArray(vMask); glVertexAttribDivisor(vClip, 1); - glVertexAttribDivisor(vTexAtlasIndex, 1); + glVertexAttribDivisor(vTexColourAtlas, 1); glVertexAttribDivisor(vTexColourBounds, 1); + glVertexAttribDivisor(vTexMaskAtlas, 1); glVertexAttribDivisor(vTexMaskBounds, 1); glVertexAttribDivisor(vFlags, 1); glVertexAttribDivisor(vColour, 1); @@ -84,8 +87,9 @@ void DrawImageShader::GetLocations() vIndex = GetAttributeLocation("vIndex"); vClip = GetAttributeLocation("ivClip"); - vTexAtlasIndex = GetAttributeLocation("ivTexAtlasIndex"); + vTexColourAtlas = GetAttributeLocation("ivTexColourAtlas"); vTexColourBounds = GetAttributeLocation("ivTexColourBounds"); + vTexMaskAtlas = GetAttributeLocation("ivTexMaskAtlas"); vTexMaskBounds = GetAttributeLocation("ivTexMaskBounds"); vFlags = GetAttributeLocation("ivFlags"); vColour = GetAttributeLocation("ivColour"); diff --git a/src/drawing/engines/opengl/DrawImageShader.h b/src/drawing/engines/opengl/DrawImageShader.h index 425735ffa7..f4609bf581 100644 --- a/src/drawing/engines/opengl/DrawImageShader.h +++ b/src/drawing/engines/opengl/DrawImageShader.h @@ -24,8 +24,9 @@ // Per-instance data for images struct DrawImageInstance { vec4i clip; - int texAtlasIndex; + int texColourAtlas; vec4f texColourBounds; + int texMaskAtlas; vec4f texMaskBounds; int flags; vec4f colour; @@ -42,8 +43,9 @@ private: GLuint vIndex; GLuint vClip; - GLuint vTexAtlasIndex; + GLuint vTexColourAtlas; GLuint vTexColourBounds; + GLuint vTexMaskAtlas; GLuint vTexMaskBounds; GLuint vFlags; GLuint vColour; diff --git a/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 668aa91a67..2d06e255c2 100644 --- a/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -952,8 +952,9 @@ void OpenGLDrawingContext::FlushImages() { DrawImageInstance instance; instance.clip = {command.clip[0], command.clip[1], command.clip[2], command.clip[3]}; - instance.texAtlasIndex = command.texColour.index; + instance.texColourAtlas = command.texColour.index; instance.texColourBounds = command.texColour.normalizedBounds; + instance.texMaskAtlas = command.texMask.index; instance.texMaskBounds = command.texMask.normalizedBounds; instance.flags = command.flags; instance.colour = command.colour;