what happens is that there is no error anywere,but it works rare, the first frame i render it renders ok, the tetrahedron is in its place, then the second frame some vertex of the tetrahedron are in its place and the others are like very far away up, and then in the next frame it disapears.
plz help me i want to know why my tetrahedron is disappearing, this is getting me into a big stuck depressing hole, i have been reading and using now a geometry shader were my tetrahedron will still be in its place but the same happens, it disappears.
You transform your positions each frame over and over again with the transformation matrices. Points closer to the origin will stay a few iterations longer but eventually all your vertices will fly away.
So, modify a little the output of your vertex shader.
Output both the clipping space position and the world position. Write the world position back into the stream output and pass the clipping space position to the rasterizer only.
struct VS_OUTPUTT
{
float4 Pos : WORLDPOS; // position in world space (for the stream output)
float4 ClipPos : SV_POSITION; // position in clipping space (for the rasterizer)
float4 Color : COLOR;
float3 Vel : VEL;
float Ma : MA;
};
VS_OUTPUTT VS2( VS_INPUT input )
{
VS_OUTPUTT output = (VS_OUTPUTT)0;
output.Pos = input.Pos; // bypass the geometry (or deform somehow with your velocity)
// better pass in your geometry in world space!
// output.ClipPos = mul( input.Pos, World );
output.ClipPos = mul( output.Pos, View );
output.ClipPos = mul( output.ClipPos, Projection );
output.Color = input.Color;
output.Vel.x = input.Vel.x+(Time*Force.x);
output.Vel.y = input.Vel.y+(Time*Force.y);
output.Vel.z = input.Vel.z+(Time*Force.z);
output.Ma = input.Ma;
return output;
}
// Tell the geometry shader to output the world space position.
GeometryShader gss= ConstructGSWithSO( vss, "WORLDPOS.xyz; COLOR.xyzw; VEL.xyz; MA.x" );
hoo man this things that i dot see are insane, thank you i like will always need another person to tell me something because i become blind with my own mistakes.
hey master is my SOSetTargets()metod ok because now my problem is that the last vertex in my vertex structure isn't changing of place, color, etc, any attribute is changing
Only the last vertex causes trouble? So the first three vertices behave as they should?
That sounds to me like the number of vertices/primitives in the draw call, the input assembler or stream output setup doesn’t fit. Though, both your SOSetTarget and IASetVertexBuffer look fine, if your offset=0 and the stride=44=sizeof(SimpleVertex). 12 indices for a tet sounds reasonable, too. The primitive topology is a triangle list, I guess?
Do you unbind the vertex buffers from the input assembler and the stream output after rendering? ID3D11Buffer* noVB[] = {NULL};
UINT noOffset[] = {0};
UINT noStride[] = {0};
g_pd3dDevice->SOSetTargets(1, noVB, noOffset);
g_pd3dDevice->IASetVertexBuffers(0, 1, noVB, noStride, noOffset);
Otherwise D3D could complain (only with warnings in d3d debug mode) in the next rendering loop, when you bind your vertex buffer to the stream output stage that the vertex buffer is still but as input at the input assembler.
Could you please paste an updated version of the input assembler setup, the shader and the creation of your vertex and index buffer, here?
Or maybe just attach the program, so that I or someone else can do a debug run. A PIX dump would work for me too.
here it is all the projects
https://rapidshare.com/files/1943985478/yea.rar
Run it and you can control the camera with the movement of the mouse, the camera is pointing up by default so move the mouse all the way down and you will see the tetrahedron moving just in one direction for simplicity, you can use your "W"S"A"D" to move the camera too.
It seems to be a problem with the index buffer.
Your tet transforms just fine if you duplicate your vertices in the vertex buffer.
When using the index buffer, in PIX the buffer at the stream output stage is totally messed up, and if rendered with another topology but pointlists PIX crashes, when I try to look at the mesh.
If you don’t like duplicating your vertices here is an alternative: Usually I have a first pass in which I invoke one vertex shader / geometry shader per vertex by rendering the whole geometry as a pointlist. Thereby I stream the data out to another buffer and disable the rasterizer. Afterwards I render in a second pass the updated vertex buffer in combination with some index buffer to actually create geometry with topology.
.... thats bad news but... thanks!, do you know any complete example were they do the stream output and render? i really wana do it this way.. its faster no?
but how can the index buffer be a problem, is there something similar between the index buffer and the buffer used for stream output? i mean, do one interfere with the other in something?