instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
January 17, 2018, 08:25:55 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Transparency issue: a tree with multiple layered textured planes with alpha map  (Read 3196 times)
pol3waf
Newbie
*
Posts: 18


View Profile
« on: January 07, 2013, 11:25:33 am »

Hello everyone and a happy new year!

After trying several solutions from the forum to get transparency set up right, I didn't get the right result.

The model to be rendered is a tree with a trunk, and another shape for the leaves, which are represented as planes with a diffuse texture with alpha channel.
The biggest problem is the sorting of the faces to be rendered. Sometimes faces from the back of the tree seem to be right in front, or the front is only rendered if another plane is right behind it, or things are darkened a lot, if, something is behind it, altough the leaves themselves are fully opaque (alpha = 1).
This will get really disturbing, if the camera is moving close to the object.

The things I've tried are:
*  IndexedFaceSet.solid = 'false', IndexedFaceSet.optimizationMode = "none", ContextSetup.zWriteTrans='false'
* IndexedFaceSet.solid = 'false', Appearance.sortType='transparent', FaceMode.smooth='false', FaceMode.cullFace='none', DepthMode.depthFunc='less', DepthMode.readOnly='true'
* Several approaches to manually set up the sorting.

Does someone have a clue, how to get this right?

Regards,
pol3waf
« Last Edit: January 07, 2013, 01:39:40 pm by pol3waf » Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #1 on: January 22, 2013, 04:44:57 pm »

Hi, you can also define the rendering order using the Appearance node's sortKey field, where the rendering order directly corresponds to the value set (e.g. 0 is rendered before 1 etc).
Besides this, back-to-front sorting (which is essential for correct blending) is not possible within one IndexedFaceSet, but can only be enforced between Shape nodes.
Logged
pol3waf
Newbie
*
Posts: 18


View Profile
« Reply #2 on: January 23, 2013, 03:29:45 pm »

Hi, you can also define the rendering order using the Appearance node's sortKey field, where the rendering order directly corresponds to the value set (e.g. 0 is rendered before 1 etc).
I tried that already, but as you said in the following ...
Besides this, back-to-front sorting (which is essential for correct blending) is not possible within one IndexedFaceSet, but can only be enforced between Shape nodes.
That might be my problem.

This brings me to the next question: How should one model trees / grass patches with good visuals and fast rendering? Is there a general guideline? Would it be better to have every transparent mesh part as a different object (shape)?

Would this also work for larger scenes with lots of these (and other) models?
My models are rather low poly, so that shouldn't be the limiting factor.

regards,
pol3waf
« Last Edit: January 23, 2013, 03:32:57 pm by pol3waf » Logged
kschwenk
Administrator
Newbie
*****
Posts: 11


View Profile
« Reply #3 on: January 24, 2013, 10:37:13 pm »

For leaves and blades of grass you can work with alpha test (if you don't have the highest demands on visual quality). For example a BlendMode with
BlendMode.alphaFunc = greater
BlendMode.alphaFuncValue = .5
should discard any fragments with alpha<=.5. Which can be used to stencil out stuff like leaves.

If you really need blending you can sometimes get away with sorting things from the inside to the outside. This was a common trick for rendering hair, for example (in the old days). Because you are (almost) always looking from the "outside" of the hair towards the "inside" of the hair with the solid head in the middle, sorting from inside to outside is effectively sorting back to front. This won't really work for trees though...
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines