I try use MRT on D3D9 driver and result is wrong in RT2 and RT3 (RT1 good result) but in OGL work great all in RT.
I very confuse about that. Texture format & size -> 512x512, ECF_A8R8G8B8 all in render texture. (OpenGL run perfectly in same irrlicht sourcecode) I'm not sure my program is wrong or miss some MRT process in D3D9
Pixel shader here D3D9:
Code: Select all
struct PS_INPUT
{
float4 Position : POSITION0;
};
struct PS_OUTPUT
{
float4 Color : COLOR0;
float4 Normal : COLOR1;
float4 Depth : COLOR2;
};
PS_OUTPUT pixelMain( PS_INPUT Input )
{
PS_OUTPUT Output;
Output.Color = float4(1.0,1.0,1.0,1.0);
Output.Normal = float4(0.0,1.0,0.0,1.0);
Output.Depth = float4(0.0,0.0,1.0,1.0);
return Output;
}//*/result here D3D9 (wrong!!! in RT2 and RT3):

Pixel shader here OGL:
Code: Select all
void main(void)
{
gl_FragData[0] = vec4(1.0,1.0,1.0,1.0);
gl_FragData[1] = vec4(0.0,1.0,0.0,1.0);
gl_FragData[2] = vec4(0.0,0.0,1.0,1.0);
}result here OGL (right all RT):

sourcode:
Code: Select all
// variable
ITexture* gbuffer[3];
array<IRenderTarget> gbufferlist;
// allocate buffer
gbuffer[0] = driver->addRenderTargetTexture( texsize, "rta", ECF_A8R8G8B8 );
gbuffer[1] = driver->addRenderTargetTexture( texsize, "rtb", ECF_A8R8G8B8 );
gbuffer[2] = driver->addRenderTargetTexture( texsize, "rtc", ECF_A8R8G8B8 );
for( u32 i = 0; i < 3; ++i )
gbufferlist.push_back( IRenderTarget(gbuffer[i]) );
// render
driver->setRenderTarget( gbufferlist );
smgr->drawAll();
// draw debug rt
driver->draw2DImage(gbuffer[0], core::position2d<s32>(0,0));
driver->draw2DImage(gbuffer[1], core::position2d<s32>(256,0));
driver->draw2DImage(gbuffer[2], core::position2d<s32>(512,0));
