• Advertisement
Sign in to follow this  

position coordinates from pixel shader?

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

I get this error during exekvation: D3D10: ERROR: ID3D10Device::DrawIndexed: Rasterization Unit is enabled (PixelShader is not NULL or Depth/Stencil test is enabled) but position is not provided by the last shader before the Rasterization Unit. [ EXECUTION ERROR #362: DEVICE_DRAW_POSITION_NOT_PRESENT ] At the same time, I notice that the depth buffer doesnt work since things further away is drawn on top of closer things. What to do? /Alex

Share this post


Link to post
Share on other sites
Advertisement
Looks like your vertex or geometrie shader (if used) does not specify the output register that contains the Position. You have to add the SV_POSITION semantic in your shader code.

If your depth buffer problem is only there with this shader or is it a general problem?

Share this post


Link to post
Share on other sites
I already have the SV_POSITION in my code,
and Im setting its values in the last geometry shader,
before the pixel shader.

I dont know if it is a general problem since I
have only made one techniqe10 so far.

Share this post


Link to post
Share on other sites
Could you show us your effect code?

Also, what does your input layout look like?


-SirKnight

Share this post


Link to post
Share on other sites
My input/output structs looks like this, I use VS_INPUT all the time except in the last GS:

struct VS_INPUT
{
float3 Pos : POSITION;
float3 Norm : NORMAL;
float2 Col : TEXCOORD0;
};

struct PS_INPUT //the pixel shader gets the coordinates from the geometry shader
{
float4 Pos : SV_POSITION;
float2 Tex : TEXTURE0;
float2 Col : TEXCOORD1;
float3 Norm : TEXCOORD0;
};

The effect is very simililar to the ParticleGS demo included in the documentation. I take out the vital parts:

Could it be something with the convertion from a float3 :POSITION to the required float4 SV_POSITION? Thanx


//------------------------------------------------------------------------------
// Vertex Shaders
//------------------------------------------------------------------------------VS_INPUT PassToGSGenerateParticles(VS_INPUT input){

return input;
}

VS_INPUT PassToGSCreateSprites(VS_INPUT input)
{
VS_INPUT output = (VS_INPUT)0;
output.Pos = mul(input.Pos, Scaling);
output.Norm = input.Norm;
output.Col = input.Col;
return output;
}

//------------------------------------------------------------------------------
//Geometryshader for generating particle system
//------------------------------------------------------------------------------

[maxvertexcount(1)] //max number of output points per primitive
void GSGenerateParticles(triangle VS_INPUT input[3], inout PointStream<VS_INPUT> PStream)
{
VS_INPUT output;

//lots of calculations...

output.Pos = input[0].Pos;
output.Norm = faceNormal;
output.Col = input[0].Col;
PStream.Append(output);


}

//------------------------------------------------------------------------------
// Geometry Shader for rendering point sprite particles. Takes a point (from
// particle system) and turns it into 2 tris.
//------------------------------------------------------------------------------

[maxvertexcount(4)]
void GSCreateSprites(point VS_INPUT input[1], inout TriangleStream<PS_INPUT> SpriteStream)
{
PS_INPUT output;

//lot of calculations, corners, etc...then:

for(int i=0; i<4; i++)
{
//convert float3 to float4
output.Pos = mul(float4(input[0].Pos,1), World );
output.Pos = output.Pos + float4((BrushSize*res),0.0); //four corners

output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Tex = texcoords[i]; //the four corners
output.Norm = normal;
output.Col = input[0].Col;
SpriteStream.Append(output);
}
SpriteStream.RestartStrip();

}

Share this post


Link to post
Share on other sites
GSGenerateParticles generates a stream of VS_INPUT structure. VS_INPUT does not have a SV_POSITION Element. I think you have to use PS_INPUT instead.

It may be a silly question but as this is changed for Direct3D 10 I am ask it:
Do you have created, attached and activate the Z-Buffer? D3D10 does not longer do this as part of the device creation.

Share this post


Link to post
Share on other sites
The stream generated by GSGenerateParticles goes to stream output, and the stream is put into PassToGSGenerateSprites.

I tried in some way to follow the ParticleGS sample, and it doesnt stream out PS_Position until its necessary (before drawout). Take a look at it, in what way should it be different here?

Im not sure about the Zbuffer, has that to do with depth stencil desk? I have tried setting up that with the same negative result.

Share this post


Link to post
Share on other sites
I found this problem occured when I used the simplest possible
flat shaded vertex-and pixel shader only renderer. So it must be
something fundamental call that I have missed? It should be noted
that Im new to directX and jumping directly into d3d10, I have no
experience of dx9.

Share this post


Link to post
Share on other sites
As Direct3D 10 is still in Beta I recommend stepping back to Direct3D 9. As there is no hardware for Direct3D 10 is available at the moment you would not have much fun with the slow software rasterizer that is part of the SDK.
Starting with direct3D 9 and HLSL will not a waste of time.

Share this post


Link to post
Share on other sites
I know but Im doing this as a project for school,
so it is more research oriented.

So again: What are they doing in the sample that I have
missed?

Share this post


Link to post
Share on other sites
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 primitive
void 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.

Share this post


Link to post
Share on other sites
Ok, so EVERY geometry shader has to output SV_POSITION, even if they not going to send the data directly to the pixel shader?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..?

Share this post


Link to post
Share on other sites
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 );
}
}

Share this post


Link to post
Share on other sites
Sorry, thanks a lot. It was the SetDepthStencilState( DisableDepth, 0 );
that was missing, now it works.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement