Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


wp8 problem


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
3 replies to this topic

#1 Andrey.Mesheryakov   Members   -  Reputation: 102

Like
0Likes
Like

Posted 29 September 2013 - 06:23 AM

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, 29 September 2013 - 07:54 AM.


Sponsor:

#2 Migi0027   Crossbones+   -  Reputation: 2132

Like
0Likes
Like

Posted 29 September 2013 - 06:43 AM

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


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!

#3 Andrey.Mesheryakov   Members   -  Reputation: 102

Like
0Likes
Like

Posted 29 September 2013 - 08:01 AM

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, 29 September 2013 - 08:02 AM.


#4 Andrey.Mesheryakov   Members   -  Reputation: 102

Like
0Likes
Like

Posted 29 September 2013 - 09:22 AM

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;





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