Sign in to follow this  

Pixel Shader never gets called, but is set?

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

Hello there,

I'm trying to draw some "terrain" (when you can call a displaced grid without color a terrain ^^),

and (again) nothing is shown on the screen.

With the graphics debugging tools of VS2012 I found out that there is no pixel shader stage similiar to this problem:

http://msdn.microsoft.com/en-us/library/vstudio/jj191650.aspx

 

Altough I do set a pixel shader:

missing-pixel-shader.png

 

The code of my pixel shader:

struct VertexOut
{
	float4 pos : POSITION;
	float4 col : COLOR;
};
float4 main(VertexOut input) : SV_TARGET
{
	return input.col;
}

Share this post


Link to post
Share on other sites
Not sure if this is directly related to your pixel shader problem, but looking at your VertexOut struct I'm concerned about the semantics. If this is all what your vertex shader spits out (and you don't have any other stages between vertex and pixel shader) this can't work. You need the SV_Position system value semantic. The debug runtime should complain about this.

Share this post


Link to post
Share on other sites

Is VertexOut the data you're returning in your vertex shader? If you're passing in the projected vertices i think you need to set the semantic for your pos as SV_Position(or SV_POSITION?); not just POSITION.  Oops unbird already said this...

 

As an addition though... if the clip space vertices are also not in the viewport, your pixel shader won't get called too. So once you've get the semantics fixed and your pixel shader still isn't running, double check your view proj matrices and make sure you're passing these matrices to your shaders. Or just hard code the clip space values and pass these to your pixel shader.

Share this post


Link to post
Share on other sites

MS says that it is ok to use non SV_ Semantics. In that current case POSITION semantic is unrealted. The error could be anywere. Try something like this :

 

 

float4 ps_main(): SV_TARGET

{

 return float4(1.f, 1.f, 0.f, 1.f);//or other ugly color
}

 

That code will eventually prove that the problem is not in the PS.

 

After that try this:

 

float4 ps_main(float col : COLOR): SV_TARGET

{

 return col;//or other ugly color
}

 

Double check your projection view matrices!!!!

Edited by imoogiBG

Share this post


Link to post
Share on other sites

Hm changing the VertexOut structure to:

struct VertexOut
{
	float4 pos : SV_POSITION;
	float4 col : COLOR;
};

didn't help much.

Returning any color in the pixel shader neither did.

 

But I'm pretty sure that the matrices are correct since the image under "Vertex Shader" looks like this:

Vertex-Shader(PID%204156).png

 

Share this post


Link to post
Share on other sites

Yes. This code creates the viewport:

//Set the viewport
D3D11_VIEWPORT viewport;
ZeroMemory(&viewport, sizeof(viewport));
viewport.Width = float(width);
viewport.Height = float(height);
viewport.MaxDepth = 1.0f;
_devcon->RSSetViewports(1, &viewport);

And my vertex shader code:

cbuffer perObject
{
	float4x4 worldViewProj;
};
struct VertexOut
{
	float4 pos : SV_POSITION;
	float4 col : COLOR; 
};
VertexOut main( float4 pos : POSITION)
{
	VertexOut ret;
	ret.pos = mul(pos, worldViewProj);

	ret.col = float4(1.0f,1.0f,1.0f,1.0f);

	return ret;
}

Share this post


Link to post
Share on other sites

This topic is 1599 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.

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