Multiple render targets problem

Started by
2 comments, last by hemu 16 years, 2 months ago
Hey guys, I'm running into a problem with multiple render targets. I somehow can't render to the second render target texture which is of the same properties as that of the first one. The second render target texture just renders with a clear color that I specify, but no info is generated on it. Here is my Pixel Shader: struct PSOUT { float4 diffuseColor: COLOR0; float4 depth: COLOR1; }; PSOUT MyPS(float4 pos:POSITION, float2 tc:TEXCOORD0, float4 lightIntensity:TEXCOORD6, float4 depth: TEXCOORD1) { PSOUT pixelOutput; float4 color = tex2D(mysamplerstate, tc); color.rgb *= lightIntensity.x; pixelOutput.diffuseColor = color; pixelOutput.diffuseColor.w = 1.0f; pixelOutput.depth.rgb = depth.x; pixelOutput.depth.a = 1.0f; return pixelOutput; } I can see the depth info if I swap the COLOR0 and COLOR1, effectively rendering the depth to render target 1. But no luck in rendering to render target 2.
Advertisement
Try checking your renderstate prior to rendering. It sounds like color writes might be disabled for the second redertarget.
I added the following line of code before rendering to any render target:

m_pd3dDevice->SetRenderState( D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN );

It didn't fix the problem. Is there any way to set the render state for a render target? An example will really help :)
To be even more precise, here is what was added:

if(FAILED(m_pd3dDevice->SetRenderState( D3DRS_COLORWRITEENABLE1, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED )))
assert(false);
if(FAILED(m_pd3dDevice->SetRenderState( D3DRS_COLORWRITEENABLE2, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED )))
assert(false);
if(FAILED(m_pd3dDevice->SetRenderState( D3DRS_COLORWRITEENABLE3, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED )))
assert(false);

This topic is closed to new replies.

Advertisement