Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 11 Aug 2007
Offline Last Active Jul 19 2012 01:52 AM

Topics I've Started

Geometry Shader Only Outputs 3 Vertices

19 July 2012 - 01:36 AM

I'm having troubles rendering a billboard quad, that's generated from a single vertex in the geometry shader. For some reason I can only emit 3 vertices. Here's my shader:

[source lang="cpp"]struct QuadVertexInput { float4 position_local : POSITION0; float4 color : COLOR0;};struct QuadVertexOutput { float4 position_projection : POSITION0; float4 color : COLOR0;};struct QuadGeometryOut { float4 position_screen : SV_Position; float4 color : COLOR0;}; struct QuadPixelOutput { float4 color : SV_TARGET;};QuadVertexOutput QuadVertexMain(QuadVertexInput input) { QuadVertexOutput output; output.position_projection = mul(input.position_local, world_matrix); output.color = input.color; return output;}[maxvertexcount(4)]void QuadGeometryMain(point QuadVertexOutput input[1], inout TriangleStream<QuadGeometryOut> stream) { QuadGeometryOut output = (QuadGeometryOut)0; float3 y_axis = float3(0.0f, 1.0f, 0.0f); float3 right = cross(y_axis, camera_direction); float3 up = cross(camera_direction, right); float3 center = input[0].position_projection; float4 vertex0 = float4(center + up * 0.5f + right * 0.5f, 1.0f); float4 vertex1 = float4(center - up * 0.5f + right * 0.5f, 1.0f); float4 vertex2 = float4(center - up * 0.5f - right * 0.5f, 1.0f); float4 vertex3 = float4(center + up * 0.5f - right * 0.5f, 1.0f); vertex0 = mul(mul(vertex0, view_matrix), projection_matrix); vertex1 = mul(mul(vertex1, view_matrix), projection_matrix); vertex2 = mul(mul(vertex2, view_matrix), projection_matrix); vertex3 = mul(mul(vertex3, view_matrix), projection_matrix); output.position_screen = vertex0; output.color = float4(1.0f, 0.0f, 0.0f, 1.0f); stream.Append(output); output.position_screen = vertex1; output.color = float4(0.0f, 1.0f, 0.0f, 1.0f); stream.Append(output); output.position_screen = vertex2; output.color = float4(0.0f, 0.0f, 1.0f, 1.0f); stream.Append(output); output.position_screen = vertex3; output.color = float4(1.0f, 1.0f, 0.0f, 1.0f); stream.Append(output);}QuadPixelOutput QuadPixelMain(QuadGeometryOut input) { QuadPixelOutput output; output.color = input.color; return output;}technique10 Quad { pass P0 { SetVertexShader(CompileShader(vs_4_0, QuadVertexMain())); SetGeometryShader(CompileShader(gs_4_0, QuadGeometryMain())); SetPixelShader(CompileShader(ps_4_0, QuadPixelMain())); }}[/source]

Can anyone help me out with what I'm doing wrong?

Here's an image of what it looks like:


Anim8tor with DirectX 9

11 August 2007 - 09:23 PM

I am a programmer that is fooling around with DirectX 9. I downloaded Anim8tor so that I could create my own meshes and load them into my programs, but whenever I create something in Anim8tor and convert its .3ds file to a .x file and load it into my program none of the materials reflect any light they just stay black. I am pretty sure that it is not my programming because my meshes made by scratch work and .x files that I have found on the net have worked fine as well. Suggestions?