Skip to content

Commit

Permalink
fix: pixel art sampler texel offset in image-render-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Dec 21, 2024
1 parent 2be62f3 commit 05c9dae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ in vec4 v_tint;
// texture resolution
in vec2 v_res;

in vec2 v_size;

in vec2 v_uv_min;
in vec2 v_uv_max;

Expand Down Expand Up @@ -53,12 +55,12 @@ void main(){
// that do not apply to a particular sprite.

vec4 color=vec4(1.,0,0,1.);
vec2 remapped_uv = v_texcoord;
remapped_uv.x = remap(0.,1., v_uv_min.x, v_uv_max.x, v_texcoord.x);
remapped_uv.y = remap(0.,1., v_uv_min.y, v_uv_max.y, v_texcoord.y);
vec2 uv = u_pixelart ? uv_iq(remapped_uv, v_size) : remapped_uv;

// GLSL is templated out to pick the right texture and set the vec4 color
vec2 uv = u_pixelart ? uv_iq(v_texcoord, v_res) : v_texcoord;
uv.x = remap(0.,1., v_uv_min.x, v_uv_max.x, uv.x);
uv.y = remap(0.,1., v_uv_min.y, v_uv_max.y, uv.y);

%%texture_picker%%

color.rgb = color.rgb * v_opacity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ layout(location=5) in vec2 a_mat_column3;
layout(location=6) in float a_opacity;
out float v_opacity;

// Texture resolution (could be bigger than a_siz)
// Texture resolution (could be bigger than a_size)
layout(location=7) in vec2 a_res;
out vec2 v_res;

// Final size of graphic
layout(location=8) in vec2 a_size;
out vec2 v_size;

layout(location=9) in lowp float a_texture_index;
out lowp float v_texture_index;
Expand Down Expand Up @@ -48,6 +49,7 @@ void main(){
v_uv_min = a_uv_min;
v_uv_max = a_uv_max;
v_res = a_res;
v_size = a_size;
v_texture_index = a_texture_index;
v_tint = a_tint;
}

0 comments on commit 05c9dae

Please sign in to comment.