diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index e112c0df7..cf195361e 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -395,7 +395,7 @@ pub inline fn textureOptions(self: OpenGL) Texture.Options { _ = self; return .{ .format = .rgba, - .internal_format = .srgba_compressed, + .internal_format = .srgba, .target = .@"2D", }; } @@ -428,7 +428,7 @@ pub inline fn imageTextureOptions( return .{ .format = format.toPixelFormat(), .internal_format = if (srgb) .srgba else .rgba, - .target = .Rectangle, + .target = .@"2D", }; } diff --git a/src/renderer/shaders/glsl/bg_image.f.glsl b/src/renderer/shaders/glsl/bg_image.f.glsl index 7c3e4363a..ee1195ef5 100644 --- a/src/renderer/shaders/glsl/bg_image.f.glsl +++ b/src/renderer/shaders/glsl/bg_image.f.glsl @@ -4,7 +4,7 @@ // so as to align with our texture's directionality. layout(origin_upper_left) in vec4 gl_FragCoord; -layout(binding = 0) uniform sampler2DRect image; +layout(binding = 0) uniform sampler2D image; flat in vec4 bg_color; flat in vec2 offset; @@ -23,7 +23,7 @@ void main() { // size of the texture to the dest rect size. vec2 tex_coord = (gl_FragCoord.xy - offset) * scale; - vec2 tex_size = textureSize(image); + vec2 tex_size = textureSize(image, 0); // If we need to repeat the texture, wrap the coordinates. if (repeat != 0) { @@ -38,7 +38,8 @@ void main() { { rgba = vec4(0.0); } else { - rgba = texture(image, tex_coord); + // We divide by the texture size to normalize for sampling. + rgba = texture(image, tex_coord / tex_size); if (!use_linear_blending) { rgba = unlinearize(rgba); diff --git a/src/renderer/shaders/glsl/bg_image.v.glsl b/src/renderer/shaders/glsl/bg_image.v.glsl index 875c40518..d55aa174a 100644 --- a/src/renderer/shaders/glsl/bg_image.v.glsl +++ b/src/renderer/shaders/glsl/bg_image.v.glsl @@ -1,6 +1,6 @@ #include "common.glsl" -layout(binding = 0) uniform sampler2DRect image; +layout(binding = 0) uniform sampler2D image; layout(location = 0) in float in_opacity; layout(location = 1) in uint info; @@ -64,7 +64,7 @@ void main() { repeat = info & BG_IMAGE_REPEAT; vec2 screen_size = screen_size; - vec2 tex_size = textureSize(image); + vec2 tex_size = textureSize(image, 0); vec2 dest_size = tex_size; switch (info & BG_IMAGE_FIT) { diff --git a/src/renderer/shaders/glsl/image.f.glsl b/src/renderer/shaders/glsl/image.f.glsl index cd93cf666..4f89d7a78 100644 --- a/src/renderer/shaders/glsl/image.f.glsl +++ b/src/renderer/shaders/glsl/image.f.glsl @@ -1,6 +1,6 @@ #include "common.glsl" -layout(binding = 0) uniform sampler2DRect image; +layout(binding = 0) uniform sampler2D image; in vec2 tex_coord; diff --git a/src/renderer/shaders/glsl/image.v.glsl b/src/renderer/shaders/glsl/image.v.glsl index 55b12ed68..779fae32f 100644 --- a/src/renderer/shaders/glsl/image.v.glsl +++ b/src/renderer/shaders/glsl/image.v.glsl @@ -1,6 +1,6 @@ #include "common.glsl" -layout(binding = 0) uniform sampler2DRect image; +layout(binding = 0) uniform sampler2D image; layout(location = 0) in vec2 grid_pos; layout(location = 1) in vec2 cell_offset; @@ -32,11 +32,12 @@ void main() { // The texture coordinates start at our source x/y // and add the width/height depending on the corner. - // - // We don't need to normalize because we use pixel addressing for our sampler. tex_coord = source_rect.xy; tex_coord += source_rect.zw * corner; + // Normalize the coordinates. + tex_coord /= textureSize(image, 0); + // The position of our image starts at the top-left of the grid cell and // adds the source rect width/height components. vec2 image_pos = (cell_size * grid_pos) + cell_offset;