Jump to content
  • Advertisement
Sign in to follow this  
Woodchuck

hlsl constant

This topic is 4551 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 read in the pdf about hl2 shading :
Quote:
Constant Controls •Direct-mapped to specific registers –Consistency with legacy paths –Don’t have to deal with HLSL constant table const float4g_EnvmapTint: register( c0 ); const float3g_EnvmapContrast: register( c2 ); const float3g_EnvmapSaturation: register( c3 ); const float4g_FresnelReflectionReg: register( c4 ); const floatg_OverbrightFactor: register( c6 ); const float4g_SelfIllumTint: register( c7 );
How do you set hlsl constant without using a constant table ? I see how for texture sampler and texture, but not for constant : integer, matrix etc. Thanx EDIT: http://www2.ati.com/developer/gdc/D3DTutorial10_Half-Life2_Shading.pdf.

Share this post


Link to post
Share on other sites
Advertisement
Quote:

How do you set hlsl constant without using a constant table ? I see how for texture sampler and texture, but not for constant : integer, matrix etc.

If you use the effects framework (ID3DXEffect), it is very easy. There are a number of functions you can use to do it, such as:

SetValue() (this is the general one that can set any type)
SetMatrix()
SetInt()
SetBool()
SetFloat()
SetVector()

All of these also have array versions that let you set an array of constants.

Share this post


Link to post
Share on other sites
I think the effects framework uses constant tables internally whether you like it or not. It's when you're dealing with the raw pixel/vertex shaders that you can ignore it (specify NULL instead of a pointer for an ID3DXConstantTable during compilation).

If you use the shaders directly, you can then use SetPixelShaderConstantB(), SetPixelShaderConstantF() and SetPixelShaderConstantI() to get at the register contents directly.

hth
Jack

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.

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!