Search code examples
openglfragment-shaderpixel-shader

change specific pixel color via fragment/pixel shader?(opengl)


Is there any way to change specific pixel color via fragment/pixel shader? (like a uniform variable?)

To be specific, im trying to implement ray-traced shadows.


Solution

  • If by pixel you mean an actual pixel on the screen, then you can achieve that with multistage rendering. Render your scene to an FBO (to a texture), then render the quad onto a screen with that texture.

    If the FBO texture size will be exactly the same as screen size, every invocation of the fragment shader will nicely correspond to the screen position.