Problem with transparency on foliage
by Bill Blaiklock · in Torque Game Engine Advanced · 03/26/2007 (1:02 am) · 8 replies
I just put in the modified version of fxFoliageReplicator for TGEA and got a few foliage sprites together. The problem is when I view them in-game all the foliage has a white outline around it, I'm guessing where the semi-transparent pixels are. They are saved as a PNG and I tried a bunch of things to make sure that the file is being saved with all the alpha information and everything. Anyway, the white outline looks terrible, especially from far away where it ends up looking like a sea of white and I have no idea why it does it. This is about what it looks like:
img183.imageshack.us/img183/7760/screenshot00500001qs6.jpg
img183.imageshack.us/img183/7760/screenshot00500001qs6.jpg
About the author
#2
img88.imageshack.us/img88/4660/screenshot00600001oy6.jpg
I made a circle and it has white on the four sides where it would show up if it was a full square (top bottom left and right edges), so there's obviously something going on with that.
edit: It's ummmm.... AlphaCutoff that controls that. Well at least I got a good look at the foliage shader code!
03/26/2007 (6:57 pm)
Well I thought of that, but it doesn't seem to be the case, either. I made a square in photoshop using no anti-aliasing and there is a white outline around the whole thing, as this shows:img88.imageshack.us/img88/4660/screenshot00600001oy6.jpg
I made a circle and it has white on the four sides where it would show up if it was a full square (top bottom left and right edges), so there's obviously something going on with that.
edit: It's ummmm.... AlphaCutoff that controls that. Well at least I got a good look at the foliage shader code!
#3
I have the problem that all my alphas of the foliagesimages are green instead of transparent.
Could you pls show me your material.cs?
I am sure I am doing something wrong here.
thanks
04/12/2007 (12:16 am)
Bill,I have the problem that all my alphas of the foliagesimages are green instead of transparent.
Could you pls show me your material.cs?
I am sure I am doing something wrong here.
thanks
#4
04/13/2007 (11:14 am)
I didn't use any material.cs for the foliage, I'd say having one at all would cause more problems then not (although I didn't particularly know you could have one for foliage). Other than that, it may just be a transparency problem with the file, you may want to look into the SuperPNG plugin for Photoshop for better PNG support if you haven't already.
#5
04/13/2007 (11:23 am)
Same outline type issues as Bill here with stock fxFoliageReplicator.
#6
It's been explained about a million times, but I'll take it one more time I suppose =)
Photoshop saves alpha as "transparency" in pngs, this works just fine for web graphics and such but not really for when the pngs are used as textures. See, when the PNG is saved with transparency rather than a proper alpha channel the background (as in the stuff that's alphaed out) is completely removed and replaced with a white matte.
What you want to do is to get the old SuperPNG plugin for photoshop, (you can get it from the artists page). Make sure you move photoshop png.8bi away from the plugins folder too.
Once you have the plugin installed you will have to set up a proper alpha channel in photoshop rather than doing the transparency thing (I refer you to the Photoshop documentation for how to do that...). With a proper alpha your background will be kept intact. You will still get a slight outline, but you can control it by setting the background to a more sensible color rather than white.
04/13/2007 (11:33 am)
This is definitely the age old problem of photoshop not saving alpha properly!It's been explained about a million times, but I'll take it one more time I suppose =)
Photoshop saves alpha as "transparency" in pngs, this works just fine for web graphics and such but not really for when the pngs are used as textures. See, when the PNG is saved with transparency rather than a proper alpha channel the background (as in the stuff that's alphaed out) is completely removed and replaced with a white matte.
What you want to do is to get the old SuperPNG plugin for photoshop, (you can get it from the artists page). Make sure you move photoshop png.8bi away from the plugins folder too.
Once you have the plugin installed you will have to set up a proper alpha channel in photoshop rather than doing the transparency thing (I refer you to the Photoshop documentation for how to do that...). With a proper alpha your background will be kept intact. You will still get a slight outline, but you can control it by setting the background to a more sensible color rather than white.
#7
So my only fix seems to be to make sure your foliage has some extra thickness around the edges and set the AlphaCutoff in the fxFoliageReplicator way low so that it cut's off the edges. Like I said, I don't know why it doesn't do that automatically.
The green background stuff has to do with all that wacky PNG transparency stuff with photoshop though.
04/20/2007 (11:57 pm)
Well my original problem was with the outline, I looked into SuperPNG and tried a million different things. The outline I couldn't get rid of until I noticed and set the AlphaCutoff to way lower than what it is defaulted to. Then I had the problem where my foilage was cut way too thin (leaves were floating and such), so I'll eventually have to make sure it is all thicker than it needs to be. The real problem is that there is no partial transparency I don't think, so it just makes it white (I'm not sure what a more sensible color would be or if changing the background color would even do much- although I guess green may work in this case). Although I made sure to make every pixel either all or nothing transparent and there is still an outline. It shouldn't do that.So my only fix seems to be to make sure your foliage has some extra thickness around the edges and set the AlphaCutoff in the fxFoliageReplicator way low so that it cut's off the edges. Like I said, I don't know why it doesn't do that automatically.
The green background stuff has to do with all that wacky PNG transparency stuff with photoshop though.
#8
04/25/2007 (12:36 pm)
Hum I need to retest Arteria tropical pack as it had that bug.
Torque Owner Bobby Leighton
Imagn' Games