Jump to content
  • Advertisement
Sign in to follow this  
Tiresias

OpenGL night - daylight scene effects

This topic is 3334 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

Hello i am using opengl to display a 2d scene with some sprites (images blitted on the screen), and i would like to add a simple light effect such as tuning the "light" of the whole scene : i mean like either make the whole scene darker, either make it lighter (depending of the hour :). I dont know if i must add some colour mask when blitting (in my render loop) each indiviual scene object (background sprites etc) or if there is a "global" screen thing i could just call before rendering all my scene element and such will apply to all of them. Any ideas welcome thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement
How are you rendering those sprites?
If you are using OpenGL, you can specify a color per vertex, that will be modulated with the sprite, thus you use this to dark the scene, or give it a blue tint, for example. Check glcolor3f function.

Share this post


Link to post
Share on other sites
Yes this is the first solution i was thinking of, but maybe there is more elegant, like as i said a global screen mask i could use before rending all object separatly ?
like in this pseudo code:

render()
{
setuprender();
for (obj in list)
obj->render();
endrender();
}

so maybe in the seturender() i could use some opengl primitive to let it know that i want to darkener evything instead of adding code in the obj->render() method? (like glENAble(LIGHT) etc

[Edited by - Tiresias on October 28, 2009 10:44:48 AM]

Share this post


Link to post
Share on other sites
Hmm, you can render a alpha blended full screen quad on top of the scene, and somehow fake the effect. Check the different blend modes avaliable, the additive one is good for lighten up the scene, and the multiply to darken.

Other alternative is to setup a shader that controls the color output, and this is probably the best solution.

Share this post


Link to post
Share on other sites
why not using the opengl build in LIGHTING stuff?

"Other alternative is to setup a shader that controls the color output" : good but how do uyou do it ? any pseudo code or code?

thanks

Share this post


Link to post
Share on other sites
hello
those 2 lines dont work,
first because u put only 3 values in the array so the last one is 0 (and it is used for ALPHA so maybe 0 would just black all),

and as well maybe (not sure) because u need to call glEnable(GL_LIGHT0) (if i dont enable it all is black),

anyway just wondering: those lights only works if u are currently using glcolor ... i mean i ma just blitting picture , and all the color info is contained in the blited surface, so maybe light will not help ... ?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!