Planetside Software Forums

General => Terragen Discussion => Topic started by: uuderzo on July 14, 2020, 08:36:32 AM

Title: Daydreaming on shadow catcher
Post by: uuderzo on July 14, 2020, 08:36:32 AM
Sorry for my daydreaming...

I was thinking about using a shadow catcher shader to drive a displacement shader. The purpose of all this mess should be using shadows to define, say, snow accumulation points in one side of objects like trees or rocks.
Obviously this would end in a recoursive problem as the displaced terrain will not catch shadows the same way as the undisplaced one.
But maybe there is some kind of iterative approach that lets one to first project a light on the terrain, bake it then use the projected shadow to drive the displacement shader?

Umberto
Title: Re: Daydreaming on shadow catcher
Post by: Hetzen on July 14, 2020, 09:04:30 AM
Or just turn the Atmosphere and Enviro Light off, with your planet colour set to white, and render a projection (top down, camera projection) and you will have a reversed mask, you can re-import to use with a Surface shader.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 14, 2020, 12:48:57 PM
Ok, more or less... something happened.
I need to stop thinking that a final image can be achieved by a single render pass...
I'm too lazy ::)
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 14, 2020, 02:41:55 PM
Doing a white surface with no GI, Enviro Light, or Atmosphere like Ulco suggested seems the best bet. You can then capture the shadow, and edit it as a map in PS or w/e. Aligning it back to the terrain may be annoying.

Quick test to show you result. I went little extreme on the Gaussian blur but more or less the idea.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 14, 2020, 03:43:14 PM
I will say, it would be nice if the shadow could be used as an active mask but it gets this data at render time I believe. After displacement calcs.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 14, 2020, 04:27:27 PM
Well, aligning the mask wasn't so much annoying.
I simply used the same downward camera as a projection camera and it went in the right place in a snap.

The annoying thing is that the rendered mask needs to be post processed in some image editor to get a gaussian smoothing.
Yes it would be cool being able to use the shadow catcher as an active input for other shaders but i guess this would introduce lots of issues.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 14, 2020, 06:26:12 PM
Yeah that would work for a certain perspective, but if you change your scenes location or camera you gotta preserve with a dupe camera or back at square one with another export.

Unfortunately there is no way to "blur" geometry beyond smoothing controls for noise and roughness but if there was, I imagein with like rocks you could easily just have a duplicate rock setup, at a larger scale, and than use a directional mask to create a buildup. Then again maybe not because we can't scale up from location, the whole area is scaled out.
Title: Re: Daydreaming on shadow catcher
Post by: Dune on July 15, 2020, 01:23:11 AM
It wasn't me, but Jon ;)
But it would indeed be very nice if Matt could make it so that shadows could be used directly. On the other hand, you get all sorts of problems, because whole mounatins and trees shed shadows, and you'd want the effect locally, I presume.
Title: Re: Daydreaming on shadow catcher
Post by: Hetzen on July 15, 2020, 07:47:54 AM
If you use the shadow at render time to displace, how do you then caste a new shadow from that displacement?
Title: Re: Daydreaming on shadow catcher
Post by: Dune on July 15, 2020, 07:50:37 AM
You have a point :-[ :P
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 15, 2020, 11:48:21 AM
Guess the shadow catcher may be used to alter color only, not displacement.

Moreover, after a bit of thinking about it, being able to catch shadows and displace in one single pass would be limiting because you could not cast a real final shadow from a different direction. The shadow catcher should be able to catch only a single light source, not visible in final rendering, used only for the fake shadow displacement.

And i don't think this would be easy to handle, if possible.
Title: Re: Daydreaming on shadow catcher
Post by: Hetzen on July 15, 2020, 01:41:22 PM
I suppose to make the effect more accurate, you could render a few shadow masks of the sun through it's arc of a day, add together, then divide by the number of images used. I guess that could simulate what would happen with temperatures.

But to be honest, the effect you've rendered looks like a fairly good representation of a snow drift. Using the Smoothing Effect in a Surface Layer, should knock out some of the lower octave noise.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 15, 2020, 02:11:58 PM
Quote from: Hetzen on July 15, 2020, 01:41:22 PMI suppose to make the effect more accurate, you could render a few shadow masks of the sun through it's arc of a day, add together, then divide by the number of images used. I guess that could simulate what would happen with temperatures.

But to be honest, the effect you've rendered looks like a fairly good representation of a snow drift. Using the Smoothing Effect in a Surface Layer, should knock out some of the lower octave noise.


I think that's a projected image map so it wouldn't be effected by smoothing shaders. I'm not sure what's up with the roughness.

I also tried to do fake stones out of a PF, and use it translated and smoothed to do similar, and the effect just wasn't right as the octaves get larger and bulbous and out of shape. Doesn't really look like pileup. Similar to blurring a image map as well, based on hard Fake Stone shapes (but I think your sun arc method would work there).

Also sorry name mix up!
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 15, 2020, 02:58:18 PM
Using a plane as SSS works a lot better, as you don't have displacement mixing artifacts from trying to mask out the snow buildup on displacement. SSS also allows you to do transmission so the end of the snow looks right laying on the rock. The only issue is it seems the shadow fixes for objects, introduces broken shadows to surfaces lol but you can get pretty quick render times with hard surface approximation (no fix for shadows). The crop was 33 second with youtube sucking up CPU.

Second image lower sun and little more depth.
Title: Re: Daydreaming on shadow catcher
Post by: Kadri on July 15, 2020, 09:05:02 PM
Your examples above are already good.
I just looked for a different approach that might not the best but you could use a negative light too with luminosity on the object.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 15, 2020, 11:02:57 PM
How interesting Kadri! Great thinking, thanks for sharing.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 16, 2020, 02:16:26 AM
Quote from: Hetzen on July 15, 2020, 01:41:22 PMI suppose to make the effect more accurate, you could render a few shadow masks of the sun through it's arc of a day, add together, then divide by the number of images used. I guess that could simulate what would happen with temperatures.

But to be honest, the effect you've rendered looks like a fairly good representation of a snow drift. Using the Smoothing Effect in a Surface Layer, should knock out some of the lower octave noise.
I added more noise in the snow accumulation area (sorry I didn't know it is called drift) to add some detail and make it slightly different from the surroundings. Without, it looked weird to me.
My target was to simulate the snow accumulation brought by wind. This is the reason that made me initally think about shadows.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 16, 2020, 09:01:42 PM
I had another thought, though I haven't attempted it yet, but it really leaves you with just one angle of approach, a vector export would give you sides, which than you could use as masks in PS etc. You could than "retain" the rock/object on a side, and then all others blur it out, and adjust intensity and would assentialy create soft buildup around the object leaving one side intact. You'd have to use the "one side" mask to mask the Y data and blur out the rest I'd imagine.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 17, 2020, 08:42:36 AM
This is another approach for a single render result.

I decoupled the terrain by creating an heightfield then rendered it again shifted and smoothed. Looks like this is the only way to break the transformation chain up to the upper node. I still have some issues in the mixing part because the merger if set to "highest" seems to honour the highest displacement but color don't seem to follow the same logic, as you can see the white appears also on gray stones sometimes.
Title: Re: Daydreaming on shadow catcher
Post by: Dune on July 17, 2020, 09:16:17 AM
If you create your stones from a PF (or voronoi blue node setup), so you have soft white dots on black, and use a compute normal to blow them up laterally after initial displacement in Y, you could try using the initial (dot) masking, shifted half a meter or so by transform shader for snow pile-up mask. But you need one-size stones for that or the distance won't fit all.
Title: Re: Daydreaming on shadow catcher
Post by: Hetzen on July 17, 2020, 09:46:21 AM
I think the issue with the Merge Shader in this case, is that the colour mapping has to adjust to new polys being created.

A more expensive, but way crisper approach, would be to put your snow surface on a planet sized sphere and your stones on the planet (or vice versa). That way you would have proper intersection between the two texture/displacement surfaces.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 17, 2020, 02:02:04 PM
Quote from: Hetzen on July 17, 2020, 09:46:21 AMA more expensive, but way crisper approach, would be to put your snow surface on a planet sized sphere and your stones on the planet (or vice versa). That way you would have proper intersection between the two texture/displacement surfaces.

Yeah I mentioned that above, though with a plane. It would give you the best realistic result when coupled with SSS to if not for the totally broken shadows.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 17, 2020, 02:50:06 PM
Quote from: WAS on July 17, 2020, 02:02:04 PM
Quote from: Hetzen on July 17, 2020, 09:46:21 AMA more expensive, but way crisper approach, would be to put your snow surface on a planet sized sphere and your stones on the planet (or vice versa). That way you would have proper intersection between the two texture/displacement surfaces.

Yeah I mentioned that above, though with a plane. It would give you the best realistic result when coupled with SSS to if not for the totally broken shadows.
Sorry what stays for SSS?
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 17, 2020, 03:54:45 PM
Quote from: uuderzo on July 17, 2020, 02:50:06 PM
Quote from: WAS on July 17, 2020, 02:02:04 PM
Quote from: Hetzen on July 17, 2020, 09:46:21 AMA more expensive, but way crisper approach, would be to put your snow surface on a planet sized sphere and your stones on the planet (or vice versa). That way you would have proper intersection between the two texture/displacement surfaces.

Yeah I mentioned that above, though with a plane. It would give you the best realistic result when coupled with SSS to if not for the totally broken shadows.
Sorry what stays for SSS?

Oh sorry, yeah SSS is kinda confusing cause we also use it for Simple Shape Shader, but I meant the Subsurface Scattering Effect of the Glass Shader under PT renderer. However similar settings can work under standard renderer. With the standard renderer and pseudo-subsurface effects, the shadows aren't broken.
Title: Re: Daydreaming on shadow catcher
Post by: Hetzen on July 17, 2020, 05:43:29 PM
I think planes makes things simpler certainly, you don't have to adapt to curvature in the projection.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 17, 2020, 06:00:52 PM
Quote from: Hetzen on July 17, 2020, 05:43:29 PMI think planes makes things simpler certainly, you don't have to adapt to curvature in the projection.

It is, and I think I thought I was having issues with it but turns out it's just a issue with the glass shader in standard render. Corner of the renders, part of the glass would be very dark, almost look as though it wasn't there. I tried 360 degrees optimal crop but didn't seem to do anything, so not sure what was going on there.

In the mean time I switched back to the basic default shader snow, and played with some stuff.

Here we have buildup of terrain, and the fake PF based rocks. Notice more "untouched" snow from melt on the right/east (and towards camera; Translation 0.3, 0, -0.1) side following same result for rocks. The terrain snow buildup may look better with more extreme offsets. I'm also attempting to mask, and offset slopes as well though not positive it's working as desired.
Title: Re: Daydreaming on shadow catcher
Post by: Hetzen on July 17, 2020, 06:58:58 PM
Yeah that works great. It's tough to get a softened version to intersect well.

Maybe a Bias Scalar on your shadow displacement to curve out the black into the white a little more softly.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 17, 2020, 07:08:02 PM
Quote from: Hetzen on July 17, 2020, 06:58:58 PMYeah that works great. It's tough to get a softened version to intersect well. Maybe a Bias Scalar on your shadow displacement to curve out the black into the white a little more softly.

I haven't tried but from how the layering of the meshes work I think the only real fix beyond "translucency" in default shader is subsurface scattering, whether pseudo or not. That way you can get that melt transmission a little better defined.

Seems the Default Shader even has it's issues too. At a distance the translucency effect becomes hard and noticeable. Wonder how that could be helped.
Title: Re: Daydreaming on shadow catcher
Post by: Hetzen on July 17, 2020, 07:21:17 PM
I was thinking more of the displacement of the snow layer. There's a hard line where the drift starts. It maybe softened out either with the gamma in the image map? Or possibly a Bias Scalar with a low value like 0.1 feeding the displacement?
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 17, 2020, 07:46:23 PM
Oh I see, yeah that's the floor of the rock shader, I think a soft clamp would fix that.
Title: Re: Daydreaming on shadow catcher
Post by: Dune on July 18, 2020, 01:09:36 AM
So you're playing with the method I mentioned? Shifting the mask for stones for snow pile-up? You may need a voronoi setup to get a really rounded, more uniform base. I tried perlin, but the pile-ups didn't always match. I also tried using fake stones masked by the base mask, but they are too inconsistent. It is pretty hard to get soft, smooth snow and rough stones.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 18, 2020, 02:37:13 AM
Yeah that's what I've initially been using after showing how FS will still be angular and useless really.

I am using voronoi billows which works alright. Kinda down to seed cause still some bunching here and there that kinda does the perlin blob thing.

This does work nicely I must say, but it lacks any melt areas and breakup to intersections without full PT subsurface, but unfortunately shadows are broken up and hard.

I may put this up on my gumroad tomorrow for donation optional (their free mode thing) if I dont go into emergency dentist.
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 18, 2020, 02:14:47 PM
Another issue with using billows, is the voronoi folds can end up on your buildup, and no way to remove them. Similar issues when creating lateral displacement with voronoi, I'm sure you're aware.

Idea

It would be cool if there was a function for the world light source position (based on whatever input sun), that could be used in conjunction with the dot product of the terrain and normals to do what we want via sun position. Now shadows needed, just position of a sun.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 19, 2020, 03:43:36 AM
Tried a variation on @Hetzen and @WAS hints.

This time i placed the rocks on a planet, and the drifted snow on a second planet (both planets are identical and simply work a "domain separators").
I find the result quite promising, there is some little glitch where surfaces are nealy matching but this is mainly because i didn't work on a plane. By the way, not working on a plane adds some interesting variations on the drifts, ok they are not wanted but they are there, maybe using a different shifting method may fix this :D
Shadows are ok (i added some translucency only for aesthetical purpose, just to see the result but looks like it works also without SSS).
Title: Re: Daydreaming on shadow catcher
Post by: Dune on July 19, 2020, 10:00:39 AM
The hard edges in the snow drift is what was my problem too. If time permits, it would be interesting to have a go at a good way to do this.... I have an idea in my head (remembering an accidental shift once), but hope to be able to find it again.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 19, 2020, 10:29:26 AM
Would it be possible to compute the gap between the two layers and use it to drive the shader transparency?
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 19, 2020, 01:25:17 PM
Looks good, how are you smoothing the fake stones?

The best way to handle the transmission is going to be the glass shader and longer render times using pseudo subsurface or PT, but with PT shadows break.

But yeah when I use Fake Stones the angles are just too much (see attachment)
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 19, 2020, 02:17:34 PM
@WAS, to smooth fake stones i routed them to a heightmap generator, then smoothed the heightmap and shaded again on another planet, identical to the first one. I attached the project to my previous message.
The problem would be using the same technique with a rock population...
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 19, 2020, 02:39:43 PM
Oh that's a great idea. Didn't even think of that.

And yeah, a rock population would be difficult. I think the microexporter can handle rocks on terrain with proper settings if I remember from tests. That could be used in another program to smooth up and give than imported as a plane and offsetted.

Also I uploaded my projects: https://planetside.co.uk/forums/index.php/topic,28102.0.html
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 19, 2020, 08:21:39 PM
Quote from: uuderzo on July 19, 2020, 02:17:34 PMThe problem would be using the same technique with a rock population...

Tackling that, there seems to be no way to make sure the population lands on exactly every spot in your map, but for the most part, rocks do show up where they need to be.

I used a very high contrast unclamped billows map, plotted where rock pops will go, than used a plane/planet with a colour adjust and smooth maximum clamp to make those small tight spots larger and smoother, than smooth maximum for a smooth transition to snow. Some voronoi creases in this example but changing seeds you may end up without them. Or you could feed the displacement shader to a height field and use the smooth filter like you do with fake stones.

You could just call the mounds without a rock being smaller rocks encompassed in snow.
Title: Re: Daydreaming on shadow catcher
Post by: Kadri on July 19, 2020, 11:45:54 PM
Does have anyone tried the classic erosion plugin (maybe the procedural could work too)?
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 20, 2020, 01:21:38 AM
Quote from: Kadri on July 19, 2020, 11:45:54 PMDoes have anyone tried the classic erosion plugin (maybe the procedural could work too)?

I was going to but the smooth on heightmap will work for all. However, I think with some smooth clamping of different layers and using thermal you could actually create a aged buildup where some had melted and more built up.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 20, 2020, 03:14:57 AM
Quote from: Kadri on July 19, 2020, 11:45:54 PMDoes have anyone tried the classic erosion plugin (maybe the procedural could work too)?
While i like your solution, please allow me to ask you to elaborate on how you used the null shader. Current TG documentation on it is really poor and i cannot guess how did you make it route to the planet for rendering.
Title: Re: Daydreaming on shadow catcher
Post by: uuderzo on July 20, 2020, 03:38:35 AM
Quote from: WAS on July 19, 2020, 02:39:43 PMOh that's a great idea. Didn't even think of that.

And yeah, a rock population would be difficult. I think the microexporter can handle rocks on terrain with proper settings if I remember from tests. That could be used in another program to smooth up and give than imported as a plane and offsetted.

Also I uploaded my projects: https://planetside.co.uk/forums/index.php/topic,28102.0.html
Sorry I messed up the threads and answered in the other one  ::)
Title: Re: Daydreaming on shadow catcher
Post by: Dune on July 20, 2020, 07:44:00 AM
I think I got something for you guys. Will upload later...
Title: Re: Daydreaming on shadow catcher
Post by: WAS on July 20, 2020, 12:52:42 PM
Quote from: uuderzo on July 20, 2020, 03:14:57 AM
Quote from: Kadri on July 19, 2020, 11:45:54 PMDoes have anyone tried the classic erosion plugin (maybe the procedural could work too)?
While i like your solution, please allow me to ask you to elaborate on how you used the null shader. Current TG documentation on it is really poor and i cannot guess how did you make it route to the planet for rendering.

The null shader is just a null. So you could use it to pipe another shader further down the tree, so it's easier to connect to other things when you node network is too big to handle when zoomed out (grabbing and inputting connections).

You can also store shaders within a null container, and pipe them out of it, using it as a nifty shader container to organize your node network.
Title: Re: Daydreaming on shadow catcher
Post by: Kadri on July 20, 2020, 03:34:41 PM
Quote from: uuderzo on July 20, 2020, 03:14:57 AM
Quote from: Kadri on July 19, 2020, 11:45:54 PMDoes have anyone tried the classic erosion plugin (maybe the procedural could work too)?
While i like your solution, please allow me to ask you to elaborate on how you used the null shader. Current TG documentation on it is really poor and i cannot guess how did you make it route to the planet for rendering.
Not sure about which part you ask. I used a plane for easier-faster testing the procedural erosion shader.
But tested the classic erosion instead.
If you mean from an input kind of approach you just hower your mouse over the input where you want it to (here over the input of the default shader in the plane object. Planet surface rendering OFF) and choose "Assign shader" (if you already have the null shader) with mouse right click. Does this help?
Title: Re: Daydreaming on shadow catcher
Post by: Dune on July 21, 2020, 01:19:50 AM
See here for a basic startup file; Snow/sand pile up. (https://planetside.co.uk/forums/index.php/topic,28107.msg279647.html#msg279647)