Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

timmay314

Simple pixel shader problem (HLSL)

This topic is 5227 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 just started messing with shaders today using HLSL, trying to get it to work in RenderMonkey. I''m having a very strange problem with a very simple pixel shader where I just try to swap the red and green components. It won''t compile, I get the following error message: COMPILE ERROR: API(D3D) /../Default DirectX Effect/Single Pass/Pixel Shader/ (3): error X5036: Read of uninitialized component(*) in r1: r/0 g/1 b/2 *a/3 Here''s my code
float sin_time_0_X;
sampler Texture0;

float4 ps_main( float4 inDiffuse: COLOR0, float2 inTex : TEXCOORD0) : COLOR0
{
   float4 color = tex2D(Texture0, inTex); // this line is the problem
   float red = color.r;
   color.r = color.g;
   color.g = red;

   return color;
}
 
However, if I just do this it works fine, even though the line that is giving me the error is unchanged:
float4 ps_main( float4 inDiffuse: COLOR0, float2 inTex : TEXCOORD0) : COLOR0
{
   float4 color = tex2D(Texture0, inTex);

   return color;
}
 
It seems to think that color.r is fine but color.g, b, or a has not been given a value. What''s wrong with this?

Share this post


Link to post
Share on other sites
Advertisement

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