my first shader(solved)

edited October 2017 in GLSL / Shaders

Hello to all... I was trying to programming my first shader, what to do is simple: color all the red pixels. But I'm finding some problem, the code is executed, but nothing happens. so I guess I'm wrong about something

processing sketch:

PShader myShader;

void setup() {
  size(250, 250, P2D);
  noSmooth();
  myShader = loadShader("shader.glsl");
}

void draw() {
  shader(myShader);
}

shader sketch:

#define PROCESSING_COLOR_SHADER
vec4 f = vec4(1.,0.,0.,1.); // f will be used to store the color of the current fragment

void main(void) {    
  gl_FragColor = f;
}

thank you very much to everyone for the support :D :D

Answers

  • edited October 2017 Answer ✓

    I'm only just learning shaders myself but this I know.

    You need something for the shader to change the colour of.
    Add a rect or ellipse or something to your sketch.

  • ooh...ok, i just add a rect, it works...thank you :D

  • Answer ✓

    Just as explanation: Calling the method shader(..) does not draw anything. It just sets the state of the OpenGL pipeline to use that shader, when something is drawn. As @SnailPropulsionLabs told you, you have to draw something to see the output.

Sign In or Register to comment.