Sign in to follow this  

Multiple render targets problem

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this