Jump to content
  • Advertisement
VietNN

DX12 Shader4ComponentMapping explain?

Recommended Posts

Hi all,

The D3D12_SHADER_RESOURCE_VIEW_DESC has a member Shader4ComponentMapping but I don't really know what is it used for? As several example set its value to D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING. I also read the document on MSDN but still do not understand anything about it.

https://msdn.microsoft.com/en-us/library/windows/desktop/dn903814(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/dn770406(v=vs.85).aspx

Anyone could help me, thank you.

Edited by VietNN

Share this post


Link to post
Share on other sites
Advertisement

In older API's there were some formats that, when fetched in the shader as a float4 value, you'd get (Red, Red, Red, 1), or (Red, Green, Blue, 1) or (Blue, Green, Red, Alpha), or (Red, Green, 0, 1), etc...

In Dx12, you're given control over this behaviour yourself. If you want the shader's float4 'x' value to contain the data from the texture's green channel, you can do that. If you want to hard-code the alpha result to 0 or 1, you can do that.

Typically though you set it to return (Red, Green, Blue, Alpha) / a.k.a. (component 0, component 1, component 2, component 3) 

Share this post


Link to post
Share on other sites

Hi Hodgman, thanks for a quick respone,

So you mean in older API, some format like RGB (only 3 channel) will be fetched as RGBA(A=1) in shader ? (or I missunderstood).

One more question, in Dx12 if I send a texture RGB, Do I have to force alpha to 0 or 1 (by setting others flag not using the DEFAULT_MAPPING flag)? or what will happen if I still using default mapping flag?

Thank you

Edited by VietNN

Share this post


Link to post
Share on other sites

Lemme give you an example: A block compressed format, such as BC5, which only has R+G, will by default return B=0 and A=1 (I hope). You can force 1 or 0 into any channel, you can shuffle channels around, you can use some of them 1-4 times and you can drop any of them or all of them (replacing them by 0 or 1). I can't think of too many uses for this though.

Edited by pcmaster

Share this post


Link to post
Share on other sites

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

  • 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!