Proper transparency for leaves and grass

If you feel like you're up to the challenge of building your own Ages in Blender or 3ds Max, this is the place for you!

Proper transparency for leaves and grass

Postby tachzusamm » Sat Jun 04, 2011 4:03 am

You know, we can't just model trees or grass with separated leaves, one by one: the Age would explode (I mean: lag) because of too many verticies.
So to get a dense vegetation, one should put an image of many leaves on a plane, containing an alpha channel for the transparent parts between the leaves, and place these planes either crossed (like an X) or circled (like an O) into the Age. Many of such planes. This is how Cyan does it as well. For example, in Relto, Eder Tsogahl, or Siralehn.
An example is shown here in the Wiki: http://www.guildofwriters.com/wiki/Planting_Some_Grass

Well, that's the theory. I never got this looking good, for months. It drove me totally crazy.

First, you may say: "Hey, that's obvious. Instead of ZTransp and Zoffs, now PassIndex in the Object Panel should be used for PyPRP 1.6!"
You're right, that's true. And you are right as well, if you recommend reading the "Managing Transparent Objects" chaper in the Wiki: http://www.guildofwriters.com/wiki/Mana ... nt_Objects

But, still, it did not look good for me. Even the wiki-chapter "Alpha Textures Removing Edge" did not really help much in my case. When we avoid the ZTransp setting, sometimes the leaves get surrounded with a shimmery border. Let's call this "alpha artifacts". It seems that at the boundary between the opaque part (the leave) and the transparent part, the alpha value influences the faces behind as well - which lets the background shine through our plants.

Here's an example:
Img1_Before.jpg
Img1_Before.jpg (80.18 KiB) Viewed 2948 times


Now, if we re-enable ZTransp and set some Zoffs, this effect is gone (well, mostly) - but now the planes are no longer sorted by Plasma in URU! The camera then renders leaves behind front leaves sometimes in front of them, which looks ugly.

Now you may say, that's just the limitations of computer graphics, or at least Plasma; and I began to believe this as well.
BUT. Have a look at Eder Tsogahl, or Siralehn. There is plenty of grass, without problems, just looking pretty good.

So is this just because those are Cyan Ages, and we have no chance to look behind the curtains? I decided to not believe that, did some research (well, lots of), and today I found the trick.
It's just a flag in the Blend Flags, which is named "kBlendAlphaTestHigh" (0x4000000).
This flag was set for the grass in Siralehn, but never in any of my exports.
Unfortunatelly PyPRP never sets this flag, and it does not have any of Blender's properties assigned to it.

So, I used PRPShop to set the flag "BlendAlphaTestHigh" manually after export - and that did it:
Img2_After.jpg
Img2_After.jpg (73.38 KiB) Viewed 2948 times



But beeing lazy, I did not want to patch my Age each time manually, so I patched the PyPRP sources a bit.
I think the best way to map this flag to is the property "premul" in the Image panel (Texture => Image => Premul), because:
a) it belongs to / influences exacly that image, and
b) it's exacly the same button (Premul) you have to use in Blender when you experience similar effects when rendering a scene,
c) it was previously unused and does not change anything in existing Ages, because it defaults to unchecked.

If you like, you can use this patched version of prp_MatClasses.py to replace the one in the official PyPRP 1.6:
prp_MatClasses.zip
(22.74 KiB) Downloaded 398 times

(this is based on the latest prp_MatClasses.py from Trunk, just added the alpha artifacts patch)

If it still does not come out as you expect - I used these setting for the other panels:
ZTransp: OFF, Zoffs: 0.00
Material: Shadeless
Object: PassIndex 3
Object- Draw: Transp ON

Happy blending, umm, Age Writing,
tach


(I hope this switch will be available in the new PyPRP 2 as well. Developers: Hint, hint! Please.)
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Proper transparency for leaves and grass

Postby Corvus » Sat Jun 04, 2011 6:56 am

Awesome! Your 2nd picture looks exactly like I tried in vain to make my plants look. This will make many age builders very happy I guess. Will have to try your fix as soon as possible. Thank you.
"To regard the imagination as metaphysics is to think of it as part of life, and to think of it as part of life is to realize the extent of artifice. We live in the mind."

-Wallace Stevens-
User avatar
Corvus
 
Posts: 204
Joined: Fri Feb 15, 2008 11:21 am
Location: Germany

Re: Proper transparency for leaves and grass

Postby diafero » Sun Jun 05, 2011 2:32 am

Nice detective work :)
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2972
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Proper transparency for leaves and grass

Postby Rabenschwinge » Sun Jun 05, 2011 3:38 am

Great! That solves a lot of problems!
While inspecting ages, I´ve found this problem over and over again, many ages have it - and the writers aren´t really responsible for it, right? :D

A question to the PyPRP-developers: would it be possible to publish a new version of PyPRP 1.x, so that we all have a working solution, until 2.0 is ready?
Rabenschwinge
 
Posts: 86
Joined: Thu Mar 26, 2009 5:56 am

Re: Proper transparency for leaves and grass

Postby ametist » Sun Jun 05, 2011 10:56 pm

Great work tach, thanks a lot!! :) Now to implement it /me rubs hands together
User avatar
ametist
 
Posts: 360
Joined: Fri Dec 28, 2007 6:55 am

Re: Proper transparency for leaves and grass

Postby Calena » Fri Jun 17, 2011 7:41 am

I downloaded and implemented the your patch last night. What a fabulous tool :P . It worked like a charm. Thank you, thank you, thank you :) :) :) .
Galatians 2: 20-21

"Don't mess with me today. I have my CAPS LOCK key and I know how to use it!"
User avatar
Calena
 
Posts: 222
Joined: Thu Jan 13, 2011 11:38 am


Return to Building

Who is online

Users browsing this forum: No registered users and 5 guests