locked
Render Targets RRS feed

  • Question

  • So, I need to create a pixel shader.  This pixel shader is going to be applied across the screen, so a render target is needed. I set up the render target, cleared it to black, and then had the render target texture drawn.  TADA, I get a big black image.  Perfect.

    Then, after I cleared the render target, I drew a sprite to the render target, thinking that I would see the sprite right smack dab on top of a black background.  But instead of drawing the sprite, it seems the sprite has almost made a cutout from the render target.  Because now there's a black image with a square straight in the middle, where previously drawn images are being shown.

    I've used the graphics debugging tools to check the image from the pixel shader, and it seems to have something to do with the alpha of the picture.  It's strange, though, the pixel shader spits the pixel out fully opaque, yet the pixel from the pixel shader isn't applied and the previous pixel wins.

    Any help, thanks.

    Tuesday, November 20, 2012 12:16 AM

All replies

  • Hello,

    Would you please provide us the whole codes to reproduce this issue,

    You can upload your project to skydriver
    http://skydrive.live.com/

    It is not necessary that you send out the whole of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business details from it.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 22, 2012 8:51 AM
    Moderator
  • Once you have a texture you need a shader resource, that why your screen is black.

    	////////////////////////////////////////////////////////////////////////////
    
    	UINT fred;
    	m_d3dDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 16, &fred);
    
    	D3D11_TEXTURE2D_DESC desc;
    	ZeroMemory(&desc, sizeof(D3D11_TEXTURE2D_DESC));
    	desc.ArraySize = 1;
    	desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
    	desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    	desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    	desc.MipLevels = 1;
    	desc.MiscFlags = 0;
    	desc.SampleDesc.Count = 1;
    	desc.SampleDesc.Quality = fred;
    	desc.Usage = D3D11_USAGE_DYNAMIC;
    	desc.Width = screenwidth;
    	desc.Height = screenheight;
    	desc.MiscFlags = 0;
    
    
    	D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDescription;
    	ZeroMemory(&renderTargetViewDescription, sizeof(renderTargetViewDescription));
    	renderTargetViewDescription.Format = desc.Format;
    	renderTargetViewDescription.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; // MS;
    
    


    n.Wright

    Thursday, September 26, 2013 9:06 PM
  • You should double-check your ID3D11BlendState and ID3D11DepthStencilState.

    BTW, you may want to look at SpriteBatch in the DirectX Tool Kit and the DirectXTK Simple Sample

    https://directxtk.codeplex.com/wikipage?title=Samples

    Friday, September 27, 2013 9:15 PM