Calculating Alpha and Opacity correctly

   6371   7   2
User Avatar
Member
543 posts
Joined: July 2005
Offline
Hi there,

I'm trying to find info regarding the “proper” way to calculate the alpha and opacity values for surface shaders. Wasn't there some docs floating around describing these issues? I've looked all over the SESI and odforce sites but can't seem to find what I was looking for (I could swear there was a .pdf or two just on this subject).

I'm just a bit confused about the way mantra/VEX deals with opacity and alpha compared to prman/RSL.

Can anyone point me to some good docs/tutorials?

Thanks!


–Mark
========================================================
You are no age between space
User Avatar
Member
941 posts
Joined: July 2005
Offline
Hey Mark,

I don't know about those docs, but here's what they represent:

Mantra's Of is *identical* to PRMan's Oi in terms of what goes on inside the renderer. Just as with PRMan's Oi, Mantra's Of determines RGB opacity/coverage for any given sample.

The difference is in what gets put out to the image as its alpha channel. Here, Mantra let's you specify that value explicitly through Af. This allows you to have an opaque object (i.e: it occludes all objects behind it), but whose alpha channel is zero (like a matte object), and other assorted trickery like that

Make sense?
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
543 posts
Joined: July 2005
Offline
Mario Marengo
Mantra's Of is *identical* to PRMan's Oi in terms of what goes on inside the renderer. Just as with PRMan's Oi, Mantra's Of determines RGB opacity/coverage for any given sample. The difference is in what gets put out to the image as its alpha channel.

That I was pretty sure of, well 90% sure :-)

Mario Marengo
Here, Mantra let's you specify that value explicitly through Af. This allows you to have an opaque object (i.e: it occludes all objects behind it), but whose alpha channel is zero (like a matte object), and other assorted trickery like that
Make sense?

Yep, makes sense, Cf and Of are set as you would in RSL based on the look you're trying to achieve, and alpha is (most often) used for masking, etc. Where I'm stuck is I often just average Of and use that as Af, unless I want to mask anything that has color or whatever. That's why I've been looking for some examples or referances of ways to set the alpha channel. I would guess then it really just depends on what you intend to do with that channel, eh?

What led to this is I've got 48 sets of data (texture maps made from the Mars GRS data) that are interpolating over time, 24 of of these maps are comped over the other set (they represent concentrations of hydrogen and carbon dioxide).

What I'm trying to illustrate is the way the CO2 becomes less dense in the Martian summer and thus “exposing” the gamma rays from the H2O on the planet's surface. What my shader was doing is making the CO2 area get really bleached out (I thought I was doing an “over” comp) so I started to concentrate on masking/alpha issues.

I know those docs are around somewhere, I think they come from the version 4.0 era, I'll find them! :-)

Thanks Mario!


–Mark
========================================================
You are no age between space
User Avatar
Member
543 posts
Joined: July 2005
Offline
Hi again,

I'm still a little confused about this; in the past I've referred to other's code/examples too often and want to understand this completely. Let me see if I can explain.

I'd like to do all this layering in one shader but am currently rendering 3 passes, one for the hydrogen, one for the CO2, and one for the “shaded relief” map of the planet's surface. I then comp them all together in SOPs using a composite COP set to “screen” … The results are close to what I'd like to do in the shader but I can't quite figure out what the “screen” operation does different than an “over” operation.

Can someone explain the difference or point me to a good source of info?

Thanks!


–Mark
========================================================
You are no age between space
User Avatar
Staff
5156 posts
Joined: July 2005
Offline
Screen is a saturating add, representative of photographic addition. Its definition is:

C = c1 + c2 - c1*c2

It doesn't use alpha information at all.
User Avatar
Member
543 posts
Joined: July 2005
Offline
twod
C = c1 + c2 - c1*c2
Hi Twod,

Ah, I see. This works good for what I'm doing because the relief map is gray scale, the hydrogen map is color, and the CO2 layer is white, nice effect.

I've been looking all over the web for references (and explanations) of the various compositing methods and found much information, but not something that really explains the physics of what's happening. Would you have any suggestions?


–Mark
Edited by - June 18, 2004 12:22:16
========================================================
You are no age between space
User Avatar
Member
1192 posts
Joined: July 2005
Offline
I found the math for all the usual compositing operations here:
http://www.vbaccelerator.com/home/VB/Code/vbMedia/Image_Processing/Compositing/article.asp [vbaccelerator.com]

Dragos
Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
User Avatar
Member
543 posts
Joined: July 2005
Offline
Thanks for the link!

It's helpful, but doesn't explain the underlying physics of the light, which is what I really want to know.
========================================================
You are no age between space
  • Quick Links