Proper transparency for leaves and grass

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:
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:
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:
(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.)
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:
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:
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:
(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.)