Jump to content

  • Log In with Google      Sign In   
  • Create Account

Cannot get textured quad visible


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Mclankyman   Members   -  Reputation: 110

Like
0Likes
Like

Posted 08 May 2013 - 11:34 AM

Hi all.

 

I just wanted to do a simple 2D game using directx11 (as I have been using direct 9 mostly).

 

I set up a 2D sprite class which was to render 2 triangles making a square and giving it a texture to represent the sprite.

 

Now all this compiles but I cannot get the sprite visible on screen.

 

 

The directx breakdown on PIX is attached. It's showing that all my vertices are correct and the vertex shader is doing what it's supposed to.

 

PIX.png

 

 

So can only assume it is something to do with the rasterizer or output merger as I have tried just outputting a colour from my pixel shader instead of a texture sample.

 

My rasterizer state is

 

D3D11_RASTERIZER_DESC rastDesc;
	ZeroMemory( &rastDesc, sizeof( rastDesc ) );
	rastDesc.FillMode =  D3D11_FILL_SOLID ;
	rastDesc.CullMode =  D3D11_CULL_NONE   ;
	rastDesc.FrontCounterClockwise = false;
    rastDesc.DepthBias = 0.0f;
	rastDesc. DepthBiasClamp = 0.0f;
	rastDesc. SlopeScaledDepthBias = 0.0f;
	rastDesc.DepthClipEnable = true;
	rastDesc.ScissorEnable = false;
	rastDesc.MultisampleEnable = false;
	rastDesc.AntialiasedLineEnable = false;

	Program::GetInstance()->GetD3DDevice()->CreateRasterizerState(&rastDesc, & m_rasterizerState);
	Program::GetInstance()->GetD3DDeviceContext()->RSSetState(m_rasterizerState);

My blender state is

 

D3D11_BLEND_DESC blendDesc;
    ZeroMemory( &blendDesc, sizeof( blendDesc ) );
    blendDesc.RenderTarget[0].BlendEnable = TRUE;
    blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
    blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
    blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
    blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
    blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC1_ALPHA;
    blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC1_ALPHA;
    blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

    float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };

    Program::GetInstance()->GetD3DDevice()->CreateBlendState( &blendDesc, &alphaBlendState_ );
    Program::GetInstance()->GetD3DDeviceContext()->OMSetBlendState( alphaBlendState_, &blendFactor, 0xFFFFFFFF );

Im using this projection matrix also as it's 2D.

 

Matrix projection = XMMatrixOrthographicOffCenterLH( 0.0f, 1000.0f, 0.0f, 1000.0f, 0.0f, 2.0f );

 

 I am all out of ideas as to what the issue could be.

 

Thanks

 

 



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 08 May 2013 - 04:54 PM

Have you tried to debug a pixel that should be affected by that sprite in PIX?  It should show you if the pixel was generated (i.e. it made it past the rasterizer stage) and also why it was discarded (i.e. depth/stencil test) or if it was blended (in which case it would be a blend issue).

 

Just right click on the pixel in your output render target and you should be able to debug what is going on.



#3 ankhd   Members   -  Reputation: 1283

Like
0Likes
Like

Posted 08 May 2013 - 09:10 PM

Hello. It looks like it is small

#4 Mclankyman   Members   -  Reputation: 110

Like
0Likes
Like

Posted 09 May 2013 - 10:04 AM

Thanks, I was looking how to debug a pixel rather than a vertex.

 

It has told me that it is discarded because it has failed the depth test.

 

The vertices have a depth of 0.25 post vertex shader. Meaning they should be visible. Plus it is the only geometry being rendered so it cant be underneath anything else.

 

So it must either be my raster code

 

D3D11_RASTERIZER_DESC rastDesc;
	ZeroMemory( &rastDesc, sizeof( rastDesc ) );
	rastDesc.FillMode =  D3D11_FILL_SOLID ;
	rastDesc.CullMode =  D3D11_CULL_NONE   ;
	rastDesc.FrontCounterClockwise = false;
    rastDesc.DepthBias = 0.0f;
	rastDesc. DepthBiasClamp = 0.0f;
	rastDesc. SlopeScaledDepthBias = 0.0f;
	rastDesc.DepthClipEnable = true;
	rastDesc.ScissorEnable = false;
	rastDesc.MultisampleEnable = false;
	rastDesc.AntialiasedLineEnable = false;

	Program::GetInstance()->GetD3DDevice()->CreateRasterizerState(&rastDesc, & m_rasterizerState);
	Program::GetInstance()->GetD3DDeviceContext()->RSSetState(m_rasterizerState);

 

Or the projection Matrix's final two values.

 

Matrix view = XMMatrixIdentity( );
Matrix projection = XMMatrixOrthographicOffCenterLH( 0.0f, 1000.0f, 0.0f, 1000.0f, 0.0f, 2.0f );
m_viewProj = XMMatrixMultiply( view, projection );

But I thought what I had wrote meant anything between 0.0 and 2.0 in world space would be visible.



#5 Mclankyman   Members   -  Reputation: 110

Like
0Likes
Like

Posted 09 May 2013 - 10:56 AM

I've sorted it. I wasn't clearing the depth buffer.

 

Although to be fair I thought this would have just rendered the image first frame then stuck like that.

 

Obviously being a problem once other objects had to be rendered.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS