Determining correct falloff

So it was brought to my attention that Viscorbel had found a problem with the custom brdf method I’ve been teaching in the Mastering V-Ray course.

You can read more here.
http://viscorbel.com/vray-materials-part-3-metals/
Image taken from his blog post:

So I did some testing and I honestly expected the reflections to line up to the orientation of the lights (22.5* rotation) but they don’t. Maybe I’m just tired and over thinking this, but from an orthographic camera, shouldn’t these reflections line up and if they don’t, is what Viscorbel trying to do physically correct?

So after thinking about it for a second I realised it’s because the thickness of the sphere offsets the angle at which the ray hits the surface.

Just need confirmation that the 3dsMax Falloff map does work linearly and everything is correct.

I’ve just tried this and I get the same result as Viscorbel.

Correct me if I’m wrong but you are expecting the falloff map to return RGB 128 at 45 degrees. It appears that it actually returns RGB 76.

I’ve attached a couple of images and a Max 2014 scene if anyone else want to check.



Falloff Test.zip (96.7 KB)

The falloff map is not linear, the correction curve to linearize it looks roughly like the attached image.

Seems that 3ds max uses some math behind the scenes to distort it for some reason.

Does that curve look a tiny bit srgb-ish?

The Falloff map works with the cosine of the angle, and not with the actual angle. The curve that viscorbel shows above is the graph of its inverse (the arccos function).

Best regards,
Vlado

It kind of does, but it’s not…
Here’s an overlay

I’ve tried correcting the falloff map with gamma or reverse gamma, but that doesn’t fix it, just distorts it differently

I knew someone smarter would figure out the math behind it :slight_smile:

That’s exactly what I thought but I can’t make the maths to fit.

255 * (0.5^2.2) = 55.5

I’m getting a value of approximately 76 at 45 degrees.

Use cos/arccos instead…

Best regards,
Vlado

Maybe this could be implemented with an OSL-Texture, so that we could use it with the gradient remap like Viscorbel mentioned here:


Feel free :slight_smile: That’s what OSL is for.

Best regards,
Vlado

Hehe, yeah I’m trying to do so, but my maths skills are just not good enough.
I got the part with the facing ratio, but I can’t get the arccos-thing to work:

shader facing_ratio_linear (

        output color Col_Out = color(0.5)
)
{

    float facing = 1 - (dot(normalize(N), normalize(I))* -1);
        Col_Out = color(facing , facing , facing );

}

I try to get the graph we are after here:

with the function: acos(x)

But this just doesn’t look like the graph we need…

Try acos(1-x)/(pi*0.5)

Best regards,
Vlado

Yes, that does it:

facing_ratio_linear.osl

shader facing_ratio_linear (
       output color Col_Out = color(0.5)
)
{
       float floatOut = acos (1.0 - (1 - (dot(normalize(N), normalize(I))* -1)))/(M_PI * 0.5);
       Col_Out = color(floatOut  , floatOut , floatOut );
}

Thanks Vlado!
facing_ratio_linear.zip (336 Bytes)

Haha! awesome man :slight_smile:
Now we can use the osl in both falloff slots and have a linear result. Thanks!

So problem solved Grant, just need to use this little osl for correcting all your reflection maps :wink:

Haha! awesome man :slight_smile:
Now we can use the osl in both falloff slots and have a linear result. Thanks!

In fact, you don’t even need to use a falloff map anymore. You can just use an output map to alter the curve, since this should be a little bit more effective for computation, I guess. :slight_smile:

Yes, if you can recreate the same curve with an Output map, it’s probably going to be somewhat more efficient than the OSL shader (there’s some overhead involved with OSL, even if the shader is just one line).

Best regards,
Vlado

Now, could someone also show the difference this has on a material? Just curious to know if this was all worth it :slight_smile:

It was worth it! :slight_smile: