Forum: Poser - OFFICIAL


Subject: Underwater submarine

Helgard opened this issue on Jun 26, 2010 · 195 posts


bagginsbill posted Mon, 28 July 2014 at 11:46 PM

For those who want to know the math of the Sun shader...

 

The P node gives absolute world coordinate position of whatever is being lit. It does so in units that are 1/10th of a Poser inch, or 1/1032 Poser Native Units.

I multiply the Y coordinate by .3 because I want inches (.1) and because the XYZ values get averaged as the output goes into a number. In other words, the output will be .3 * 10 * (Y in inches) / 3 which is Y in inches. Voila. We'll call this Y. In matmatic:

Y = P(0, .3, 0).asNumber()

Letting W stand for the water level in inches,

W = 2400

we need to know the depth (d) of the point being shaded below the water surface, so

d = W - Y

We don't want negative depth, so everything less than zero should be treated as 0. (Negative depth means above the water, and should be left alone).

d = Max(d, 0)

We're going to want to scale that depth according to some adjustable attenuation distance, D

D = 1200

d = d / D

The attenuation of light happens according to the exponential function. The attenuated light color RGB(160, 190, 200) goes into an exponentiation with the depth as the exponent and the color as the base.

C = IColor(160, 190, 200) ** d

That's the math for the sun shader.

Why does the negative depth (i.e. stuff above the water) not get changed?

Because for things above the water, we saw to it that d is 0. Any color to the power 0 is white.

Here's the entirety

C = IColor(160, 190, 200) ** (Max(2400 - P(0, .3, 0).asNumber(), 0) / 1200)


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)