position coordinates from pixel shader?

Started by
14 comments, last by alebo611 17 years, 9 months ago
The inout part of a gemetry shader have to output an element with the SV_POSITION semantic. You have used VS_INPUT which doesn’t meet this requirement. You should use PS_INPUT or a new defined structure there.

[SOURCE][maxvertexcount(1)] //max number of output points per primitivevoid GSGenerateParticles(triangle VS_INPUT input[3], inout PointStream<PS_INPUT> PStream){PS_INPUT output;//lots of calculations...output.Pos = input[0].Pos;output.Norm = faceNormal;output.Col = input[0].Col; PStream.Append(output);}[/SOURCE]


To solve your depth buffer problem you have to create a 2D Texture with a depth format. Then create a depth stencil view. Set it together with your render target view. Finally you will need a depth stencil state object that has to be set to the output merger.

I have some code for this but I am not on my vista system at the moment.
Advertisement
Ok, so EVERY geometry shader has to output SV_POSITION, even if they not going to send the data directly to the pixel shader?
The SV_POSITION semantic is not for pixel shader. The rasterizer use it to decide were in your outputted data it should look for the position. As the only way to the pixel shader goes through the rasterizer you will always need a SV_POSITION element if you use a pixel shader. In the case you use the stream out function the data never reach the rasterizer and you don’t need a SV_POSITION element.
Yes Im using stream out function!!

It goes like following:

1) Input mesh->PassToGSGenerateParticles->GSGenerateParticles->STREAM OUTPUT

that means I dont have to use SV_Position. Then:

2) STREAM OUTPUT->PassToGSCreateSprites->GSCreateSprites->PIXELSHADER

As you can see GSCreateSprites uses SV_Position, and
it works well if I skip the first (1) technique.

First you say GSGenerateParticles needs SV_Position, then you tell it doesnt
if I use stream out..?
How should I know this? You have not posted the techniques part of your FX file and the source code of your render function.

In the case you work with stream out the problem is another one.

Make sure that your pixel shader is set to NULL and that the depth test is disabled

In the FX File:

DepthStencilState DisableDepth{    DepthEnable = FALSE;    DepthWriteMask = 0;};[...]technique10 xyz{  pass xyz  {    [...]    SetPixelShader( NULL );            SetDepthStencilState( DisableDepth, 0 );  }}
Sorry, thanks a lot. It was the SetDepthStencilState( DisableDepth, 0 );
that was missing, now it works.

This topic is closed to new replies.

Advertisement