Jump to content
  • Advertisement
Sign in to follow this  
schupf

HLSL: Uniform default values

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

Hello,

I have a little HLSL shader with one uniform variable and I want to give this uniform a default value. I tried it like this:


float4 u_color = float4(1, 0, 0, 1);

PS_OUTPUT main(VS_OUTPUT In) {
PS_OUTPUT Out;
Out.color = u_color;
return Out;
}

If I want to I can set u_color in the C++ host code but if I do not set it explicitely, the default color (set in the shader file) should be used.
Unfortunately the code above does not work. The object is always white and not red.

Anyone know what I am doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Default values for shader constants will not be set automatically unless you use the effects framework. If you use raw shaders, then you will have to use shader reflection to get the default value and then set it yourself.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!