Problem with shader

Started by
1 comment, last by DividedByZero 9 years, 10 months ago

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

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?

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

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

This topic is closed to new replies.

Advertisement