Sign in to follow this  

Add skybox to deferred scene

This topic is 2057 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 have basic deferred renderer project setup. In my scene i have added some buildings and terrain and now i want to add skybox to it.
I need help how to tag pixels with stencil buffer where objects are drawn so i can later draw a skybox (with zenable false) only on pixels that are not tagged? What is a proper render states to set? Is there some other method beside "stencil masking"?

Thanks for your time.

Share this post


Link to post
Share on other sites
I'm not sure if it is the fastest way to way to handle the sky, but in the lighting part I test if the pixel depth is bigger than some treshold (like >0.999) then I draw sky, otherwise I calculate the lighting for the current pixel. Probably you could handle the situation with the stencil buffer too.

Cheers!

Share this post


Link to post
Share on other sites
[quote name='MJP' timestamp='1335727569' post='4935874']
You don't need to use stencil if you don't want, you just need to force your skybox to have a depth of 1.0 and then enable depth testing. The easiest way to do that is to your viewport MinZ and MaxZ to 1.0.
[/quote]
I did that in my game and... didn't work well. OpenGL renderer worked fine, but D3D9 was pushing the skybox in front of other objects that were very close to the far plane (maybe some driver bug?). To avoid the problem I enforced all skybox vertices to have z=1 in the vertex shader:
[code]
VS_OUTPUT main(VS_INPUT input)
{
VS_OUTPUT output;

output.position = mul(input.position, worldViewProjTransform);
output.position.z = output.position.w;
output.texCoord0 = input.texCoord0;

return output;
}
[/code] Edited by maxest

Share this post


Link to post
Share on other sites

This topic is 2057 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this