Sign in to follow this  
lonewolff

Problem with shader

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

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

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