Masking shadows using functions?

Started by Tangled-Universe, December 30, 2009, 03:54:23 pm

Previous topic - Next topic

Tangled-Universe

Hi everybody,

I'm struggling in making a function which masks/isolates shadowed areas.
I Thought of subtracting emitted colour from diffuse colour and then put that into a conditional scalar and then return a value of 1 when the colour is below a certain set level, but I can't get it to work.

Anybody any ideas?

Thanks in advance,

Martin

FrankB

try this:

<terragen_clip>
<conditional_scalar
name = "Conditional scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-1720 180 0"
gui_group = ""
enable = "1"
input_node = "Luminance to scalar 01"
gui_use_preview_patch_size = "1"
gui_preview_patch_size = "125 125"
condition = "4"
comparison_value = "Constant scalar 01"
if_result = "Constant scalar 01_1"
else_result = "Constant scalar 01_1_1"
>
</conditional_scalar>
<constant_scalar
name = "Constant scalar 01_1_1"
gui_use_node_pos = "1"
gui_node_pos = "-1380 240 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
scalar = "1"
>
</constant_scalar>
<constant_scalar
name = "Constant scalar 01_1"
gui_use_node_pos = "1"
gui_node_pos = "-1480 280 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
scalar = "0"
>
</constant_scalar>
<constant_scalar
name = "Constant scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-1560 340 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
scalar = "0.08"
>
</constant_scalar>
<luminance_to_scalar
name = "Luminance to scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-1740 320 0"
gui_group = ""
enable = "1"
input_node = "Get final colour 01"
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
>
</luminance_to_scalar>
<get_final_colour
name = "Get final colour 01"
gui_use_node_pos = "1"
gui_node_pos = "-1640 440 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
>
</get_final_colour>
</terragen_clip>

FrankB

here's how it looks

Tangled-Universe

Thanks Frank :)
I'm not sure though if this really works. It's just a condition for diffuse color.
What I want is to compare the diffuse color with the emitted color. If there's a big difference then it's likely to be a shadow, which I think is a more exact approach.
But maybe it is not possible?

dandelO

I know what you're thinking, TU! I want that, too. :D

FrankB

you'll get your sparkles from luminosity, excluding shadow areas... eventually. maybe. ;)

Tangled-Universe

December 30, 2009, 06:32:21 pm #6 Last Edit: December 30, 2009, 06:43:33 pm by Tangled-Universe
Haha not only, but indeed :) I "want/need" it for something "bigger", how do you say ;D
It would also greatly improve my understanding to get other aspects "selected" using functions. It's still magic to me :(

FrankB

It's really a tough problem to solve... I can't find a way to get the direction of rays from the sun, or any lightsource. Maybe Matt can help, or tell us if this is possible?

Dune

If this is about sparkles in only sunlit areas, and not in shadows, luminosity won't work, as I wrote in the sparkle topic. I might have something, but must test again today. Simply said: get some tiny fake stones, no color (=black) attach a powerfractal for extra tiny displacement (more areas that might sparkle), no color (or black, I can't recall what I did). Then a reflective shader with high settings, all blended by a tiny fractal, color shoved to the left. I'll make a tgd/tgc if I got a decent snowscape.

If this is about snow/vegetationtypes in shadowed areas, and not in sunlit areas, it's an interesting approach, FrankB.

---Dune

FrankB

It will work with luminosity, BUT it has to be manually adjusted per scene. I've done this once in the very early alpha stages, and it looked quite ok :)

Tangled-Universe

That's indeed what I want to do Ulco. I want to place populations/mosses etc. on either lit or unlit areas etc.

It's indeed very useful for the sparkle-thing, though it coincides perfectly it is not the reason I started this ;)

If you can get a camera placed "near" the sun or at least at a considerable altitude and corresponding heading than you can use those coordinates as vector-input for the function, but that's all I can think of so far.

Martin

FrankB

I've tried this briefly as well (with the camera), but couldn't get it to work properly.