swdever

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

176 Neutral

About swdever

  • Rank
    Newbie
  1. Good job! This should be the right answer.Thank you!
  2. Thank you for your answer. But the sample code,which I am studying, sets CullMode =  None. But the result is still perfect. After read you answer, I try to modify the code like this: CullMode = Front. Still the demo works well. Then I try to modify the code like this: CullMode = Back. This time, the skybox disappear. But other objects in my scene are rendered still. So I think maybe the CullMode isn't the key point in my problem.
  3.    Suppose my skybox is a sphere. I have learned that when draw a skybox, we can make the sphere's z value equal to its w value in the vertex shader, like this:     VertexOut VS(VertexIn vin) { VertexOut vout; //PosH stand for position in Homogeneous coordinate vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj).xyww; //PosL stan for position in local coordinate,used as a lookup vector in cubemap vout.PosL = vin.PosL; return vout; }      I can't totally undestand why we can do like that.  If we do so, after perspective divide, wouldn't there be two part of the sphere becomes in  the view frustum's far plane, one behind the camera originally and the other in front of the camera originally? If they already in the view frustum, then, how can the pipeline clip out the one which behind the camera originally? Hope someone help me figure it out?
  4.    Hey,    I am studying the sample ParticlesGS in the DX SDK. I try to implement a simpler fireworks myself. But there's some thing wrong in my Stream Out Geometry Shader. Here's my GS code. [maxvertexcount(100)] void StreamOutGS( point Particle input[1], inout PointStream<Particle> pStream ) { input[0].age += gTimeStep; if( input[0].type == PT_EMITTER ) GSEmitterHandler( input[0], pStream ); else if( input[0].type == PT_SHELL ) GSShellHandler( input[0], pStream ); else if( input[0].type == PT_EMBER1 ) GSEmber1Handler( input[0], pStream ); }     The struction and functions used in the StreamOutGS are defined before,like these: struct Particle { float3 pos : POSITION; float3 vel : VELOCITY; float2 size : SIZE; float age : AGE; uint type : TYPE; };     cbuffer cbFixed { float gSecondPerShell = 1.0; float gShellLife = 3.0; float gEmber1Life = 2.0; float3 gAcceW = { 0.0f, -9.8f, 0.0f }; }; #define PT_EMITTER 0//particle type #define PT_SHELL 1 #define PT_EMBER1 2 void GSGenericHandler( Particle input, inout PointStream<Particle> pStream ) { input.pos += input.vel * gTimeStep + 0.5 * gTimeStep * gTimeStep * gAcceW; input.vel += gTimeStep * gAcceW; pStream.Append( input ); } void GSEmitterHandler( Particle input, inout PointStream<Particle> pStream ) { if( input.age > gSecondPerShell ) { float3 vRandom = RandUnitVec( PT_SHELL );//return a random unit vector,defined before Particle p; p.pos = input.pos; p.vel = input.vel + 8.0f * vRandom; p.size = float2( 1.0f, 1.0f ); p.age = 0.0f; p.type = PT_SHELL; input.age = 0.0f; pStream.Append( p ); } pStream.Append( input ); } void GSShellHandler( Particle input, inout PointStream<Particle> pStream ) { if( input.age >= gShellLife ) { Particle p; float3 vRandom = float3( 0.0f, 0.0f, 0.0f ); for( int i = 0; i < 30; ++i ) { vRandom = RandUnitVec( PT_EMBER1 + i );////return a random unit vector p.pos = input.pos; p.vel = input.vel + 15.0 * vRandom; p.size = float2( 0.8f, 0.8f ); p.age = 0.0f; p.type = PT_EMBER1; pStream.Append( p ); } } else GSGenericHandler( input, pStream ); } void GSEmber1Handler( Particle input, inout PointStream<Particle> pStream ) { if( input.age < gEmber1Life ) GSGenericHandler( input, pStream ); }    It seems that the emitter works well. But the shell just explodes into one ember,not thirty as I defined,that is,maybe the loop in GSShellHandler  just loops one time for each shell,I guess.Can anybody tell me where the bug is?      In addition, I use the visual stdio 2012.I debug my HLSL code with its Graphics Diagnostic Tools. Each time I capture one frame,I only can access one input for debug. For example,if there are ten particles pass through my StreamOutGS,one emitter,two shells and seven embers.When I capture one frame and debug StreamOutGS,mostly,the input particle is a ember.I have no idea how to access and use the other nine particles to debug. Also,I don't know how to access a shell to debug at the exactly time it explodes. That's why I don't know how to debug my loop in GSShellHandler. Hope somebody give some help. 
  5.         I think you don't understand what I have asked. Maybe it because of my poor English. But I found the first link you provided is useful. I have got a deep understand in the circumstance I have encountered. Thank you!
  6.    I'm sorry there is an error in the figure I provided. It's my fault. I have corrected it. If D3D uses the order you provided to draw, that is, (v0, v1, v2) for the first triangle and (v1, v2, v3) for the second triangle. Then the first triangle's winding order will be clockwise and the second triangle's will be counter-clockwise .    I find the diagram of vertex ordering for primitive types in this link. http://msdn.microsoft.com/en-us/library/bb205124%28v=VS.85%29.aspx    Maybe using the standard rules, the two triangles will be (v0, v1, v2) and (v1, v3, v2)?
  7.    Hi! I am learning how the Geometry Shader works in D3D11. I am studying a sample which inputs one point into the Geometry Shader and outputs a quad each time. As shown in the figure below, the sample specifies the vertices generated by the Geometry Shader.(Sorry. I don't know how to upload a image. Hope you can understand the figure.)     v1               v3 ------------------ |                 | |                 | |                 | |                 | ------------------ v0                v2   With general method,if we want to draw a quad, we pass four vertices to the VertexBuffer, then create a IndexBuffer, binding them to the pipeline. Then the pipeline uses the data in the IndexBuffer and the VertexBuffer to draw two triangles what make up a quad. But in the sample I am studying, there is no IndexBuffer. The sample just generates these four vertices and append them to a TriangleStream object in the order: v0,v1,v2,v3, at the end of the Geometry Shader. Since D3D11 uses counter-clockwise culling state by default, visible triangles must be drawn in clockwise order. But how does the pipeline determine which three vertices of these four vertices to choose and their order to draw a visible triangle. There is no IndexBuffer in the sample. Maybe the Geometry Shader's output is drawn using a fixed index?Can anybody help me figure it out?   PS: The sample works well.
  8.    Hi! I am learning how the Geometry Shader works in D3D11. I am studying a sample which inputs one point into the Geometry Shader and outputs a quad each time. As shown in the figure below, the sample specifies the vertices generated by the Geometry Shader.(Sorry. I don't know how to upload a image. Hope you can understand the figure.)     v1               v2 ------------------ |                 | |                 | |                 | |                 | ------------------ v0                v3   With general method,if we want to draw a quad, we pass four vertices to the VertexBuffer, then create a IndexBuffer, binding them to the pipeline. Then the pipeline uses the data in the IndexBuffer and the VertexBuffer to draw two triangles what make up a quad. But in the sample I am studying, there is no IndexBuffer. The sample just generates these four vertices and append them to a TriangleStream object in the order: v0,v1,v2,v3, at the end of the Geometry Shader. Since D3D11 uses counter-clockwise culling state by default, visible triangles must be drawn in clockwise order. But how does the pipeline determine which three vertices of these four vertices to choose and their order to draw a visible triangle. There is no IndexBuffer in the sample. Maybe the Geometry Shader's output is drawn using a fixed index?Can anybody help me figure it out?   PS: The sample works well.