Game Development Community

Render Target and Color1 help.

by Taylor Petrick · in Torque Game Engine Advanced · 08/27/2009 (9:51 am) · 1 replies

I'm working on some full screen shader stuff, and I can't seem to pull data from Color1.

I'm rendering the fullscreen shader with this:
GFX->pushActiveRenderTarget();	

	mRenderTarget = GFX->allocRenderToTextureTarget();
	mRenderTarget->attachTexture(GFXTextureTarget::Color0, mSurface[0]);
	mRenderTarget->attachTexture(GFXTextureTarget::Color1, mSurface[1]);
	mRenderTarget->attachTexture(GFXTextureTarget::DepthStencil, GFXTextureTarget::sDefaultDepthStencil);

	GFX->setActiveRenderTarget(mRenderTarget);
	gClientSceneGraph->renderScene();
	GFX->popActiveRenderTarget();

        // Pass transforms to shader, create full-screen quad, render//

For testing purposes, I've got a handful of models in the scene that use this in their pixel shader:

struct ConnectData
{
    float2 texCoord           : TEXCOORD0;
};

struct PS_OUTPUT
{
    half4 color0 : COLOR0;
    half4 color1 : COLOR1;
};


PS_OUTPUT main( ConnectData IN, uniform sampler2D diffuseMap  : register(S0))
{
   PS_OUTPUT OUT;  

   OUT.color0 = tex2D( diffuseMap, IN.texCoord );
   OUT.color1 = tex2D( diffuseMap, IN.texCoord );
   
   return OUT;
}

When rendering the full screen shader with the texture set as "mSurface[0]", everything works like it should. If I set the texture as "mSurface[1]", however, the screen is entirely black.

Any suggestions?

#1
08/27/2009 (10:19 am)
Ah, I think I found the problem. In both of these functions:
const Point2I GFXD3D9TextureTarget::getSize()
void GFXD3D9TextureTarget::activate()

its hard-coded to handle COLOR0 only.

EDIT:
I applied the fix in this thread:
http://www.garagegames.com/community/forums/viewthread/81651

And now I get a lovely pink screen. Has anyone gotten MRTs working in TGEA?