i test if using pixel shader, SetTextureStageState has no effect
so how to use the texture's alpha value in pixel shader, i can not find any instruction
i test if using pixel shader, SetTextureStageState has no effect
so how to use the texture's alpha value in pixel shader, i can not find any instruction
I think that SetTextureStageState is FFP thing and it won't work with shaders.
...so how to use the texture's alpha value in pixel shader.
You must set some render states to enable alpha blending.
To set alpha blending based on texture alpha channel you could do this:
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
Like belfegor mention. In DirectX9 some of the render state still works while others no longer do anything once you use shaders.
Pixel shaders completely replace the old SetTextureStageState calls; see http://msdn.microsoft.com/en-us/library/windows/desktop/bb944006%28v=vs.85%29.aspx#Pixel_Shader_Basics
If you want to set a specific alpha value for use in a shader you either send it as a shader constant or pass it through from the vertex shader as a color attribute.
I think that SetTextureStageState is FFP thing and it won't work with shaders.
...so how to use the texture's alpha value in pixel shader.
You must set some render states to enable alpha blending.
To set alpha blending based on texture alpha channel you could do this:
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
i mean D3DTSS_ALPHAOP, how pixel shader gets texture's alpha
Pixel shaders completely replace the old SetTextureStageState calls; see http://msdn.microsoft.com/en-us/library/windows/desktop/bb944006%28v=vs.85%29.aspx#Pixel_Shader_Basics
If you want to set a specific alpha value for use in a shader you either send it as a shader constant or pass it through from the vertex shader as a color attribute.
i want to get the picture's alpha channel value
In pixel shader:
float4 textureColor = tex2D( samp, texCoord );
float alpha = textureColor.a;