Jump to content
  • Advertisement
Sign in to follow this  
ic0de

OpenGL Stopping my skybox from "Blooming out"

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

I recently made a new skybox which is brighter than my old one. I have encountered a problem where my bloom shader sees my bright skybox and blurs it beyond recognition. I somehow need to keep the effect where the bright sky bleeds onto the edges of the mountains without my sky exploding onto itself. Anyone have any idea how to prevent this?

btw. I'm using OpenGL.

Share this post


Link to post
Share on other sites
Advertisement
Can you post the pixelshader for your bloom effect? Is there a threshold you can increase for the blooming? It seems like many pixels in your new skybox are brighter (closer to (1,1,1,1) ) and trigger the blooming threshold because of that.

Share this post


Link to post
Share on other sites
Can you post the pixelshader for your bloom effect? Is there a threshold you can increase for the blooming? It seems like many pixels in your new skybox are brighter (closer to (1,1,1,1) ) and trigger the blooming threshold because of that.[/quote]

Yes it does have a threshold (even controllable from the in game GUI). However changing the threshold would affect everything not just the skybox. Anyway here is my code:


#version 120
uniform sampler2D color_texture;
uniform float level;
varying vec2 vTexCoord;
void main(void)
{
vec4 sample = texture2D(color_texture, vTexCoord);
if((0.2126*sample.r) + (0.7152*sample.g) + (0.0722*sample.b) > level)
{
float brightenRatio = 1.0 / max(max(sample.r, sample.g), sample.b);
sample.r *= brightenRatio;
sample.g *= brightenRatio;
sample.b *= brightenRatio;
}
else
{
sample.r = 0.0;
sample.g = 0.0;
sample.b = 0.0;
}
sample.a = (0.2126*sample.r) + (0.7152*sample.g) + (0.0722*sample.b);
gl_FragColor = sample;
}


I think I have a solution though, I can do a masked blend when I compose the final image and whatever pixels are skybox will not be copied onto the new image.

Share this post


Link to post
Share on other sites
Well don't use if's, because that method looks shitty. There is hard jump from black to white. This is how you make a soft threshold:

vec3 colorThresholded = max(0.0, color - vec3(threshold)) * (1.0 / threshold);

Share this post


Link to post
Share on other sites
you may want to go so far as to mask the skybox, you may use one of the channels of your GBuffer, or a stencil buffer, or something to indicate which pixels of the screens should be eligible for bloom.

blooming the sky is an intutive way to make a homogenous look to the effect. but your artists will likely want more control over what the player sees, even in the extremely bright sky.

We haven't added masking yet, but we want to. we want to mask other post effects.

Share this post


Link to post
Share on other sites
If you mask out the sky when applying the bloom, the environment will no longer blend into the sky, causing an irregularity around edges.
Can't you simply lower the brightness of the sky so it's more adjusted to the rest of the scene before blooming?

Share this post


Link to post
Share on other sites
Just set a stencil bit when you draw your skybox, and stencil test for that bit being unset when applying bloom. If you've got the same depth/stencil buffer attached, you'll apply bloom to everything else, while leaving your skybox untouched.

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!