Jump to content
  • Advertisement
Sign in to follow this  
hemu

Multiple render targets problem

This topic is 3873 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
Advertisement
Try checking your renderstate prior to rendering. It sounds like color writes might be disabled for the second redertarget.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!