• Advertisement
Sign in to follow this  

[DX10] Triangle not being rasterized

This topic is 3518 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'm trying to draw a simple triangle using basic vertex and pixel shaders (no geometry shader set). Pix is telling me that the vertices are being correctly transformed in the vertex shader, but then the rasterizer is (apparently) only drawing the first pixel, or the vertex positions have all been sucked into the exact centre of the screen (also the location of the first vertex). If I change the position of the first vertex, even just nudge it to (-1, 0, 0) the single pixel disappears (yet it still looks fine Post-VS in Pix). Free Image Hosting at www.ImageShack.us The viewport setup is.. Width = 640; Height = 480; MinDepth = 0.0f; MaxDepth = 1.0f; TopLeftX = 0; TopLeftY = 0; I am still able to render my skybox (cube + cubemap) absolutely fine without any major state changes (just a different effect). Has anyone got any ideas? Thanks in advance, Ed [Edited by - Degra on July 6, 2008 2:27:34 PM]

Share this post


Link to post
Share on other sites
Advertisement
Have you checked if your Cullmode match your triangle vertex order?

Share this post


Link to post
Share on other sites
Quote:
Original post by Demirug
Have you checked if your Cullmode match your triangle vertex order?


Culling is turned off.

This is the rasterizer state..

FillMode = D3D10_FILL_SOLID;
CullMode = D3D10_CULL_NONE;
FrontCounterClockwise = true;
DepthBias = false;
DepthBiasClamp = 0;
SlopeScaledDepthBias = 0;
DepthClipEnable = false;
ScissorEnable = false;
MultisampleEnable = false;
AntialiasedLineEnable = false;

Share this post


Link to post
Share on other sites
try changing FrontCounterClockwise to false, and check again. If it works now, you specified the vertices in the false order...

Share this post


Link to post
Share on other sites
Quote:
Original post by MadMax1992
try changing FrontCounterClockwise to false, and check again. If it works now, you specified the vertices in the false order...


Nope, still nothing except that one pixel :(.

Share this post


Link to post
Share on other sites
float4x4 cWVP : WORLDVIEWPROJECTION;

struct VS_INPUT
{
float3 position : POSITION;
float4 colour : COLOUR;
};

struct VS_OUTPUT
{
float4 position : SV_Position;
float4 colour : COLOUR;
};


struct PS_OUTPUT
{
float4 colour : SV_Target;
};



VS_OUTPUT Pass0VertexShader( VS_INPUT IN )
{
VS_OUTPUT OUT;

OUT.position = mul(float4(IN.position, 1.0f), cWVP);
OUT.colour = IN.colour;
return OUT;
}

PS_OUTPUT Pass0PixelShader( VS_OUTPUT IN )
{
PS_OUTPUT OUT;

OUT.colour = float4(IN.colour.rgb,1.0f);
return OUT;
}




technique10 Debug
{
pass Pass0
{
SetVertexShader(CompileShader( vs_4_0, Pass0VertexShader() ));
SetGeometryShader(NULL);
SetPixelShader(CompileShader( ps_4_0, Pass0PixelShader() ));
}
}

[Edited by - Degra on July 7, 2008 2:27:08 AM]

Share this post


Link to post
Share on other sites
Shouldn't you need a value colour in your VS_OUTPUT structure? since you are accessing it in the pixelshader?

Share this post


Link to post
Share on other sites
Quote:
Original post by littlekid
Shouldn't you need a value colour in your VS_OUTPUT structure? since you are accessing it in the pixelshader?


he is right, struct VS_OUTPUT doesn't contain float4 colour.

maybe you should check error messages you receive when you compile the shaders.
If a shader can't compile and you try to use it, it will just skip the rendering for those primitives.

Share this post


Link to post
Share on other sites
Whoops, I've fixed the shader (somehow it didn't copy correctly) and will post the draw call when I get home.

Share this post


Link to post
Share on other sites
The draw call is simply

g_d3dDevice->Draw(3, 0);

The right vertex buffer is assigned and the vertices are correctly transformed in the vertex shader. I believe its the rasterizer that's doing *something* weird, but I've no idea what.

Share this post


Link to post
Share on other sites
By draw call I meant all code around (the "set state" of the output merger, input assembler, etc)

Share this post


Link to post
Share on other sites
Quote:
Original post by XVincentX
Have you checked the buffer creation??


Post also the buffer creation.

P.S. Have you set primitive topology?

Share this post


Link to post
Share on other sites
Quote:
Original post by XVincentX
P.S. Have you set primitive topology?


Silly me! I'd accidently been specifying a value from my vertex type enum which happened to equate to D3D10_PRIMITIVE_TOPOLOGY_POINTLIST. The point in the screen's centre was the first vertex, the other two were off-screen.

Thanks guys!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement