Forums

You are not logged in.

#1 2012-07-23 13:55:01

Atom
Member
Registered: 2009-06-17
Posts: 42

Implementing Multiply/Add modes for AO?

Hi All,

I am trying to implement two different modes for mixing the results of AO calculations.

I have Add working but I am not sure how to modify the equation to make multiply work?

Code:

// Calculate the illumination model.
Oi = Ot;
if (ao_blend_type == 0) {
    // Ambient occlusion Add.
    sc = Ct * ((ambient_intensity*ambient()) +
        (diffuse_intensity*diffuse(Nf)) + 
        (ao_intensity * ambient_occlusion)) + 
        specular_color * specular_intensity * specular(Nf,V,(specular_hardness/500)) + 
        (my_Kr * Cr);
} else {
    // Ambient occlusion Multiply.
    sc = Ct * ((ambient_intensity*ambient()) +
        (diffuse_intensity*diffuse(Nf)) + 
        (ao_intensity * ambient_occlusion)) + 
        specular_color * specular_intensity * specular(Nf,V,(specular_hardness/500)) + 
        (my_Kr * Cr);        
}

Does anyone have any tips on modifying the second calculation?

Thanks!

Last edited by Atom (2012-07-23 13:55:43)


Blender 2.6.3
Windows XP64 3Gb
3Delight 9.0
Matt Ebb's 3Delight Exporter 0.76

Offline

 

#2 2012-07-23 17:39:29

bertrand
Member
From: Vancouver
Registered: 2007-01-09
Posts: 324
Website

Re: Implementing Multiply/Add modes for AO?

Hi Atom,

This all looks odd to me.
With the standard amb+diff+spec model, the ambient is multiplied by the occlusion. (The diif+spec being modulated by shadows.)
I'm not sure what the ao_intensity refers to in your model. Envmap lookup? Shader parameter?
Cheers,
B.

Offline

 

#3 2012-07-23 17:41:42

DavC
Member
Registered: 2011-07-13
Posts: 20

Re: Implementing Multiply/Add modes for AO?

I'd say like this...

// Calculate the illumination model.
Oi = Ot;
if (ao_blend_type == 0) {
    // Ambient occlusion Add.
    sc = Ct * ((ambient_intensity*ambient()) +
        (diffuse_intensity*diffuse(Nf)) +
        (ao_intensity * ambient_occlusion)) +
        specular_color * specular_intensity * specular(Nf,V,(specular_hardness/500)) +
        (my_Kr * Cr);
} else {
    // Ambient occlusion Multiply.
    sc = Ct * ( ( (ambient_intensity*ambient()) +
                       (diffuse_intensity*diffuse(Nf)) ) *
                       (ao_intensity * ambient_occlusion) ) +
        specular_color * specular_intensity * specular(Nf,V,(specular_hardness/500)) +
        (my_Kr * Cr);       
}

So in the end we get this simple idea for multiply...
( ( ambient + diffuse ) * ao ) + specular + reflection

And this for add...
ambient + diffuse + ao + specular + reflection

However I must say, from personal experience, I don't know why you would want to "add" ambient occlusion, unless you have "ao_intensity" as an environment map, or something like that.

Personally I'd much prefer this...
( ambient * ao ) + diffuse + specular + reflection
It's more "physically correct".

How that helps,
David Cattermole

Offline

 

#4 2012-07-24 06:54:59

Atom
Member
Registered: 2009-06-17
Posts: 42

Re: Implementing Multiply/Add modes for AO?

Thanks for the info. I am still new at shader writing and have been developing mostly from Renderman books. I am trying to emulate the Blender features for AO which include Add and Multiply. In Blender you typically use Add mode for a full CG, no footage rendered scenes. If you are compositing your 3D with footage you typically use Multiply.

ao_intensity, in this case is the amount of the AO that you want to include in the final. Further up in my shader I calcualate ambient_occlusion as a color using either gather or occlusion.  But if I only want 50%of that included in my final I would set ao_intensity to 0.5.

One more quick question, what is the best way to include Cs in your final solution?
Would it just be

Code:

Cs * ambient + diffuse + ao + specular + reflection

or

Code:

Cs + ambient + diffuse + ao + specular + reflection

Last edited by Atom (2012-07-24 07:10:25)


Blender 2.6.3
Windows XP64 3Gb
3Delight 9.0
Matt Ebb's 3Delight Exporter 0.76

Offline

 

#5 2012-07-24 12:07:16

bertrand
Member
From: Vancouver
Registered: 2007-01-09
Posts: 324
Website

Re: Implementing Multiply/Add modes for AO?

Cs should be the base surface color. You can't add it.
It should be something like c = Cs * textureColor. Then you do c * ambient + c * diffuse.

As for the ao, it should also scale the ambient portion, not just the diffuse. (In fact, you don't generally want your ao fo scale the diffuse. Although sometime you do.)

Offline

 

Board footer

PunBB is © Copyright 2002–2005 Rickard Andersson

You are here: Resources » Forums
Follow us on Twitter
© 2006-2011 dna research. All Rights Reserved.
Trademarks & Copyrights Notices