Skip to content

Using filter(PShader) will bug blending mode #5616

@iGoodie

Description

@iGoodie

Description

I'm trying to postprocess my screenbuffer with a basic vignette fragment shader.
I load the shader, then use filter(), the very first frame is perfect, but the other one is just blended wrong ignoring the transparency values.

Expected Behavior

image() callbacks will blend properly after filter(PShader) callbacks.
Very first frame drawn;
proper_frame

Current Behavior

image() renders images ignoring the transparency values
Frames after the first frame drawn;
improper_frame

Steps to Reproduce

  1. Load following vignette.fsh shader;
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

#define PROCESSING_TEXTURE_SHADER

uniform sampler2D texture;
uniform vec2 resolution;
 
varying vec4 vertColor;
varying vec4 vertTexCoord;

void main() {
	vec4 texColor = texture2D(texture, vertTexCoord.xy);
	
	vec2 position = (gl_FragCoord.xy / resolution.xy) - vec2(0.5);
	
	float len = length(position);
	
	gl_FragColor = vec4( texColor.rgb*(1.0-len), 1.0 );
}
  1. Execute given draw() method body;
public void render() {
	background(255);
	image(someTransImg);
	filter(vignetteShader);
}
  1. See it will draw transparency right only for the first frame. (use frameRate(1) @ setup() to see easier)

Your Environment

  • Processing version: 3.4 (Stable)
  • Operating System and OS version: Windows 7 Home Premium

Possible Causes / Solutions

I believe filter(PShader) somehow changes the blending mode into MIX mode.
Also calling blendMode(BLEND) right after filter(PShader) solves it. But that shouldn't be an intended behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions