Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


HLSL Pixel Shader returns (0,0,0,0)


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
3 replies to this topic

#1 sas_x86   Members   -  Reputation: 102

Like
0Likes
Like

Posted 08 May 2012 - 09:13 AM

Hello.
There is a shader which implements shadow map technique
struct VS_INPUT { float4 Pos : POSITION0; float4 Normal: NORMAL; float4 Color : COLOR; float2 TexCoords : TEXCOORD0; float4 TexWeights : TEXCOORD1; };

float4x4 xLightWorld;
float4x4 xLightView;
float4x4 xLightProjection;

struct SMapVertexToPixel { float4 Position : POSITION0; float4 Position2D : POSITION1; };

SMapVertexToPixel ShadowMapVertexShader(VS_INPUT In)
{ SMapVertexToPixel Output = (SMapVertexToPixel)0;
Output.Position = mul(In.Pos, xLightWorld);
Output.Position = mul(Output.Position, xLightView);
Output.Position = mul(Output.Position, xLightProjection);
Output.Position2D = Output.Position; return Output; }

float4 ShadowMapPixelShader(SMapVertexToPixel PSIn) : COLOR
{
	 return float4(PSIn.Position2D.z/PSIn.Position2D.w, 0, 0, 1);
}

I run this code in PIX in Debugger window and for some pixel i have
ShadowMapPixelShader | ( 0.161, 0.000, 0.000, 1.000 ) | float4
but in Render window all pixels are black.
If i change code
float4 ShadowMapPixelShader(SMapVertexToPixel PSIn) : COLOR
{
	 return float4(0.5f, 0, 0, 1);
}
all pixels will be little bit red.
Why?

Sponsor:

#2 NickUdell   Members   -  Reputation: 288

Like
0Likes
Like

Posted 11 May 2012 - 05:46 AM

Can you check in pix that your matrices are definitely being set?

May I also ask why Output.Position and Output.Position2D are identical? Seems a bit of a waste of space and resources...
Sole Creator of Pigment - a procedural, block-base space trading sim.

PhD student working on medical imaging at the University of Southampton.

Enjoyer of games, films, books and cider.

#3 sas_x86   Members   -  Reputation: 102

Like
0Likes
Like

Posted 15 May 2012 - 09:13 AM

Can you check in pix that your matrices are definitely being set?

May I also ask why Output.Position and Output.Position2D are identical? Seems a bit of a waste of space and resources...

Hello.
My matrices are set. I can see it in Mesh window of Pix (Pre-vertex shader, Post-Vertex shader and Viewport is correct).
Output.Position and Output.Position2D are identical because i thought that after vertex shader i can't use a Position field in the Pixel Shader.

#4 NickUdell   Members   -  Reputation: 288

Like
0Likes
Like

Posted 15 May 2012 - 11:51 AM

You can use the position value in the pixel shader, it'll be interpolated between the vertices so it will be the position at that pixel.

Looks to me like you're outputting depth at that point. What are you near and far plane values? If you have a really large range then the object might appear with a very dark colour due to how far away it is. Could you set it to return 1 - depth to make sure it's definitely setting the pixel colour there?
Sole Creator of Pigment - a procedural, block-base space trading sim.

PhD student working on medical imaging at the University of Southampton.

Enjoyer of games, films, books and cider.




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