Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Problems with Transparency when using dbo world files

Author
Message
Pixel Perfect
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: UK
Posted: 14th Oct 2007 18:03
I've run into a problem when using transparency with an object created from an imported DBO file created in 3D World Studio.

Initially I was using a single textured terrain with various brushes and mesh objects including trees. This appeared to work fine in DarkDGK if I used the dbSetObjectTransparency setting 4. However, having now introduced multi textured terrain in 3DWS I found that the alpha blending between the textures wasn't being honoured with setting 4, changing it to any other setting from results in the alpha blending working (though no where near as well as in 3DWS) but the trees transparency ignores the terrain texture and displays the backdrop colour behind it!

I can get round this by loading the trees and vegetation as separate objects and applying setting 4 to them.

Is this a problem with the rendering order and has anyone found a way around this?

No matter how good your code is, someone will improve on it
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 14th Oct 2007 19:15
I've had that "Problem" in various guises - in both Iron Infantry's early birth in Dark Basic and I suspect I'll have the problem again in DarkGDK - however the T.Ed export is a text file of "Files" and stuff and color settings etc - and it has the "Alpha" blend export or "Super Texture" which I was forced to do because I just don't know how to take the light map files and somehow overlay them onto the mesh - though it looks great in the editor and would love to do it. Looks like that might be a 3dws PLUS in your favor... however the trick you mentioned - with texture flag 4 or whatever is basically what I'm going to do - and implement something that is a combination of OnScreen/Offscreen Culling and something I saw in a demo whose basic Idea I'm going to use - the demo was called "Quasi-Voxels" which is basically (AFAIK) making a Ton of Instances of a certain "Folliages" and based on a "overlay" map that is the same size as your terrain - depending on the color in the overlay - you show the correct folliage as you walk around.

This Voxel thing seems perfect for texturing roads, making grass and bushes - but I'm not convinced its the way to go for trees. I'm thinkning of possibly doing some sort of low poly tree canopy system - for dense forrest with folliage underneath.

But the Whole Texture Backdrop color on the edges of trees and stuff - most annoying. I think You might need to make a folliage loader/engine of sorts like I'm going to start this afternoon.

Pixel Perfect
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: UK
Posted: 14th Oct 2007 23:17
Yeah .. thanks Jason .. some food for thought there ... like you I'm definitely going to have to come up with something because this is a bit of a show stopper at the moment.

I've done some reading up on alpha channels and it would seem that 24 bit picture formats that support a full alpha channel provide 8 bits 0 = transparent to 255 = opaque. The shades in between representing degrees of transparency.

The DarkDGK help documentation shows the transparency function as being:

void dbSetObjectTransparency ( int iObject, bool bFlag )

which would imply that it can be either on or off.

Well documentation is not exactly their strong point as we all know that there are various modes and the second parameter controls this. Mode 4 is generally regarded as the recommended transparency setting for trees which I have found to be true from experimenting, however, that screws up my alpha blended textures.

Looking at the DBPro help for this command revealed the following documentation on the modes:

0 - draw first no alpha
1 - draw first with alpha masking
2 and 3 - draw second which overlaps solid geometry
4 - draw second alpha test (only render beyond 0x000000CF alpha values)
5 - water line object (separates depth sort automatically)
6 - combination of 3 and 4 (second phase render with alpha blend AND alpha test, used for fading LOD
leaves)

The reason for my problem seems apparent, mode 4 only renders pixels which have an alpha setting greater than 207 which is getting pretty far up the scale to opaque, hence unable to render more subtle graduations of texture blends.

Mode 6 would seem to be tailor made but I can confirm that it behaves no differently from mode 4, at least in my situation.

The other modes 1,2,3 and 5 do all allow some degree of alpha blending (looks well nicer in 3D World Studio though) but suffer from the other problem of having a fringe transparency effect in which it seems to display the texture or colour of the object beneath the terrain. So in the case of trees where you are looking through a large number of leaves towards a terrain it actually looks as if the terrain is transparent and you are seeing what ever is behind it. This does not seem to occur with brush limbs, only terrain.

I have included two example screen dumps to illustrate this.

By the way, for anyone new to using foliage and transparency in GDK, mode 4 and 6 although giving the best rendition of leaves and foliage close up do not employ any kind of LOD (mipmap) compensation, so as you move away from the object you gradually loose the leaves and the overall appearance of a tree!
Modes 1,2,3 and 5 do use mip mapping and retain the general image of the tree canopy even at distance.

No matter how good your code is, someone will improve on it

Attachments

Login to view attachments
Pixel Perfect
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: UK
Posted: 14th Oct 2007 23:21
Ooops .. second file here

No matter how good your code is, someone will improve on it

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 15th Oct 2007 00:25
Excelent Post BTW. Question. Do you know How to Alpha Map? We can move this to another thread - But you picture shows what looks like one object using multiple textures. This is VERY Efficient - and Looks Superb to the Super Textures I'm using.

Do you know how 3DWS can make a DBO like that when it exports?

Pixel Perfect
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: UK
Posted: 16th Oct 2007 21:23
Have been doing some more practical investigation into this transparency problem and I'm now firmly convinced the problem is down to the internally (Dark Basic engine) generated mipmaps and the z-order when trying to render the trees over my alpha mapped terrain.

It only occurs when the option to use mipmaps is enabled and can be prevented by taking it out of the z order using dbDisableObjectZDepth() function. This however is of no use as the tree will now render its self in front of everything.

I have found a working alternative but screws up the original intention of using a single world object designed in 3DWS. If I create all the trees as separate objects and apply the following functions:

dbSetObjectTexture(objectNumber,2,0);

the last parameter needs to be zero to prevent mipmap generation

dbSetObjectTransparency (objectNumber,4);

gives the best rendering of the leaves but now has the leaf
fading attribute somehow cancelled by use of the previous
function so produces a decent representation of the tree at
distance.

This combination now allows me to have the alpha blended terrain in the 3DWS object by using a mode other than 4 for the transparency but avoid the terrain leaking transparency problems on the trees.

I really hope this helps anyone else who encounters similar problems and I am left wondering if this is a bug or just a realistic drawback of not being able to exactly determine the order in which objects are rendered.

If anyone out there knows a way to directly control the rendering order I'd be really interested!

@Jason
If you'd like to start a separate thread on level design tools we could share our knowledge, I'd certainly be interested in learning a bit more about T-Ed and the super textures your using.

No matter how good your code is, someone will improve on it

Login to post a reply

Server time is: 2024-11-16 20:58:57
Your offset time is: 2024-11-16 20:58:57