Jump to content
  • Advertisement
Sign in to follow this  
kerryhall

Post processing effects?

This topic is 3700 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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);
}

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!



Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!