Jump to content
  • Advertisement
Sign in to follow this  
alebo611

position coordinates from pixel shader?

This topic is 4431 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
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; //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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!