Planetside Software Forums

General => Terragen Discussion => Topic started by: Tangled-Universe on December 30, 2009, 03:54:23 PM

Title: Masking shadows using functions?
Post by: Tangled-Universe on December 30, 2009, 03:54:23 PM
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
Title: Re: Masking shadows using functions?
Post by: FrankB on December 30, 2009, 05:06:48 PM
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>
Title: Re: Masking shadows using functions?
Post by: FrankB on December 30, 2009, 05:10:41 PM
here's how it looks
Title: Re: Masking shadows using functions?
Post by: Tangled-Universe on December 30, 2009, 05:56:59 PM
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?
Title: Re: Masking shadows using functions?
Post by: dandelO on December 30, 2009, 06:15:42 PM
I know what you're thinking, TU! I want that, too. :D
Title: Re: Masking shadows using functions?
Post by: FrankB on December 30, 2009, 06:17:27 PM
you'll get your sparkles from luminosity, excluding shadow areas... eventually. maybe. ;)
Title: Re: Masking shadows using functions?
Post by: Tangled-Universe on December 30, 2009, 06:32:21 PM
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 :(
Title: Re: Masking shadows using functions?
Post by: FrankB on December 30, 2009, 07:07:25 PM
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?
Title: Re: Masking shadows using functions?
Post by: Dune on December 31, 2009, 02:34:52 AM
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
Title: Re: Masking shadows using functions?
Post by: FrankB on December 31, 2009, 05:10:02 AM
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 :)
Title: Re: Masking shadows using functions?
Post by: Tangled-Universe on December 31, 2009, 05:12:09 AM
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
Title: Re: Masking shadows using functions?
Post by: FrankB on December 31, 2009, 08:21:59 AM
I've tried this briefly as well (with the camera), but couldn't get it to work properly.