Skip to content

Commit 4d31682

Browse files
committed
Use a Vec2 uniform for new atlas size instead of pulling from a sampler2D so that we don't have to bind the new atlas texture while rendering to it
1 parent 988dec0 commit 4d31682

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

arcade/context.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ def __init__(
186186
fragment_shader=":system:shaders/atlas/resize_simple_fs.glsl",
187187
)
188188
self.atlas_resize_program["atlas_old"] = 0 # Configure texture channels
189-
self.atlas_resize_program["atlas_new"] = 1
190-
self.atlas_resize_program["texcoords_old"] = 2
191-
self.atlas_resize_program["texcoords_new"] = 3
189+
self.atlas_resize_program["texcoords_old"] = 1
190+
self.atlas_resize_program["texcoords_new"] = 2
192191

193192
if gl_api != "webgl":
194193
# SpriteList collision resources

arcade/resources/system/shaders/atlas/resize_simple_vs.glsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88

99
// Old and new texture coordinates
1010
uniform sampler2D atlas_old;
11-
uniform sampler2D atlas_new;
1211

1312
uniform sampler2D texcoords_old;
1413
uniform sampler2D texcoords_new;
1514

1615
uniform mat4 projection;
1716
uniform float border;
17+
uniform vec2 size_new;
1818

1919
out vec2 uv;
2020

2121
void main() {
2222
// Get the texture sizes
2323
ivec2 size_old = textureSize(atlas_old, 0).xy;
24-
ivec2 size_new = textureSize(atlas_new, 0).xy;
2524

2625
// Read texture coordinates from UV texture here
2726
int texture_id = gl_VertexID / 6;

arcade/texture_atlas/atlas_default.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,10 @@ def resize(self, size: tuple[int, int], force=False) -> None:
712712

713713
# Bind textures for atlas copy shader
714714
atlas_texture_old.use(0)
715-
self._texture.use(1)
716-
image_uvs_old.texture.use(2)
717-
self._image_uvs.texture.use(3)
715+
image_uvs_old.texture.use(1)
716+
self._image_uvs.texture.use(2)
718717
self._ctx.atlas_resize_program["border"] = float(self._border)
718+
self._ctx.atlas_resize_program["size_new"] = size
719719
self._ctx.atlas_resize_program["projection"] = Mat4.orthogonal_projection(
720720
0,
721721
self.width,

0 commit comments

Comments
 (0)