I'm having trouble with transparent textures. Here's a bit of code
dbAutoCamOn();
dbLoadObject("media\\groundplane\\groundplane.x", 2);
dbPositionObject(2, 0, 0, 20);
dbScaleObject(2, 1000, 1, 1000);
dbXRotateObject(2, 90);
dbLoadObject("media\\cloudlayer\\cloudlayer.x", 1);
dbXRotateObject(1, -90);
dbSetObjectEmissive ( 1 , 0x00646464 );
dbSetObjectAmbience ( 1 , 0x00FFFFFF );
dbSetAlphaMappingOn ( 1, 100 );
//dbDisableObjectZDepth ( 1 );
dbPositionObject(1, 0, 0, -5);
dbSetObjectTransparency ( 1, 1 );
float i=1;
while ( LoopSDK ( ) )
{
i-=.01;
dbPositionObject(1, 0, i, 0);
if (i < -5) i+=10;
if ( dbEscapeKey ( ) )
return;
dbSync();
}
Now there's one line that's commented out. I'll come back to it later.
cloudlayer.x contains a cloud layer that should be "over" the ground layer "groundplane.x". Both files are attached to this post. Now the cloud layer contains a semi-transparent texture. To create the feeling of high-altitude flight, the cloud plane will be between the camera and the ground. The character/plane/user controlled object will be above the clouds.
Now here's the problem. I don't see the ground through the cloud plane, what I see is a big blue blotch, which is the backdrop color. It's as though the render is ignoring the ground plane and using just blue as the transparent color (Z buffer related sorting problem?).
To test the theory you can uncomment the commented line in the code above. Then you will get exactly the result I'm looking for. Problem is, now if I render the aircraft/character, I won't be able to put it on top of the clouds as the clouds will now render last no matter what.
So, any clue to what's going on? Thanks in advance.
---
http://christianboutin.com