Fading out an impostor

Started by
18 comments, last by GameDev.net 18 years, 11 months ago
Quote:Original post by baldurk
What filtering method are you using? is it just linear? See if setting the background to white before rendering the cloud makes any difference at all anyway. Sometimes weird things work :).


I tried setting the background clear color to white when rendering the impostor and tried both ONE and SRC_ALPHA for the source factor, they don't work. My hat is all out of weird things to pull out [sad]

Here's the impostor texture with alpha, maybe someone can figure out how to fade it nicely:

Advertisement
Looks like the problem lies in your texture generation. Here's a blown up view of it in the gimp on my system:



I did a real quick erase of the black semi-transparent haze and whipped up an app to show the difference:



So it seems that black is creeping in there. I assume there's no black in your rendering of the cloud. I'm guessing here, but maybe when blending the rendered cloud with the 0,0,0,0 frame buffer created it? I don't know why it would still do that if you set the framebuffer to 1,1,1,0 though.

One solution I guess would be what I did and make it so that you get the texture data and loop through it going a=(r+g+b)/3 on it, but that's a lot slower.
Well the edge is, though a little less visible, still present. The cloud must be blended with 1, 1 - SRC_ALPHA and I have no idea how to make it fade then. My simulation will have to do without switching from the impostor billboard to the 3d particles :(.

Maybe something could be done with the combiner but I'm not sure the combiner does it's thing after blending, otherwise it wouldn't work. I'm guessing what I want is this:

Result = (Incoming + Destination * (1 - IncomingAlpha)) * IncomingAlpha;
Quote:Original post by Ilici
Well the edge is, though a little less visible, still present. The cloud must be blended with 1, 1 - SRC_ALPHA and I have no idea how to make it fade then. My simulation will have to do without switching from the impostor billboard to the 3d particles :(.

Maybe something could be done with the combiner but I'm not sure the combiner does it's thing after blending, otherwise it wouldn't work. I'm guessing what I want is this:

Result = (Incoming + Destination * (1 - IncomingAlpha)) * IncomingAlpha;


Well the edge is still visible because I did a quick erase to remove the worst of it. If you removed all the black, then I'd think that it would disappear entirely.
This is the difference between images generated for alpha (which would be mostly white), and images generated with pre-multiplied alpha (which is what you have). GL_ONE, GL_ONE_MINUS_SRC_ALPHA is the pre-multiplied alpha blending function. Just learn to love it and live with it -- it's the least incorrect options.

It's somewhat un-clear what you mean by wanting to "fade out" with pre-multiplied alpha. If you want to make some parts fade towards black, then just put black into the rendered image, but make the alpha strong.
enum Bool { True, False, FileNotFound };
I may be being stupidly obtuse here, but couldn't you just use ONE,ONE_MINUS as you are doing, then fade the vertex colours to black to fade out?
I mean I want it to fade from opaque to completely transparent.

Thanks to hplus0603 for sorting me out.
try this
fade the color out as well

glColor4f(fade,fade,fade,fade)
draw cloud
Quote:Original post by OrangyTang
I may be being stupidly obtuse here, but couldn't you just use ONE,ONE_MINUS as you are doing, then fade the vertex colours to black to fade out?


Quote:
try this
fade the color out as well

glColor4f(fade,fade,fade,fade)
draw cloud


Omg, that works! Seriously, I thought I tried that but it seems I did something wrong the previous time. Thanks to the both of you, 10x!

Shots:
Full Impostor:


Approx half half:


Full 3D:


[Edited by - Ilici on June 5, 2005 4:33:34 PM]
Quote:
try this
fade the color out as well

glColor4f(fade,fade,fade,fade)
draw cloud

fade =?

This topic is closed to new replies.

Advertisement