OpenGL: Fix Custom Shaders (#7697)

Ref: GitHub Discussion #7696 

See commit messages for details.
pull/7701/head
Qwerasd 2025-06-26 17:19:19 -06:00 committed by GitHub
commit 979d72056b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 11 deletions

View File

@ -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",
};
}

View File

@ -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);

View File

@ -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) {

View File

@ -1,6 +1,6 @@
#include "common.glsl"
layout(binding = 0) uniform sampler2DRect image;
layout(binding = 0) uniform sampler2D image;
in vec2 tex_coord;

View File

@ -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;