Skip to main content
GameDev.net gamedev.net
🔒 Locked

wp8 problem

Started by ?????? ????????? Sep 29, 2013 at 12:23 PM 2 replies 1.7k views
Original Post
?????? ?????????
?????? ?????????

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!

Veiled Glitch
Veiled Glitch

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

?????? ?????????
?????? ?????????

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 );
?????? ?????????
?????? ?????????

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;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.