Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

shader problem ?

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



**********************************************
PassThruGS.vsh

Vertex shader that passes on particle data
to the geometry shader without change
The geometry shaders do all the update
& rendering work for this particle system
***********************************************/

//-----------------------------------------------------------------------------
// Input / output structures
//-----------------------------------------------------------------------------

// Input and output from vertex shader - particle data

float4x4 ViewProjMatrix;
float4x4 InvViewMatrix;

// GPU is performing some scene update, so it needs timing info
float Time;


struct VS_InputOutput
{
float3 Position : POSITION;
float3 Velocity : TEXCOORD0;
float Life : PSIZE0;
float Delay : PSIZE1;
};
struct GS_VertInOut
{
float3 Position : POSITION;
float3 Velocity : TEXCOORD0;
float Life : PSIZE0;
float Delay : PSIZE1;

};




//-----------------------------------------------------------------------------
// Main function
//-----------------------------------------------------------------------------

VS_InputOutput VS( in VS_InputOutput i)
{
VS_InputOutput o;
o = i;
return o;
}

//-----------------------------------------------------------------------------
// Main function
//-----------------------------------------------------------------------------

[maxvertexcount(1)] // This shader deals with particles one at a time. When a particle dies, it is immediately respawned,
// so this shader will always output one particle as well
void GS
(
point GS_VertInOut inParticle[1], // One particle in, as a point
inout PointStream<GS_VertInOut> outParticles // Must output a point stream, will only contain the one updated point
)
{
const float3 Gravity = { 0, -9.8f, 0 };

inParticle[0].Delay -= Time;
if (inParticle[0].Delay < 0)
{
// Fairly general purpose particle update code
inParticle[0].Life -= Time;
inParticle[0].Position += inParticle[0].Velocity * Time;
inParticle[0].Velocity += Gravity * Time;
outParticles.Append( inParticle );
}
}


technique10 particleUpdate
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( CompileShader( gs_4_0, GS() ) );
SetPixelShader( NULL );

//SetBlendState( NoBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
//SetRasterizerState( CullNone );
//SetDepthStencilState( DepthWritesOff, 0 );
}
}


its for an update for paricles so all the particle maths are done on the gpu .

fx composer says " not all elements of SV_Position were writen .

i cant figure out its meaning or how to get around it , any ideas

Share this post


Link to post
Share on other sites
Advertisement
When you output SV_Position from a vertex or geometry shader (which is typedef'ed as POSITION if you compatibility mode enabled when compiling shaders) it needs to be a float4 position that's in post-projection clip space. You seem to just be outputting some sort of world-space position from your geometry shader, which isn't going to work. You need to apply your projection matrix and output the resulting float4 as SV_Position in order for the pipeline to be able to rasterize the triangles.

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!