2014-06-16 6 views
0

저는 directX 11에서 투명한 픽셀을 렌더링하려고합니다. 셰이더를 만들거나 블렌드 상태가 자동으로 수행해야하는지 잘 모르겠습니다. 이전에는 자동으로 처리 한 것으로 생각했지만 투명한 텍스처는 텍셀마다 손실되는 단색으로 렌더링되었습니다. 원래 텍스처는 (7, 7, 7, 139)이고 렌더링 된 색상은 (38, 47, 56, 255)입니다. enter link description here다른 모든 텍셀에서 DirectX 11 투명 블렌딩이 누락되었습니다

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

픽셀 쉐이더

float4 TexturePixelShader(PixelInputType input) : SV_TARGET { 
float4 textureColor; 
textureColor = shaderTexture.Sample(SampleType, input.tex); 
//discard pink for sprite transparency 
if(textureColor.r == 1.0f && textureColor.g == 0.0f && textureColor.b == 1.0f) { 
    discard; 
} 
//set the colour white as the specified pixel colour 
if(textureColor.r == 1.0f && textureColor.g == 1.0f && textureColor.b == 1.0f) { 
    textureColor = textureColor * pixelColor; 
} 
return textureColor; 
} 

답변

2

해제 AlphaToCoverage

enter image description here

. 멀티 샘플링 렌더링에만 사용해야합니다.

+0

이렇게하면 화면이 검게 변하지 만 블렌드 설명을 구성하여이 문제를 해결할 수 있습니다. 도움을 주셔서 감사합니다 : D – Anthony

+0

그래, 고쳐. 거대한 감사 인사를하고 싶습니다. 나는이 시간에 곤란한 시간을 보냈습니다. 신의 축복, 돌보기 <3 – Anthony

+0

당신을 진심으로 환영합니다. –