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

[SharpDX] Question about Z-Buffer

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 Lordadmiral Drake   Members   

787
Like
0Likes
Like

Posted 20 August 2014 - 04:35 AM

In my game I need to render a background starsphere which obviously has to be rendered behind everything else.

With XNA it was pretty easy to do this with DepthStencilState.None before the draw call abd DepthStencilState.Default after it.

 

In SharpDX these two DepthStencilStates also exist (from looking at the source code), but somehow I can't access them.

 

So, is there an easy way to turn the Z-Buffer off and then back on, or do I need to dive deeper?



#2 BlackBrain   Members   

517
Like
1Likes
Like

Posted 20 August 2014 - 06:05 AM

You need to set the DepthStencilState of the DeviceContext .

For disabling DepthTesting and Writing to DepthBuffer :

DepthStencilStateDescription desc = new DepthStencilStateDescription();
desc.IsDepthEnabled=false;
desc.DepthComparison = Comparison.Always;
desc.DepthWriteMask = DepthWriteMask.Zero;
DepthStencilState state = new DepthStencilState(device, desc);
contex.OutputMerger.SetDepthStencilState(state); 

and for restarting back to default state you can just set DepthStencilState to null :

contex.OutputMerger.SetDepthStencilState(null); 



#3 xoofx   Members   

1101
Like
2Likes
Like

Posted 20 August 2014 - 06:20 AM

In SharpDX these two DepthStencilStates also exist (from looking at the source code), but somehow I can't access them.

 

SharpDX is providing low-level DirectX and a higher level API with the Toolkit. I assume you are talking about the Toolkit, but please in the future, try to give more context.

 

That being said, I don't know how you are looking at the source code or even you are usually using an API, but the method GraphicsDevice.SetDepthStencilState is well defined.

 

Also, GraphicsDevice.DepthStencilStates.Default and None provides default states, and can be used like this:

GraphicsDevice.SetDepthStencilState(GraphicsDevice.DepthStencilStates.Default);
....

GraphicsDevice.SetDepthStencilState(GraphicsDevice.DepthStencilStates.None);

It is the same behavior for blend states and rasterizer states.



#4 Lordadmiral Drake   Members   

787
Like
0Likes
Like

Posted 20 August 2014 - 05:20 PM

 

In SharpDX these two DepthStencilStates also exist (from looking at the source code), but somehow I can't access them.

 

SharpDX is providing low-level DirectX and a higher level API with the Toolkit. I assume you are talking about the Toolkit, but please in the future, try to give more context.

 

That being said, I don't know how you are looking at the source code or even you are usually using an API, but the method GraphicsDevice.SetDepthStencilState is well defined.

 

Also, GraphicsDevice.DepthStencilStates.Default and None provides default states, and can be used like this:

GraphicsDevice.SetDepthStencilState(GraphicsDevice.DepthStencilStates.Default);
....

GraphicsDevice.SetDepthStencilState(GraphicsDevice.DepthStencilStates.None);

It is the same behavior for blend states and rasterizer states.

 

Thanks, that did the trick :) I was simply looking in the wrong place (doh).

 

Yes, I was talking about the toolkit.

 

As for the source code, I was looking here: https://github.com/sharpdx/SharpDX






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.