Transparency and Shaders

Can anybody help me put together an overview of how Unity shaders work with transparency? I’ve attached a Quicktime 7.0 .mov file to show the effect I’m trying to reproduce in Unity.

I’m replicating our animated fire texture in Unity by putting the textures into a .mov file, which seems to work well, but if I use a single, static particle, the transparency on the particle shaders seems really odd. The only one that really uses the alpha correctly is the “additive-multiply”, but that one makes it all washed out. “Additive” almost disappears completely, and the rest seem to fade the whole thing out, rather than use any kind of alpha.

I also tried switching to a normal polygon with a basic alpha/diffuse shader. That gave me a pretty clear representation of the flame image–much better than ay of the particle shaders, but it needs to be a bit brighter.

The shader we use in our old engine just uses the alpha correctly (like the alpha/diffuse shader does), but then makes opaque portions of the image full-bright. Should I use a polygon to achieve such an animated effect or a particle? Is there a built-in shader that does this or should I try to write a custom one?

I also want the fire image to always stay the same size and vertical orientation, but rotate to always face the camera. I assume that’s just scripting, but perhaps it affects the object vs. particle decision?

Our tests also show that transparency appears to be handled in opposite manners between the different shaders. In the normal shader, a black background shows up as opaque, regardless of a separate alpha channel. Yet if you put the same bitmap into the particle shader the black background is required for the transparency effect.

These tests are all coming out of Photoshop 7.1 using the targa format (note that they changed the targa alpha format from 7.0 to 7.1).

I’m guessing that the particle shader is not actually using alpha, but just color multiplying–that’s why you need the black?

I can’t reproduce it here - the alpha in particle shaders seems to be treated “like it should”. Maybe the texture you have does not import correctly? Try looking in the inspector at the texture and it’s alpha channel. Otherwise, please submit a project that shows the problem via ReportBug.app

To me it looks like this could easily be reproduced with the QT movie flame texture and a very simple “billboard” sript. The only thing I’d add to the recipe is the Alpha/Selph-Illuminated shader available on the WIKI. It should look identical to your example movie with a little tweaking. The “particle additive” shader approach gets washed out since there’s a light behind the torch and the cumulative RGB effect is probably greater than “1”.

Or just using Particle/AlphaBlended should be ok

Excellent advice. So it LOOKS like my real problem is that I can’t get Quicktime to make a movie with Alpha. I’m using 7.1. I’ve tried everything from Sorension Video 3 with color depth “Millions of Colors+” to the new H.264 codec.

I’m attaching a few of the images I’m using to make the Quicktime movie in case anyone can see if the images I’m using are bad or what? If anyone can post any kind of functioning Quicktime Movie that has alpha, that will also help me pin down that the problem is indeed in my Quicktime movie.

By the way, the thing that threw me off is that the “Additive/Multiply” shader seemed to be working, but that must have just been the additive effect, rather than any alpha channel.

14566–493–$torchtestimages_201.zip (36.6 KB)

I thought I read something on the forum about exporting to “Animation” to preserve transparency. Worth a shot at the least…

Until this gets sorted out, Joachim posted a nice workaround in this topic:

http://forum.unity3d.com/viewtopic.php?p=14806#14806

The Animation Codec set to “Millions of colors+” is the only one that will work in Unity I think. Sorenson 3 uses a 1-bit alpha channel as far as I remember and probably won’t cut it. The FPS tutorial uses 2 Animation Codec QuickTime movies in the GUI that have alpha channels (the rocket and ammo counters).

One annoying thing about using QuickTime Pro for exporting movies with alpha is that the movie cannot be resized at export or all is lost. The best method is to import a Tiff image sequence into QT and then export out using the Animation Codec. Or use After Effects with your composition having no background layer and render out to the Animation Codec from there with a straight unmatted alpha channel.

i fixed everything by converting my png sequence (rendered out in maya using mental ray cuz i was using a 3d model with very high poly count), to a .avi with sony vegas.
i then used ffmpeg to convert this avi to a mpng avi file using this line: >ffmpeg -i c:desktopblabla.avi -vcodec png -q:v 4 -an -y out.avi
then i used AVI player with playmaker actions from the asset store to load the file and play it on a plane using the unlit/transparent shader.
wow thats alot haha.
took me alot of time to figure out, i hope this post comes in handy for someone who’s spending way to much time figuring out how to make a video transparent :slight_smile:
greets!