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 & HelpOpenGL and 3D Libraries › Applying Multiple Alpha Masks
Page Index Toggle Pages: 1
Applying Multiple Alpha Masks (Read 1091 times)
Applying Multiple Alpha Masks
Sep 17th, 2005, 1:24am
 
I'm playing with implementing Daniel Shiffman's Smoke Particle System example in OpenGL/3d.  The original example first uses a greyscale texture map to add an alpha channel to a solid white image, then uses the tint() method to uniformly fade the alpha towards transparency as the particle's age increases. Now, tint() doesn't work for GL textures.

I -could- make a 2d PGraphics object, draw the texture to it, then tint() it, then make the PGraphics object the quad's texture, but that seems likely to bog down the system when the number of particles increases.  The other option is to use the loadPixels() command, iterate through the pixels in the image, modify the alpha channel, then updatePixels.  However, the way I have things set currently,  when I do this, it modifies the PImage object that all the particles use directly.  I think I need to make a unique copy of the PImage (ie, not just newimage = oldimage, which just makes a reference) .. what's the easiest way to do this?   I'm working with PImage.copy() right now but it seems like there should be an easier way

Help?

Regards,
Ryan Spicer
Re: Applying Multiple Alpha Masks
Reply #1 - Sep 17th, 2005, 1:05pm
 
You can skip the whole tint thing actually. If you remember the old quad-texture demo. All you have to do is set an alpha channel on the fill:
Code:

fill(red,green,blue,alpha);

Although you're mapping a texture to the object you also wind up tinting it the colour of the current fill setting.

I discovered this the hard way as I was doing a fill(0); and trying to map a texture at the same time. Very confusing.

I'd stay away from PGraphics2 and Java2D for the time being. I discovered a bug the other day with drawing alpha channels and there seem to be a lot of posts about PGraphics2 being a pain. P3D and PGraphics3 are bound to be much more stable.
Re: Applying Multiple Alpha Masks
Reply #2 - Sep 17th, 2005, 4:41pm
 
st33d.. you, sir, are the man.  Thanks so much for your fast responses to my n00bie questions as I get up to speed with P5. Big kudos.

Cheers,
Ryan Spicer
Re: Applying Multiple Alpha Masks
Reply #3 - Sep 17th, 2005, 5:01pm
 
so there's some confusion in the current code for fill vs. tint and how they work.. in opengl, textures respond to fill, and in P3D (i believe), textures work with tint. the "correct" method is that tint() will color textures (not fill), because people wind up being surprised (annoyed) when fill(0) makes their texture black, so it's better to make it explicit by using tint().

these issues are also logged as a bug here:
http://dev.processing.org/bugs/show_bug.cgi?id=90
so you can check there to see progress.
Page Index Toggle Pages: 1