Transparency - in certain directions transparency is transparent through to the sky instead of to th

@pspeed said:
This is because geometry in the transparent bucket is sorted back to front but there is no really accurate way to do that for all objects. By putting everything in the transparent bucked (even the solid background parts) you make this even harder.

I don't know how your scene is constructed exactly but it looks like the big green solid thing is considered to be "in front of" the blocks near the top... probably because it's near edge is closer to the camera than those blocks or something.

Arranging a scene with transparency can be difficult though you can specifically control the sort order if there is a logical way to do so.


In the screen shot you are looking down the z axis, the green solid block is further away in its entirety in the z axis. That said, the entire scene is constructed from a single mesh (both the green block at the bottom and the leaves are 1 object). I presume this is the cause of the problem. I did this for efficiency reasons but I could split the scene into transparent and non transparent meshes to go into the different buckets (which would probably be wise anyway as I presume the transparent bucket is more expensive). This would still mean, however, that leaves couldn't be transparent through to other leaves (unless I batched each seperately which was prohibitively slow). That would be a shame but not a terminal problem. A worse problerm is that they would be transparent through to other leaves in certain directions but not in others, which would lead to an ugly looking inconsistency

Is it an accepted limitation that a mesh that 'bends back on itself' cannot be transparent through to itself?

One object = one mesh. It doesn’t matter if all the vertices on the mesh are joined to each other or not, it’s still one object as far as the engine and your graphics card are concerned.

@richtea said:
In the screen shot you are looking down the z axis, the green solid block is further away in its entirety in the z axis. That said, the entire scene is constructed from a single mesh (both the green block at the bottom and the leaves are 1 object). I presume this is the cause of the problem. I did this for efficiency reasons but I could split the scene into transparent and non transparent meshes to go into the different buckets (which would probably be wise anyway as I presume the transparent bucket is more expensive). This would still mean, however, that leaves couldn't be transparent through to other leaves (unless I batched each seperately which was prohibitively slow). That would be a shame but not a terminal problem. A worse problerm is that they would be transparent through to other leaves in certain directions but not in others, which would lead to an ugly looking inconsistency

Is it an accepted limitation that a mesh that 'bends back on itself' cannot be transparent through to itself?


You can also set alpha test to true and the falloff threshold to some reasonable amount. Without these, even the fully transparent pixels will fill the Z-buffer and prevent the pixels behind from being drawn if that happen to be drawn after. Controlling the threshold amount will control how dramatic this effect is, ie: what alpha is considered solid and what is considered "transparent".
1 Like

As an example of what I mean; say a U shaped piece of glass (no distortion or effects, just say some occasional streaks on the surface so you can see it

.

looking at it like:

Eye —> U —> Background



As you look through it you first see the streaks on the first leg of the U as your line of vision enters it

Then you (correctly) don’t see streaks of the outside of the first leg as you exit it - since the back face is not rendered unless specifically requested

Then you should see the streaks on the second leg of the U. But you only see them if you’re looking in certain directions



For example





In this image the second leg of the glass is obscured by the first leg:

'>





http://imgur.com/QnBcF



But in this image the middle leg is clearly visible through the transparent parts of the glass:

'>

http://imgur.com/ihhiA





I recognise that this is probably very difficult/impossible for the graphics card to get right but I just wanted to make sure that this isn’t a bug/something I’m doing wrong before I try to do it another way*



Obviously transparent objects being visible through other transparent objects would be best, but as a plan B is there a way to make sure transparent objects are NEVER seen through other transparent objects to make it at least consistent in all directions



(some slightly odd glass behaviour I’ve seen in other games is starting to make a lot of sense now)

@pspeed said:
You can also set alpha test to true and the falloff threshold to some reasonable amount. Without these, even the fully transparent pixels will fill the Z-buffer and prevent the pixels behind from being drawn if that happen to be drawn after. Controlling the threshold amount will control how dramatic this effect is, ie: what alpha is considered solid and what is considered "transparent".


Interesting, I'll try this tonight

Ok, by tonight I mean now:



That helps dramatically! Thank you!



So in conclusion:



Where an object may bend round upon itself and is partially transparent (so a part of an object may been seen through holes in that same object) the following must be done



In addition to the normal procedure:

[java]mat1.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); [/java]

and

[java]newGeometry.setQueueBucket(Bucket.Transparent);[/java]



The following must also be done



[java]mat1.getAdditionalRenderState().setAlphaTest(true);

mat1.getAdditionalRenderState().setAlphaFallOff(0.7f);[/java]

@pspeed said:
Are the trees still in the translucent bucket?

It was in the Transparent Bucket, Translucive bucket do the same as it alway did, i see the tree from the other side of the mountain
like if there was no mountain before them to draw

But the Transparent one, make the fog get draw before my trees and the ocean as well.

@nehon said:
if you are using the translucent bucket and filters you need to add a TranslucentBucketFilter at the end of your filter stack, so that the fpp handles the bucket, instead of the render manager.
Try it it should works

EDIT : wait minute, why do you have to put your trees in the translucent bucket? Transparent should work. Only thing I see that could cause your issue is that you set your tree material to not write depth for some reason i can't explain.


Even if i dont realy need it now, could you post how to make use of the TranslucentBucketFilter, so when i come to the moment i use too many particle i wont have any problem, thank you.

Edit: Sorry yea it s normal i dont write the Depth, cause it make the tree errase the one behind with the side of the leaf when the transparency is activated, so it cause the whole forest to erase them self.
Maybe i am doing wrong by removing it, but in one of the tutorial on the material, it clearly said to remove it so we can see the other transparent object of the scene over, like the ocean and other tree leaf.

https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-ash4/289044_10150964374346485_2121453264_o.jpg
@n3cr0 said:
Edit: Sorry yea it s normal i dont write the Depth, cause it make the tree errase the one behind with the side of the leaf when the transparency is activated, so it cause the whole forest to erase them self.
Maybe i am doing wrong by removing it, but in one of the tutorial on the material, it clearly said to remove it so we can see the other transparent object of the scene over, like the ocean and other tree leaf.

No! let the trees write the depth that's the reason of all your other issues, then you are going to add shadows and it's not gonna work.
Disabling depth write is very particular and should be used only in particular cases.

Set your tress to write depth.

To avoid your issue just set an alphaFalloff on your leaves material mat.getAdditionalRenderState().setAlphaFalloff(0.5f); for example.
1 Like
@nehon said:
To avoid your issue just set an alphaFalloff on your leaves material mat.getAdditionalRenderState().setAlphaFalloff(0.5f); for example.


And mat.getAdditionalRenderState().setAlphaTest(true);
1 Like
@nehon said:
No! let the trees write the depth that's the reason of all your other issues, then you are going to add shadows and it's not gonna work.
Disabling depth write is very particular and should be used only in particular cases.

Set your tress to write depth.

To avoid your issue just set an alphaFalloff on your leaves material mat.getAdditionalRenderState().setAlphaFalloff(0.5f); for example.

@pspeed said:
And mat.getAdditionalRenderState().setAlphaTest(true);

Realy thank you, Everything is working fine now, i realy appreciate, Now i can get on my gameplay :)