We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Texture fading to transparancy
Page Index Toggle Pages: 1
Texture fading to transparancy (Read 493 times)
Texture fading to transparancy
Apr 22nd, 2008, 4:03pm
 
Hey guys,
is there any way to achieve an effect of fading a polygons texture to complete tranparancy?
During runtime I create a PImage and then gradually add more transparancy to each row of pixels like this:
Quote:
int b = 0;
for (int i = 0; i < copyOfImage.pixels.length; i++) {
   int currR = (image.pixels[i] >> 16) & 0xFF;
   int currG = (image.pixels[i] >> 8) & 0xFF;
   int currB = image.pixels[i] & 0xFF;

   if (i%image.width == 0)
      b++;

copyOfImage.pixels[copyOfImage.pixels.length -i -1] = pa.color(currR, currG, currB, b * 2);
}


This works when I display the image with the 'image()' function. But this only allows me to draw it at Z=0 (right?)

Thus I set the image as a texture of a polygon but then the gradual alpha effect is lost and it seems that only the whole texture can be set to have one alpha value with the 'tint()' function, which is not what I want.

There has to be a way to achieve this. Any ideas?

Re: Texture fading to transparancy
Reply #1 - Apr 24th, 2008, 2:53pm
 
Nevermind, I figured it out..
Re: Texture fading to transparancy
Reply #2 - Apr 24th, 2008, 4:56pm
 
How did you do it?
Re: Texture fading to transparancy
Reply #3 - Apr 25th, 2008, 5:45pm
 
Actually it works with the method I  posted before. Just assign that PImage as a texture to a polygon and it works. I overlooked that somewhere in my code the texture was reset to a non transparent one again..thats what u get when u try coding at 3am. =)
Page Index Toggle Pages: 1