PDA

View Full Version : Blue to specular...



starbase1
04-05-2008, 08:56 AM
My first attempt to get heavy duty with nodes...

Elsewhere in these forums I am working on making a VERY high resolution Earth model. And the fewer maps the better - I am permanently up against memory limits, and maximum image sizes.

It came to time to do the specular, and I thought, "In essence I want only the blue stuff to have a specular highlight - can I do this with nodes?"

Attached is what I have come up with. It definitely needs some tuning - values are chosen just to make sure it works, and I am using a low resolution Earth map. But I think I am on the right track here.

Here's an outline of the approach, to explain the node diagram.

I take the blue and red channels, and subtract the red from the blue. (I tried green it did not work so well). For water this number should be definitely positive. I multiply it up, to get a bigger number. This is then clamped to values between 0 and 1.

The other scalar is just to set the shininess.

I've attached the test image, also one called 'ugly' which shows dark edges on the land - not sure what is causing them yet, but if anyone has any ideas, lets hear them!

Am I doing it right?
Any suggestions?

dpont
04-05-2008, 09:50 AM
I don't know if this is the most simpler or faster you can do,
but if you want to get a mask for one unique color,
paste it in a Color constant node, substract it to your image,
do a dot product (rxr + gxg + bxb) and invert.
57207

Denis.

Edit: may be I forgot a logic node at the end,
if equal to 1 give 1 else 0.

starbase1
04-05-2008, 09:55 AM
Thanks, I'm not sure I fully understand, but I'll follow the chart and give it a go! It does sound more elegant than my way, and seems to work!

dpont
04-05-2008, 10:03 AM
I think that the substraction is easy to understanstand,
so you get a Null vector for blue (or any other selected color)
then you need a scalar, an addition of 'r + g + b' could be
enough to have a zero scalar, inverted it gives 1,
then with the logic node you force all other values
(non blue colors) to give zero.

Denis.

Edit: I didn't rescale the specular, but you know how.

starbase1
04-05-2008, 10:16 AM
Thanks for the explanation, I have not done dot products in 30 years...

dpont
04-05-2008, 10:17 AM
In fact my theory failed a bit with result equal to 1,
since I used a compressed jpg, the blue in the image
was not constant, may be that's true also in your
image map, so I have added a threshold,
using 0.99 in the logic node works, you can
tweak it if the ocean color vary along the coast.
57208

Denis.

dpont
04-05-2008, 10:51 AM
One thing also, the product can be negative,
so I added an Abs node,
57210

57211

I remember, than picking such region in a image
with Photoshop to make a grey mask may not
be enough even with a threshold, but addition
of several color selection.

Denis.

dpont
04-05-2008, 11:16 AM
The dot could be negative not the inverted dot,
Abs node was not correctly placed,
57212

Denis.

dpont
04-05-2008, 12:55 PM
I have modified a bit the formula to get a smooth
gradient with the threshold, and built an experimental node,
a x32 Color Key node,
57215

57214

In DP Kit/Tools.

Denis.

dpont
04-06-2008, 03:54 AM
Fixed a few things and added a Smoothness control,
57236

57235

Denis.

dpont
04-06-2008, 02:44 PM
Another version (not compatible with previous preset/saved surfaces)
The output has been inverted, but an "Invert" checkbox has been added,
user can now select the color mode, between RGB, HSV and YUV.

57263

57262

Denis.

starbase1
04-06-2008, 03:47 PM
Wow Denis, many many thanks for your help! I never expected a custom node when I asked for advice!

And I can see many other possibilities, as your example shows...

Nick

avkills
04-09-2008, 08:16 AM
Denis, anyway you could compile that for Mac Universal Binary? :D

-mark

JohnMarchant
04-09-2008, 11:18 AM
Also could someone please do a 64bit version,

Thanks, John

dpont
04-14-2008, 01:42 AM
This node has been included in the DP Kit node pack,
with a new Curve Gradient node,
thanks to Marvin Landis for the x64 version,
http://perso.orange.fr/dpont/plugins/nodes/Additionnal_Nodes_2.html

Denis.