Fresnel Function

Started by old_blaggard, December 29, 2009, 08:50:27 pm

Previous topic - Next topic

old_blaggard

Just a quick little thing that I whipped up in relation to this thread: http://forums.planetside.co.uk/index.php?topic=8402.0

Here's what it does:
- Anything facing the camera exactly gets a value of 1.
- Anything facing 90 degrees away from the camera gets a value of 0.
- Everything in between is interpolated linearly.
- The whole thing is automatic - it will adjust whenever you move your camera.

Enjoy!
http://www.terragen.org - A great Terragen resource with models, contests, galleries, and forums.

Walli


dandelO


mogn

Thanks for the tgc. But it seems to output the value 1 m anywhere?

See alternative implemention:

old_blaggard

Heheh, I didn't know that the length to scalar node was hiding in there ;).

Could you clarify what you mean by "... value 1 m anywhere?" I'm not sure I follow.
http://www.terragen.org - A great Terragen resource with models, contests, galleries, and forums.

mogn

Create a displacement shader and connect the output from the fresnel networh to the righthand input.
Double press the displacementshader, and show the small display in a new window.
Then you can see the numerical output (y as a function of x,z) from the fresnel network by placing the mouse
in the new window.

Tangled-Universe

Hi Paul,

Me again :) I haven't been able to do something really useful with it, I'm also not sure if it works, but that could also be because I'm not 100% sure how to apply it.
Which of the 2 should work, or both? And how?
Thanks in advance :)

Martin

old_blaggard

Martin - I believe that the two should function identically. It was certainly working for me when I sent it to you last night.

mogn - For some reason your experiment reminds me of a proof Turing made about why you cannot have a program that determines whether any given program terminates or not ;). I'm about to run out the door, but I'll say this - I wouldn't recommend using this function to drive displacement, as it is largely itself dependent on displacement and this might lead to unexpected results.
http://www.terragen.org - A great Terragen resource with models, contests, galleries, and forums.

mogn

Quote from: old_blaggard on December 30, 2009, 11:00:20 am
Martin - I believe that the two should function identically. It was certainly working for me when I sent it to you last night.

mogn - For some reason your experiment reminds me of a proof Turing made about why you cannot have a program that determines whether any given program terminates or not ;). I'm about to run out the door, but I'll say this - I wouldn't recommend using this function to drive displacement, as it is largely itself dependent on displacement and this might lead to unexpected results.


No paradox. The displacement shader has no connection to other parts of the schene, but is a very good tool to inspect the output
of scalar nodes.

Matt

January 01, 2010, 09:14:58 pm #9 Last Edit: January 01, 2010, 09:21:13 pm by Matt
Hi Mogn,

Your divide scalar node won't give the result you want, because divide scalar expects both inputs to be scalars. If any of its inputs are vectors, they are converted to scalars by using the length of the vector, so you lose the vector information. In your example the result of the divide scalar is then converted back to a vector for the dot product node by copying the scalar into each component, which gives the wrong result.

What you want is divide vector. It's OK for one of its inputs to be a scalar.
Just because milk is white doesn't mean that clouds are made of milk.

mogn

January 01, 2010, 10:56:26 pm #10 Last Edit: January 01, 2010, 10:58:45 pm by mogn
Matt of cause, It should be a divide vector (to normalize the vector). but this does not explain why I get a contant output
from the last node in the original network. See reply #8

Matt

Quote from: mogn on January 01, 2010, 10:56:26 pm
Matt of cause, It should be a divide vector (to normalize the vector). but this does not explain why I get a contant output
from the last node in the original network. See reply #8


The shader preview renders with a narrow FOV from a high camera, so the dot product on a flat surface will probably give values close to 1 everywhere
Just because milk is white doesn't mean that clouds are made of milk.

RRMessiah

Hi Guys,

Late reply,  but thanks for the function. Can you help me with the math behind adjusting the tightness of the falloff and limiting what normals have a value > 0?

Thanks! 

old_blaggard

If you're looking to adjust the falloff, I would recommend plugging the output through a color adjust shader, which will allow you to clamp and scale the transition quite easily.
http://www.terragen.org - A great Terragen resource with models, contests, galleries, and forums.

RRMessiah

Ack! I should've known. Thanks! Works great.