OpenGL: Fix Custom Shaders (#7697)
Ref: GitHub Discussion #7696 See commit messages for details.pull/7701/head
commit
979d72056b
|
|
@ -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",
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "common.glsl"
|
||||
|
||||
layout(binding = 0) uniform sampler2DRect image;
|
||||
layout(binding = 0) uniform sampler2D image;
|
||||
|
||||
in vec2 tex_coord;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue