Difference between revisions of "Proper transparency for leaves and grass"
Tachzusamm (Talk | contribs) (Created page with "== The transparency problem == You know, we can't just model trees or grass with separated leaves, one by one: the Age would lag extremely because of too many verticies. So to g...") |
m (fix typo) |
||
(6 intermediate revisions by one other user not shown) | |||
Line 7: | Line 7: | ||
+ | [[File:Img1_Before.jpg|thumb|right|Fig. 1. Example of alpha artifacts]] | ||
Well, that's the theory. I never got this looking good, for months. It drove me totally crazy. | Well, that's the theory. I never got this looking good, for months. It drove me totally crazy. | ||
Line 14: | Line 15: | ||
− | 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. | + | 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. |
− | |||
− | |||
− | |||
− | |||
Line 27: | Line 24: | ||
BUT. Have a look at Eder Tsogahl, or Siralehn. There is plenty of grass, without problems, just looking pretty good. | BUT. Have a look at Eder Tsogahl, or Siralehn. There is plenty of grass, without problems, just looking pretty good. | ||
− | |||
== The solution == | == The solution == | ||
+ | [[File:Img2_After.jpg|thumb|right|Fig. 2. Image with the flag set]] | ||
+ | |||
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 finally found the trick. | 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 finally found the trick. | ||
+ | |||
+ | |||
It's just a flag in the Blend Flags, which is named '''kBlendAlphaTestHigh''' (0x4000000). | It's just a flag in the Blend Flags, which is named '''kBlendAlphaTestHigh''' (0x4000000). | ||
Line 37: | Line 37: | ||
− | |||
− | |||
+ | So, I used [http://forum.guildofwriters.org/viewtopic.php?f=86&t=2639 PRPShop] to set the flag '''kBlendAlphaTestHigh''' manually after export - and that did it. | ||
− | == | + | == Easier transparency support == |
But beeing lazy, I did not want to patch my Age each time manually, so I patched the PyPRP sources a bit. | 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: | I think the best way to map this flag to is the property '''Premul''' in the Image panel ('''Texture''' => '''Image''' => '''Premul'''), because: | ||
− | + | * it belongs to / influences exacly that image, and | |
− | + | * it's exacly the same button (Premul) you have to use in Blender when you experience similar effects when rendering a scene, | |
− | + | * it was previously unused and does not change anything in existing Ages, because it defaults to unchecked. | |
+ | |||
[[File:Img_Premultiply_Button.jpg]] | [[File:Img_Premultiply_Button.jpg]] | ||
− | If you like, you can use this patched version of '''prp_MatClasses.py''' to replace the one in the | + | '''UPDATE:''' '''''The following patch was only useful for PyPRP 1.60; it is no longer needed if you use the current version PyPRP 1.61.''''' |
+ | |||
+ | '''''If you already upgraded to 1.61, just use the feature as shown in the image above.''''' | ||
+ | |||
+ | |||
+ | If you like, you can use this patched version of '''prp_MatClasses.py''' to replace the one in the older PyPRP 1.60: | ||
+ | |||
+ | [http://forum.guildofwriters.org/download/file.php?id=1694 prp_MatClasses.zip] | ||
− | + | (this is based on the previous prp_MatClasses.py from PyPRP 1.60 Trunk, just added the alpha artifacts patch) | |
− | + | ||
− | (this is based on the | + | |
+ | == Additional hints == | ||
If it still does not come out as you expect - I used these setting for the other panels: | If it still does not come out as you expect - I used these setting for the other panels: | ||
ZTransp: OFF, Zoffs: 0.00 | ZTransp: OFF, Zoffs: 0.00 | ||
Line 67: | Line 73: | ||
Happy blending, umm, Age Writing, | Happy blending, umm, Age Writing, | ||
− | tach | + | ~tach |
Latest revision as of 06:22, 27 April 2013
The transparency problem
You know, we can't just model trees or grass with separated leaves, one by one: the Age would lag extremely 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: 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.
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.
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.
The solution
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 finally 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 kBlendAlphaTestHigh manually after export - and that did it.
Easier transparency support
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:
- it belongs to / influences exacly that image, and
- it's exacly the same button (Premul) you have to use in Blender when you experience similar effects when rendering a scene,
- it was previously unused and does not change anything in existing Ages, because it defaults to unchecked.
UPDATE: The following patch was only useful for PyPRP 1.60; it is no longer needed if you use the current version PyPRP 1.61.
If you already upgraded to 1.61, just use the feature as shown in the image above.
If you like, you can use this patched version of prp_MatClasses.py to replace the one in the older PyPRP 1.60:
(this is based on the previous prp_MatClasses.py from PyPRP 1.60 Trunk, just added the alpha artifacts patch)
Additional hints
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