Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Add skybox to deferred scene

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 belfegor   Members   

2833
Like
0Likes
Like

Posted 29 April 2012 - 06:29 AM

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.

#2 kauna   Members   

2922
Like
1Likes
Like

Posted 29 April 2012 - 11:53 AM

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!

#3 MJP   Moderators   

19407
Like
1Likes
Like

Posted 29 April 2012 - 01:26 PM

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.

#4 maxest   Members   

614
Like
1Likes
Like

Posted 29 April 2012 - 03:11 PM

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.

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:
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;
}

Edited by maxest, 29 April 2012 - 03:12 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.