hlsl constant

Started by
2 comments, last by jollyjeffers 18 years, 2 months ago
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.
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.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Ok but it is the same that constant table finaly (it use it I think).

Thank you.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement