PlaneShift

Development => Development Deliberation => Topic started by: LigH on August 15, 2006, 09:05:55 am

Title: Small note about CS transparency problems
Post by: LigH on August 15, 2006, 09:05:55 am
I asked in #crystalspace again about possible reasons for rendering problems behind transparent textures. 'mdmkolbe' told me the following:

Quote
well you have to make the Z buffer read-only when rendering transparent textures
(and render transparent textures after all the solid textures)   
I don't know how much of the Z buffer stuff CS will take care of for you

The last sentence might be related to rendering priorities I guess.

You have probably read such kind of tips several times; unfortunately, searching for "transparency" returns too many hits to find a good one. But I am curious if the reason is already addressed, or if you are still looking for a reliable solution.
Title: Re: Small note about CS transparency problems
Post by: Wired_Crawler on August 21, 2006, 09:44:48 pm
I asked in #crystalspace again about possible reasons for rendering problems behind transparent textures. 'mdmkolbe' told me the following:

Quote
well you have to make the Z buffer read-only when rendering transparent textures

According to CS docs you make z-buffer read-only by setting z-buffer mode to ztest. Unfortunately, this does not help always (but sometimes it do helps, especially when combined with proper render priority and mixmode alpha).

Quote
(and render transparent textures after all the solid textures)

AFAIK there isn't anything like texture priority (maybe binary alpha does it, but it is not acceptable in all cases). CS is object-oriented engine, so if you have model built of both transparent and non-transparent parts you have a problem :P.

Quote
I don't know how much of the Z buffer stuff CS will take care of for you

That's bad. Who should know it, if developers don't  :-\ ?

LigH, it seems, that there are two persons which see problems with transparency in CS: You and me ;). The rest desperately tries to use what they have ;). There are very few entries in history.txt related to transparency handling, there are no bug reports regarding transparency in CS bugtracker, also I couldn't find many (any?) complaints about it on CS forums.
IMO, transparency handling is one of weakest CS features. There are numerous problems related to this:
[td]The scene
(http://img230.imageshack.us/img230/8918/trans1bu0.th.jpg) (http://img230.imageshack.us/my.php?image=trans1bu0.jpg)
[/td]
[td]Oh! You can't see cubes through transparent texture!
(http://img201.imageshack.us/img201/5510/trans2ep6.th.jpg) (http://img201.imageshack.us/my.php?image=trans2ep6.jpg)
(moving or turning slighgtly makes cubes appear/disappear)[/td]
[/tr][/table]
You can see this effect in PS in numerous places. Let's hope pvsvis will fix it  :-\.

Title: Re: Small note about CS transparency problems
Post by: LigH on August 22, 2006, 07:48:57 am
Simple test scenes are surely the best to demonstrate these issues...

I recorded another chat (http://www.ligh.de/tmp/Transparency_chat.pdf) and uploaded it to my webspace, hope it explains more.

I already understand that visibility culling must not occur behind partially transparent textures; Object orientation in this case is not too helpful though, when it comes to tather complex and especially "concave" objects; if the rendering order cannot be determined by the GPU, then the CPU may have to pre-order the object's parts before rendering, to avoid "Escher" results (wrong depth order, making the object look like self-prenetrating).

(moving or turning slighgtly makes cubes appear/disappear)

This is the effect which seems to prove that specific calculations in CrystalSpace are not reliable. Priority textures must be drawn reliably always in the same way, or the priority rules are unusable. Even a check if an object is completely covered by another, must be disabled if one of them is partially transparent.
Title: Re: Small note about CS transparency problems
Post by: Induane on August 27, 2006, 11:50:38 am
I've investigated this further as well.  Well, at least I've attempted to find a combination of flags in blender2crystals exporter that would produce good results because I've been trying to make some nice low poly trees.  In that I think I suceeded.  All I did was add a property to the genmesh plane that has the transparant texture.  The flag I ended up setting was a boolean, - texture_binary TRUE

and when exported I can find no issues at all on any of my tests.  Before I was using a combination of aplha priority, ztest zbuffer, with dynavis culler.  Not sure if that helps but it really made a major difference for me.
Title: Re: Small note about CS transparency problems
Post by: Wired_Crawler on August 28, 2006, 07:51:22 pm
The flag I ended up setting was a boolean, - texture_binary TRUE

Setting texture_binary to "true" in blender2crystal adds "binary alpha" tags to textures definitions. Yes, it helps in many cases, but not always (see images I posted above, texture_binary was set to "true" for the plane). Additionally - binary alpha does not allow having semi-transparent parts of textures (smooth transitions between opaque and transparent areas), You will see only fully opaque or fully transparent parts.
All of this is in described in CS docs.
Title: Re: Small note about CS transparency problems
Post by: Induane on August 30, 2006, 06:14:06 pm
well the issue I had was that setting it in the blender2crystal gui (I hope I was doing it right) didn't seem to make a reflective change in the properties area.  Setting it manually made the difference so that could be a b2cs bug.. I was using a cvs checkout of it.  I also noticed that if you set objects that can be obscured by it to clipping "false" then they quit disappearing in many cases.