Sign in to follow this  

hlsl constant

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

This topic is 4338 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.

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

Sign in to follow this