I'm trying to decide and figure out how to change the color tone of screen with opengl. I need functions to change the whole screen (minus characters) to a reddish tone, negative, and grayscale. I haven't tried yet, but I'm guessing I can use shaders, which I'm not familiar with. Or I can somehow use the glDrawPixel command, but I think it might be an expensive call. Or I can make a color vertex array from the game objects and blend from that. I do have DevIL, developers image library included in my project, and there are functions such as saturation and filters like in photoshop, but these functions are meant for while building textures and not dynamically changing them during game play. Did I miss any other ways? Does anyone have any hints how I could accomplish this or what route I should take?
Edit: This is in a Opengl / win32 project, no SDL.
OpenGL and color effects
Moderator: Coders of Rage
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: OpenGL and color effects
What would the cost be if you did a glColor3f call before you drew anything? Is that possible? Sort of like how a camera can be handled by calling glTranslate3f before you do anything.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: OpenGL and color effects
Not sure EXACTLY what you want to do here, but I suspect I have an idea.
If you want to do all three of those in combination, the best solution would be as an image based post-processing effect. This involves rendering the scene to an offscreen render target as a forward rendering pass, then in a separate pass render a full screen quad to an intermediate render target sampling the offscreen target as a texture in an image processing effect. (Yes, this would involve shaders).
If you wanted to give it a reddish hue, you could clear the backbuffer to a desired colour and accumulate the final result via alpha blending into the framebuffer from the processed scene texture. IE: glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE);
Investigate screen space effects and image processing.
If you want to do all three of those in combination, the best solution would be as an image based post-processing effect. This involves rendering the scene to an offscreen render target as a forward rendering pass, then in a separate pass render a full screen quad to an intermediate render target sampling the offscreen target as a texture in an image processing effect. (Yes, this would involve shaders).
If you wanted to give it a reddish hue, you could clear the backbuffer to a desired colour and accumulate the final result via alpha blending into the framebuffer from the processed scene texture. IE: glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE);
Investigate screen space effects and image processing.
- Spikey
- Chaos Rift Cool Newbie
- Posts: 98
- Joined: Sat Dec 13, 2008 6:39 am
- Programming Language of Choice: C++
- Location: Ottawa, Canada
- Contact:
Re: OpenGL and color effects
That's what I was doing in the first place, and it worked, but then when I changed my render function into calling a DisplayList, it stopped working. I still don't have it working yet, I'm playing around with GL_COLOR_ARRAY vertex array, hopefully it works.What would the cost be if you did a glColor3f call before you drew anything?
@ qpHalcy0n
Thanks for the ideas, I'll look into it!
- Spikey
- Chaos Rift Cool Newbie
- Posts: 98
- Joined: Sat Dec 13, 2008 6:39 am
- Programming Language of Choice: C++
- Location: Ottawa, Canada
- Contact:
Re: OpenGL and color effects
Sweet, I got it working. I was misusing the color array.