Jump to content

  • Log In with Google      Sign In   
  • Create Account


Problem with shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 DarkRonin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 16 June 2014 - 07:40 PM

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, 16 June 2014 - 07:41 PM.


Sponsor:

#2 Samith   Members   -  Reputation: 2116

Like
3Likes
Like

Posted 16 June 2014 - 07:43 PM

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, 16 June 2014 - 07:52 PM.


#3 DarkRonin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 16 June 2014 - 07:49 PM

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

 

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


Edited by DarkRonin, 16 June 2014 - 08:14 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS