Author Topic: Masking shadows using functions?  (Read 3388 times)

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6183
    • CGScenery.com - Terragen Tutorials!
Masking shadows using functions?
« on: December 30, 2009, 07: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

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masking shadows using functions?
« Reply #1 on: December 30, 2009, 09:06:48 PM »

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masking shadows using functions?
« Reply #2 on: December 30, 2009, 09:10:41 PM »
here's how it looks

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6183
    • CGScenery.com - Terragen Tutorials!
Re: Masking shadows using functions?
« Reply #3 on: December 30, 2009, 09: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?

dandelO

  • Guest
Re: Masking shadows using functions?
« Reply #4 on: December 30, 2009, 10:15:42 PM »
I know what you're thinking, TU! I want that, too. :D

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masking shadows using functions?
« Reply #5 on: December 30, 2009, 10:17:27 PM »
you'll get your sparkles from luminosity, excluding shadow areas... eventually. maybe. ;)

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6183
    • CGScenery.com - Terragen Tutorials!
Re: Masking shadows using functions?
« Reply #6 on: December 30, 2009, 10: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 :(
« Last Edit: December 30, 2009, 10:43:33 PM by Tangled-Universe »

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masking shadows using functions?
« Reply #7 on: December 30, 2009, 11: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?

Offline Dune

  • Member
  • *
  • Posts: 15128
    • www.ulco-art.nl
Re: Masking shadows using functions?
« Reply #8 on: December 31, 2009, 06: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

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masking shadows using functions?
« Reply #9 on: December 31, 2009, 09: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 :)

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6183
    • CGScenery.com - Terragen Tutorials!
Re: Masking shadows using functions?
« Reply #10 on: December 31, 2009, 09: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

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masking shadows using functions?
« Reply #11 on: December 31, 2009, 12:21:59 PM »
I've tried this briefly as well (with the camera), but couldn't get it to work properly.