mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Fix assumption that colour texture and mask texture originate from same atlas
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user