Skip to content

working with shaders in py5 #300

Answered by hx2A
Maltiec asked this question in Q&A
Jun 9, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

I looked at some code I wrote that uses apply_filter() and I recall the shader needs to work a bit differently than regular shaders. Normally when you create a vert and frag shader it is for drawing triangles and the shader has no information about pixels it is being drawn on top of. apply_filter() is different in that you have access to the all of the pixels in the window.

The following fragment shader could be used with apply_filter().

// filename: data/red.glsl

// processing supplied variables
uniform sampler2D texture;
varying vec4 vertColor;
varying vec4 vertTexCoord;

void main() {
  // get original color for this pixel
  vec4 originalColor = texture2D(texture, vertTexCoord.st) * v…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@hx2A
Comment options

Answer selected by Maltiec
@Maltiec
Comment options

@hx2A
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants