-
Notifications
You must be signed in to change notification settings - Fork 361
Closed
Description
Bug Report
texture0.use(0) seems to bind to all channels in fragment shader and texture1.use(1) does not bind to any.
System Info
Arcade 2.6.17
-------------
vendor: Intel
renderer: Mesa Intel(R) HD Graphics 620 (KBL GT2)
version: (4, 6)
python: 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0]
platform: linux
Actual behavior:
With
# Python code
texture0.use(0)
texture1.use(1)
...
# Fragment shader
#version 330
uniform sampler2D t0;
uniform sampler2D t1;
both t0 and t1 refer to texture0.
Expected behavior:
I would expect t0 to refer to texture0 and t1 to refer to texture1.
Steps to reproduce/example code:
This is a pretty minimal example where the shader blends tex_0 with tex_0 to create a solid color rather than blending tex_0 with tex_1 to create a gradient.
import arcade
class MyWindow(arcade.Window):
def __init__(self):
global cs, vs, gs, fs
super().__init__(80, 80, "X")
self.center_window()
# Create textures and FBOs
self.tex_0 = self.ctx.texture((self.width, self.height))
self.fbo_0 = self.ctx.framebuffer(color_attachments=[self.tex_0])
self.tex_1 = self.ctx.texture((self.width, self.height))
self.fbo_1 = self.ctx.framebuffer(color_attachments=[self.tex_1])
self.quad_fs = arcade.gl.geometry.quad_2d_fs()
# Create shader program
self.prog = self.ctx.program(
vertex_shader="""#version 330
in vec2 in_vert;
in vec2 in_uv;
out vec2 uv;
void main()
{
gl_Position = vec4(in_vert, 0., 1.);
uv = in_uv;
}""",
fragment_shader="""#version 330
uniform sampler2D t0;
uniform sampler2D t1;
in vec2 uv;
out vec4 fragColor;
void main()
{
// Expect same output as
// fragColor = mix(vec4(0.0, 0.0, 1.0, 1.0), vec4(1.0,0.0,0.0,1.0), smoothstep(0.0, 1.0, uv.x));
fragColor = mix(texture(t0, uv), texture(t1, uv), smoothstep(0.0, 1.0, uv.x));
}"""
)
def on_draw(self):
self.clear()
# Fill the textures with solid colours
self.fbo_0.clear(color=(0.0, 0.0, 1.0, 1.0), normalized=True)
self.fbo_1.clear(color=(1.0, 0.0, 0.0, 1.0), normalized=True)
# Bind our textures to channels
self.tex_0.use(0)
self.tex_1.use(1)
# Run the shader and render
self.quad_fs.render(self.prog)
app = MyWindow()
arcade.run()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

