Jump to content
  • Advertisement
Sign in to follow this  
brekehan

states in HLSL

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

Can someone please point me to where the docs list all the syntax for setting states in HLSL? All I have to go off of is this and it is a far cry from a reference. For example, I am left wondering how to set the "render state" as they did in XNA from the application, in my DX10 app's shader:
   RenderState renderState = GraphicsDevice.RenderState;

   renderState.DepthBufferEnable = true;
   renderState.DepthBufferWriteEnable = false;
   renderState.AlphaTestEnable = false;
   renderState.ColorWriteChannels = ColorWriteChannels.None;

My HLSL, which doesn't compile and points an error to the line:
RenderState OcclusionRenderState
{
   ZENABLE = TRUE;
};

[Edited by - brekehan on May 18, 2009 7:48:21 PM]

Share this post


Link to post
Share on other sites
Advertisement
I'm guessing there is no such thing as a RenderState in DX10 and I have to use some combination of blend state and depth stencil state?

Also, how do I set all 8 elements of a variable to false?
Is there a better way then:


BlendState DefaultBlending
{
AlphaToCoverageEnable = FALSE;
BlendEnable[0] = FALSE;
BlendEnable[1] = FALSE;
BlendEnable[2] = FALSE;
BlendEnable[3] = FALSE;
BlendEnable[4] = FALSE;
BlendEnable[5] = FALSE;
BlendEnable[6] = FALSE;
BlendEnable[7] = FALSE;
SrcBlend = One;
DestBlend = One;
BlendOp = Add;
SrcBlendAlpha = One;
DestBlendAlpha = Zero;
BlendOpAlpha = Add;
RenderTargetWriteMask[0] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[1] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[2] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[3] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[4] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[5] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[6] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
RenderTargetWriteMask[7] = 0x0F; // D3D10_COLOR_WRITE_ENABLE_ALL
};

Share this post


Link to post
Share on other sites
Also, for depth stencil state it says:

Quote:

StencilRef
[in] Reference value to perform against when doing a depth-stencil test. See remarks.


Yet, the remarks have nothing about it. What is this value supposed to be?

Share this post


Link to post
Share on other sites
:/

So many questions, so little answerers...
Gimmie a P.O. Box, I'll send money to good teachers :)

Although the above questions still apply, I think I've got it working. My last hurdle is just translating that one XNA line:

Quote:

renderState.ColorWriteChannels = ColorWriteChannels.None;


I think this is how I should be doing it. Does that look correct?


BlendState OcclusionAlphaBlend
{
BlendEnable[0] = FALSE;
RenderTargetWriteMask[0] = 0x00; // Write no colors
};

DepthStencilState OcclusionDepthStencil
{
DepthEnable = TRUE;
DepthWriteMask = ZERO;
DepthFunc = Less;
StencilEnable = FALSE;
};


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!