Post processing effects?
Hey all!
So I would like to be able to manipulate pixels after rendering. I'm not sure if this is called post-processing or what. Basically I would like to able to do things like swap the R and G values of all pixels, convert the screen to gray scale, lighten all pixels by a certain amount, etc.
I did find this thread:
http://www.gamedev.net/community/forums/topic.asp?topic_id=440479&whichpage=1
Where it is suggested to use frame buffer objects. I found the tutorials on here:
http://flashbang.se/postbreak.php?id=18
On how to set up a framebuffer object, now if I could only figure out how to use them to do what I want....(say, adding 10 to all red pixel values capping at 255 of course)
If anyone could help, that would be awesome! :)
Thanks!
Quote:Original post by kerryhall
Hey all!
So I would like to be able to manipulate pixels after rendering. I'm not sure if this is called post-processing or what. Basically I would like to able to do things like swap the R and G values of all pixels, convert the screen to gray scale, lighten all pixels by a certain amount, etc.
I did find this thread:
http://www.gamedev.net/community/forums/topic.asp?topic_id=440479&whichpage=1
Where it is suggested to use frame buffer objects. I found the tutorials on here:
http://flashbang.se/postbreak.php?id=18
On how to set up a framebuffer object, now if I could only figure out how to use them to do what I want....(say, adding 10 to all red pixel values capping at 255 of course)
If anyone could help, that would be awesome! :)
Thanks!
That's very easy using shaders.
I recommend you to use GLEW to be able accesing shader extensions on OpenGL.
After that, write a trivial vertex shader (you are not going to change vertex)
void main(void)
{
gl_FrontColor = gl_Color;
gl_Position = ftransform();
}
For instance, this is a fragment shader to swap the R and G values (maybe there are syntax mistakes)
void main()
{
vec3 color=gl_Color;
gl_FragColor = vec3(color.g,color.r,color.b);
}
Hmmmm, let's say that I would like to do something like only render even numbered pixel rows, while odd numbered pixel rows are black.
Or let's say I want to render just within a triangle or pentagon area on the screen, the rest of the screen black.
Or lets say I want to render my scene, but then draw a 10 pixel wide green border around the screen.
Would I use a fragment program?
Thanks to everyone!
Or let's say I want to render just within a triangle or pentagon area on the screen, the rest of the screen black.
Or lets say I want to render my scene, but then draw a 10 pixel wide green border around the screen.
Would I use a fragment program?
Thanks to everyone!
Thank you! I'm not sure how to use the stencil buffer in this way though.
Could someone show me some quick code to use the stencil buffer to draw to a non-rectangular region of the screen? Thank you!
Could someone show me some quick code to use the stencil buffer to draw to a non-rectangular region of the screen? Thank you!
Also, does anyone know how to initialize the stencil buffer with SDL? All the examples I have found use glut.
Thanks!
Edit:
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,1);
was the initialization code I was looking for. I have also found this code example from the red book to render to a non-rectangular region:
http://www.opengl.org/resources/code/samples/redbook/stencil.c
However, if I could find a fast way to modify pixel values directly, that would be great!
[Edited by - kerryhall on May 19, 2008 5:53:53 PM]
Thanks!
Edit:
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,1);
was the initialization code I was looking for. I have also found this code example from the red book to render to a non-rectangular region:
http://www.opengl.org/resources/code/samples/redbook/stencil.c
However, if I could find a fast way to modify pixel values directly, that would be great!
[Edited by - kerryhall on May 19, 2008 5:53:53 PM]
Hey all! Thanks for all your help so far. I have successfully figured out how to render to non rectangular regions of the screen.
However, I still have one question:
How can I render to a certain region of the screen, but render in red pixels only? Or render at half brightness only? (all pixel values are halved)
Would I use a pixel shader for this? Anyone have an idea? Thanks!
Kerry
However, I still have one question:
How can I render to a certain region of the screen, but render in red pixels only? Or render at half brightness only? (all pixel values are halved)
Would I use a pixel shader for this? Anyone have an idea? Thanks!
Kerry
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement