diff --git a/doc/tutorials/shader_inputs/basic_shader.py b/doc/tutorials/shader_inputs/basic_shader.py index 141e416705..0d422a3f67 100644 --- a/doc/tutorials/shader_inputs/basic_shader.py +++ b/doc/tutorials/shader_inputs/basic_shader.py @@ -10,7 +10,7 @@ def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) self.center_window() self.background_color = arcade.color.ALMOND - + # GL geometry that will be used to pass pixel coordinates to the shader # It has the same dimensions as the screen self.quad_fs = arcade.gl.geometry.quad_2d_fs() @@ -40,7 +40,7 @@ def on_draw(self): # Draw a simple circle self.clear() arcade.draw_circle_filled( - SCREEN_WIDTH / 2, + SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 100, arcade.color.AFRICAN_VIOLET @@ -49,7 +49,13 @@ def on_draw(self): # Run the shader and render to screen # The shader code is run once for each pixel coordinate in quad_fs # and the fragColor output added to the screen - self.quad_fs.render(self.prog) + # Because the fragColor has a varying transparency we need to enable + # blending. When blending is disabled each pixel's color is exactly + # equal to fragColor, but with blending enabled the pixel's final + # color is a mix of the original color and fragColor based on the + # alpha values. + with self.ctx.enabled(self.ctx.BLEND): + self.quad_fs.render(self.prog) app = MyWindow() diff --git a/doc/tutorials/shader_inputs/texture_write.py b/doc/tutorials/shader_inputs/texture_write.py index c6ad51a75a..970efc2159 100644 --- a/doc/tutorials/shader_inputs/texture_write.py +++ b/doc/tutorials/shader_inputs/texture_write.py @@ -10,7 +10,7 @@ def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) self.center_window() self.background_color = arcade.color.ALMOND - + # GL geometry that will be used to pass pixel coordinates to the shader # It has the same dimensions as the screen self.quad_fs = arcade.gl.geometry.quad_2d_fs() @@ -23,7 +23,7 @@ def __init__(self): self.fbo.clear(color=arcade.color.ALMOND) with self.fbo: arcade.draw_circle_filled( - SCREEN_WIDTH / 2, + SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 100, arcade.color.AFRICAN_VIOLET @@ -36,7 +36,7 @@ def __init__(self): in vec2 in_vert; void main() { - gl_Position = vec4(in_vert, 0., 1.); + gl_Position = vec4(in_vert, 0.0, 1.0); } """, fragment_shader=""" @@ -63,8 +63,9 @@ def on_draw(self): self.tex.use(0) # Run the shader and render to the framebuffer - self.quad_fs.render(self.prog) - + with self.ctx.enabled(self.ctx.BLEND): + self.quad_fs.render(self.prog) + # Copy the framebuffer to the screen to display self.ctx.copy_framebuffer(self.fbo, self.ctx.screen) diff --git a/doc/tutorials/shader_inputs/textures.py b/doc/tutorials/shader_inputs/textures.py index f792b91cf2..e45174f547 100644 --- a/doc/tutorials/shader_inputs/textures.py +++ b/doc/tutorials/shader_inputs/textures.py @@ -10,7 +10,7 @@ def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) self.center_window() self.background_color = arcade.color.ALMOND - + # GL geometry that will be used to pass pixel coordinates to the shader # It has the same dimensions as the screen self.quad_fs = arcade.gl.geometry.quad_2d_fs() @@ -53,8 +53,8 @@ def __init__(self): { // Set pixel color as a combination of the two textures fragColor = mix( - texture(t0, uv), - texture(t1, uv), + texture(t0, uv), + texture(t1, uv), smoothstep(0.0, 1.0, uv.x)); // Set the alpha based on time fragColor.w = sin(time); @@ -77,7 +77,7 @@ def on_draw(self): # Draw a simple circle self.clear() arcade.draw_circle_filled( - SCREEN_WIDTH / 2, + SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 100, arcade.color.AFRICAN_VIOLET @@ -93,7 +93,8 @@ def on_draw(self): # Run the shader and render to screen # The shader code is run once for each pixel coordinate in quad_fs # and the fragColor output added to the screen - self.quad_fs.render(self.prog) + with self.ctx.enabled(self.ctx.BLEND): + self.quad_fs.render(self.prog) app = MyWindow() diff --git a/doc/tutorials/shader_inputs/uniforms.py b/doc/tutorials/shader_inputs/uniforms.py index d7fdbff6b4..cb34b30e9a 100644 --- a/doc/tutorials/shader_inputs/uniforms.py +++ b/doc/tutorials/shader_inputs/uniforms.py @@ -10,7 +10,7 @@ def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) self.center_window() self.background_color = arcade.color.ALMOND - + # GL geometry that will be used to pass pixel coordinates to the shader # It has the same dimensions as the screen self.quad_fs = arcade.gl.geometry.quad_2d_fs() @@ -49,7 +49,7 @@ def on_draw(self): # Draw a simple circle self.clear() arcade.draw_circle_filled( - SCREEN_WIDTH / 2, + SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 100, arcade.color.AFRICAN_VIOLET @@ -61,7 +61,13 @@ def on_draw(self): # Run the shader and render to screen # The shader code is run once for each pixel coordinate in quad_fs # and the fragColor output added to the screen - self.quad_fs.render(self.prog) + # Because the fragColor has a varying transparency we need to enable + # blending. When blending is disabled each pixel's color is exactly + # equal to fragColor, but with blending enabled the pixel's final + # color is a mix of the original color and fragColor based on the + # alpha values. + with self.ctx.enabled(self.ctx.BLEND): + self.quad_fs.render(self.prog) app = MyWindow()