Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

Problem with shader

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

Hi Guys,

 

I am trying my hand at HLSL for the first time in DirectX 11.

 

I have attempted to write a shader that just colors the quad that I have created (with a view to expanding it to display a texture later on).

 

But, I am not getting anything displayed on the screen. I know the quad is there, as it displays color ok with a different shader (and slight modification to my code).

 

Here is the buggy shader (go easy on me, I am just learning smile.png )

struct VOut
{
 float4 position : POSITION;
 float4 color   : COLOR;
 float2 tex0  : TEXCOORD0;
};

VOut VShader(float4 pos : POSITION, float4 col : COLOR, float2 tex : TEXCOORD0)
{
 VOut output;
 output.position = pos;
 output.color = col;
 output.tex0 = tex;
 return output;
}

float4 PShader(float4 pos : SV_POSITION, float4 col : COLOR, float2 tex : TEXCOORD0) : SV_TARGET
{
 return col;
}

I am using debug mode and also error checking all of my function calls. So, I know the shader compiles ok, but my understanding isn't good enough yet to know where I am going wrong.

 

Any help would be awesome smile.png

Edited by DarkRonin

Share this post


Link to post
Share on other sites
Advertisement

Vout::position should have the SV_POSITION semantic, not POSITION.

 

EDIT: Other things that could mess you up: is your vertex color correct? Are you doing any alpha blending? If so, are you sure the alpha component of the vertex color is 1? If you try to write out float4(1,1,1,1) instead of col in the pixel shader do you get a white quad? 

Edited by Samith

Share this post


Link to post
Share on other sites

Vout::position should have the SV_POSITION semantic, not POSITION.

 

Thanks for the quick reply. I just noticed that also.

Edited by DarkRonin

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!