Jump to content
  • Advertisement
Sign in to follow this  
?????? ?????????

DX11 wp8 problem

This topic is 2115 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

Hello!

I'm trying to make something on wp8 using dx11. And I have one bug. I'm trying to draw a picture with transparency.gpApp->m_deviceContext->IASetVertexBuffers( 0, 1, vertexbuffer.GetAddressOf(), &stride, &offset );
gpApp->m_deviceContext->PSSetShaderResources( 0, 1, pImage->m_texture.GetAddressOf() );
gpApp->m_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
gpApp->m_deviceContext->Draw( 3 * trianglesCount, 0 );
 

And all looks ok - 

runjpg_5973997_9210037.jpg.

I see transparent square on a picture.

 

But then I minimizing the app the transparent part is going black - 

suspendjpg_3882626_9210046.jpg

 

vertex shader----------------------------------------------------
struct VertexShaderInput
{
  float4 pos : POSITION;
  float4 color : COLOR0;
  float2 texcoord : TEXCOORD;
};


struct VertexShaderOutput
{
  float4 pos : SV_POSITION;
  float4 color : COLOR0;
  float2 texcoord : TEXCOORD;
};


VertexShaderOutput main(VertexShaderInput input)
{
  VertexShaderOutput output;


  output.pos = input.pos;
    output.texcoord = input.texcoord;
  output.color = input.color;


  return output;
}
----------------------------------------------------
 
pixel shader----------------------------------------
Texture2D Texture;
SamplerState ss;


struct PixelShaderInput
{
  float4 pos : SV_POSITION;
  float4 color : COLOR0;
  float2 texcoord : TEXCOORD;
};


float4 main(PixelShaderInput input) : SV_TARGET
{
  return Texture.Sample(ss, input.texcoord);
  //return input.color * Texture.Sample(ss, input.texcoord);
}
----------------------------------------------------
 

 

Please give me a direction that I have done wrong. Any ideas! Thanks!

Edited by Andrey.Mesheryakov

Share this post


Link to post
Share on other sites
Advertisement

We can safely assume that wp8 is Windows Phone 8, right? (Just have to ask)

  • Your shader code seems fine
  • To simplify our lives, put the code in the <> tool your thread editor gives you. (It makes it more readable wink.png )
  • Can we see your blend state, how is it defined?
  • Is the red in the background automatic, or is it something you draw as well? (Order matters!)

 

-MIGI0027

Share this post


Link to post
Share on other sites

Yes, wp8 mean Windows Phone 8.

 

Here is blend state creation -

D3D11_BLEND_DESC bd;
bd.RenderTarget[0].BlendEnable = TRUE;
bd.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
bd.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
bd.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; 
bd.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
bd.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
bd.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
bd.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
bd.IndependentBlendEnable = FALSE;
bd.AlphaToCoverageEnable = FALSE;


DX::ThrowIfFailed( m_device->CreateBlendState(&bd, &m_blendNormal) );

Red background is from here - 

float blendFactor[] = {1.0f, 1.0f, 1.0f, 1.0f}; 
m_deviceContext->ClearRenderTargetView( m_rendertarget.Get(), color );
Edited by Andrey.Mesheryakov

Share this post


Link to post
Share on other sites

Fixed. Blend state should be - 

D3D11_BLEND_DESC bd;
ZeroMemory(&bd, sizeof(bd));
bd.RenderTarget[0].BlendEnable = TRUE;
bd.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
bd.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; 
bd.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
bd.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
bd.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; 
bd.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
bd.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
bd.IndependentBlendEnable = FALSE;
bd.AlphaToCoverageEnable = FALSE;

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!