Maybe this will be something for the file sharing section, but it's not finished yet, I guess.
For my last (tropical) images I tried to create a procedural shore foam preset. I carried on with some stuff that was mentioned here:
https://planetside.co.uk/forums/index.php/topic,28028.msg278689.html#msg278689
So far I created three "rows" of foam in real world scale (the cube in the image has the average size of a human). As you can see the setup uses displacement to scalar nodes and some following color adjust shaders, which use the water object's level to create different distances and falloffs to create the foam lines. Additionally I used the "ocean foam texture" setup I shared once in the file sharing section to create the foam patterns. I managed to put all the foam texture nodes into a grouped shader to make it a bit cleaner.
It works with procedural terrains and with loaded ones. So far so good. This setup works nicely with a water level of 1. Of course I could change all parameters of the color adjust shaders by hand, if my water object's level would be different, but that would be rather inconvenient. So, I need some help!
Is there any function or whatever, that I could put somewhere (probably after the displacement to scalar nodes?) to just enter the water level, and that would change the color adjust shaders' values automatically? I guess, they would only have to be shifted up or down, since the relations between the values should stay the same.
So, I hope, someone has a good idea!!
This looks rather convincing, and the face it isn't really sinus waves means it should be faster. And for distant stuff wouldn't even matter.
Quote from: Hannes on March 09, 2022, 08:38:24 AMIs there any function or whatever, that I could put somewhere (probably after the displacement to scalar nodes?) to just enter the water level
Just add an add scalar with the water depth after the displ to scalar indeed. Either minus of plus.
EDIT: it seems you have to deduct the new water level from the displ to scalar. And it's probably not needed to diverse from the compute terrain, which is faster.
I like the foam pattern trailing behind the edge, very cool.
So, I put Add scalars behind each Displacement to scalar function. Do I have to use a Constant scalar to input the value? If you say I have to deduct the new water level from the Displ to scalar, what does it mean, if I have a water level of 100 for example?
Sorry, but I'm an absolute node idiot... :(
Also, since the disp to scalar is dispalcement in range with height, you probably can use a smooth step to end it at your water level (or start it at water level, not sure if the scalar logic is reversed as Ulco mentioned).
I really like this and I'll play around with it in a bit... after I try to remake my old sombrero galaxy... :P
Looking forward to your input, guys! When it comes to nodes I'm really stuck...
Exactly, so 2 of them. And use constant scalar of -100 for level 100, indeed. You can probably also add a vector after the terrain, and add a constant vector or so, with Y as minus water level.
In the meantime I put a Smooth step scalar with a constant scalar of 100 (new water level) plugged into the step end behind the Displacement to scalar node, and connected everything. It all shows up, but the foam stuff seems to be a hundred times larger except the foam pattern of course. So it seems, the values aren't just shifted up, but somehow multiplied by 100. Without knowing what I was doing, I put a Divide scalar with a value of 100 behind the Smooth step scalar, and all the foam disappeared... :( :( :(
Quote from: Dune on March 09, 2022, 12:39:08 PMExactly, so 2 of them. And use constant scalar of -100 for level 100, indeed. You can probably also add a vector after the terrain, and add a constant vector or so, with Y as minus water level.
I tried it with a divide scalar with a value of 100. Did the same like the Add scalar with -100. But it didn't work out.
Do you mean an Add vector (or Divide)?
Add vector with a constant vector Y -100 didn't work either. And the (100 times larger) coastline is pink.
these kind of stuff should be in the software by default.
This looks extremely promising
@Hannes !
I'm even more lost when it comes to nodes so I'm no help but I do hope you get the help you need. Really looking forward to the final solution.
I'll have another look and save what I did this time ;) But divide won't work and smooth step neither, because then you'd need another step that's very close to the 100. It just softens the lot.
It's actually a lot simpler if you just add a surface shader and a transform shader like this (I just figured it out). The transform stretches the terrain Y so the foam is right around the coastline, and not diverging, and the surface shader can be used to compensate (minus offset) for the water level. In my example I set it at 50m (so -50 in surface shader).
That is why I usually start my terrain with a PF stretched in Y, to be sure foam follows coastline.
First of all, sorry for the delay. I honestly forgot. It's been a rough day. Second, sorry for the node OCD.
Anyways, here is my take at the problem. This uses a sphere for global water coverage, and allows for two general inputs. Water level, and Shore Precision Multiplier.
This should work well for positive water level, but maybe for negative? I forgot to check and am getting tired.
As a note though. In situations like this where your adjustments all rely on 0 level in texture space, the surface layer offset is super handy. Apply one before your compute terrain, and just offset the terrain up or down to desired "water level" without adjusting the lake level. You also don't need to stretch the scalar which may make masking slower.
Cool, guys!!! Thanks a lot! :) :) :) I'll have a look asap.
Guys, I took a look at both of your scenes.
Jordan, I really like the tidied up stuff. No node mess until you open up the sphere's network. Cool.
But I found that there is a Multiply scalar that isn't plugged into anything. (See attached image). So actually the Shore precision multiplyer only goes into this "dead" Multiply scalar, and so doesn't seem to have any function.
I tried to connect it to the Complement Water Level node below (without knowing why! It's just the closest node...), but then all the foam disappeared.
However, I tried to use 100 in the Water level Constant scalar, and the foam lines were about 100 times larger except the foam pattern (like in my previous attempts).
Ulco, your file almost worked. To make things simpler, I lowered the lake object to 0 instead of 1, and adjusted all the color adjust shaders by hand. I used my previous version for that and then added your Stretch Y-Transform shader and the Minus offset by water level surface layer.
As expected things stayed the same when I only connected the Minus offset... surface layer with the Connection-null shader (See "No stretch" screenshot).
But when I put your Stretch Y shader in between, all "foam rows" seem to be pushed away from the land (see "Stretch" screenshot).
I then used a Displacement offset of -0.8 instead of 0, and the foam rows were roughly where they should be. But that's of course not the desired effect.
Apart from that I realised, that the more I moved the water level away from 0, the more unexpected and incorrect the result was. At a level of 300 the foam didn't match the shoreline anymore.
I didn't expect, that this is so tough!!!
Anyway, thanks a lot for your tips!! Maybe you'll have some more? ;)
I don't know why TG has such a hard time with internal node networks now. I can't even load the terracing function, and other stuff without fixing them every time. Something is messed up with internal node networks.
The precision modulator may help with some of the issues when your water level is high.
The issue is we are basing on a scalar, so it's pretty dependant on a slice of that data where we applied all the adjustments. When you Y stretch, stuff you want to interpret as depth and not effected by waves, will now be in range of all the masking, do you end up with a huge area effected.
I'd really look into just offsetting your whole world. It's really meant for issues like this where your functions rely on alt 0.
Quote from: WAS on March 10, 2022, 11:40:20 AMI'd really look into just offsetting your whole world. It's really meant for issues like this where your functions rely on alt 0.
Thanks Jordan, I'll do that for sure!
By the way, I continued playing with Ulco's file and found, that it works pretty good, when you're close to the origin (0,0,0). The more you go away from that, the more unpredictable the results are.
Also, Shore Precision is meant to be 1, it was an add scalar, so 0 was default, but it's not multiply, so 1 is default to keep base settings.
Then you can use positive integers to clamp in the shore precision, or negative to get it out further.
Quote from: Hannes on March 10, 2022, 11:53:59 AMQuote from: WAS on March 10, 2022, 11:40:20 AMI'd really look into just offsetting your whole world. It's really meant for issues like this where your functions rely on alt 0.
Thanks Jordan, I'll do that for sure!
By the way, I continued playing with Ulco's file and found, that it works pretty good, when you're close to the origin (0,0,0). The more you go away from that, the more unpredictable the results are.
Probably because you're using the Compute Terrain, so the data is normalized along the spheroid (pointing along normal)
Here is a water level of 100, far from 0,0,0 on my function, with precision of 1. Seems to be working for me.
What I should do is add two precisions, negative, and positive.
Quote from: WAS on March 10, 2022, 11:54:29 AMProbably because you're using the Compute Terrain, so the data is normalized along the spheroid (pointing along normal)
No, I didn't use the compute terrain at this moment.
However your idea of offsetting the whole world works great!!! Fantastic idea. I'd never thought of that.
Gonna test your new file right away! Thanks!
Yeah offsetting is probably the most hassle-free.
Here is a version 2. Basically with this one, you have control over the initial "slice" via precision start, and end. So it doesn't reall matter what elevation you are at, you can use the precision settings to dial in the area.
Quote from: WAS on March 10, 2022, 12:03:20 PMHere is a water level of 100, far from 0,0,0 on my function, with precision of 1. Seems to be working for me.
Yes, it works indeed. But since you're using a sphere (that's at least what I think), everything gets larger, the higher the level is. Like the image on a half inflated balloon. The more you inflate it, the larger the image gets. So at level 0 I have a foam area of a few meters, and at a level of 300 the area is a few hundred meters wide.
It shouldn't be getting larger. It's all working off the same terrain and masking. I think that just has to do with the terrain shape and depth. More slope, more your masks will be pushed away from each other (think contour shader).
I'm not sure you can defeat that without turning all the colour adjusts into smooth step scalars and using constant scalars that math each other to scale according to the water level.Thinking about how to do that makes my brain freeze so I'm not sure I have the solution to that aspect.
On a totally different note, you can also apply a Smoothing shader after "Terrain Normal Output" or after your disp to scalars, and you can use this to round some of your shapes, to look like waves rolling in. That way when there is hard turning edges in the terrain, they'll be smoother and the wave will have smooth arcs caressing the shore shapes, instead of angled exactly like them.
Quote from: WAS on March 10, 2022, 12:39:18 PMOn a totally different note, you can also apply a Smoothing shader after "Terrain Normal Output" or after your disp to scalars, and you can use this to round some of your shapes, to look like waves rolling in. That way when there is hard turning edges in the terrain, they'll be smoother and the wave will have smooth arcs caressing the shore shapes, instead of angled exactly like them.
Interesting thought. Tested it.
Awesome. You could even play around with it too, like a colour adjusted version of the terrain inputed as the scale modulator. See what sort of effects you can get. Hugging more here, less there, etc. Could even smooth that colour adjust so the effect is more gradual.
I am still not done with this idea. My thought process now is we could get all these waves via the modulo function, which gives a half sinus effect. Trying to see if I can smooth the hard edges. Than really all we need to do is divide terrain scalar + pf warp duplicates, and you got different scale wakes to easily clamp in solid area, and mask in foam.
Sounds amazing! I understood maybe ten percent of the things you mentioned, but I guess, it's gonna be great! Keep going!! ;D
Just think instead of normal sinus waves like this
Screenshot_120.jpg
We have one that looks like this
Screenshot_119.jpg
That way you have the defined shapes of the wakes procedurally based on the terrain, no custom clamping needed, you just vary the terrain intensity with a multiply for every variation of waves, and maybe one clmap just for the wake line.
Mission accomplished: https://planetside.co.uk/forums/index.php/topic,29914.new.html#new
The stretching is indeed a crude methode, that's why I always stretch the terrain Y to begin with.
The modulo always got me a hard/clamped output, so I don't know how that would work properly. The problem with the second curve is that it also needs to point at the coast. Must be possible. Jon has done a lot in that area, but I was never able to replicate.
Quote from: WAS on March 10, 2022, 06:16:07 PMThat way you have the defined shapes of the wakes procedurally based on the terrain, no custom clamping needed, you just vary the terrain intensity with a multiply for every variation of waves, and maybe one clmap just for the wake line.
I see. great!!!
Quote from: Dune on March 11, 2022, 01:38:16 AMThe stretching is indeed a crude methode, that's why I always stretch the terrain Y to begin with.
The modulo always got me a hard/clamped output, so I don't know how that would work properly. The problem with the second curve is that it also needs to point at the coast. Must be possible. Jon has done a lot in that area, but I was never able to replicate.
Check the link I just posted. It's a sinus function with functionality like Modulo, you can lean the edge to either side of the wave with a smooth edge.
I'll check it out, thanks.
Quote from: Hannes on March 09, 2022, 08:38:24 AMMaybe this will be something for the file sharing section, but it's not finished yet, I guess.
For my last (tropical) images I tried to create a procedural shore foam preset. I carried on with some stuff that was mentioned here:
https://planetside.co.uk/forums/index.php/topic,28028.msg278689.html#msg278689
So far I created three "rows" of foam in real world scale (the cube in the image has the average size of a human). As you can see the setup uses displacement to scalar nodes and some following color adjust shaders, which use the water object's level to create different distances and falloffs to create the foam lines. Additionally I used the "ocean foam texture" setup I shared once in the file sharing section to create the foam patterns. I managed to put all the foam texture nodes into a grouped shader to make it a bit cleaner.
It works with procedural terrains and with loaded ones. So far so good. This setup works nicely with a water level of 1. Of course I could change all parameters of the color adjust shaders by hand, if my water object's level would be different, but that would be rather inconvenient. So, I need some help!
Is there any function or whatever, that I could put somewhere (probably after the displacement to scalar nodes?) to just enter the water level, and that would change the color adjust shaders' values automatically? I guess, they would only have to be shifted up or down, since the relations between the values should stay the same.
So, I hope, someone has a good idea!!
Thanks for sharing this Hannes, I was admiring the waves on your tropical picture and wondering how you did them!
Quote from: WAS on March 10, 2022, 12:14:09 PMYeah offsetting is probably the most hassle-free.
Here is a version 2. Basically with this one, you have control over the initial "slice" via precision start, and end. So it doesn't reall matter what elevation you are at, you can use the precision settings to dial in the area.
Hello WAS, I downloaded the tgd and tried to use it in my personal project, I loaded in the two shaders from the water node into my project. However the shoreline foams don't appear. Only the blue ocean is visible.
I am using a heightfield I generated from world machine, and imported as a ter file in terragen, with a scale of 7996m on both x and y axis. I set the waterlevel to 950
I have worked with terragen nodes on few occasions. But I feel its the start and end multipliers that need tweaking. Sadly, my tweaks don't seem to work. Please assist me in finding the best settings for my scene. Thanks
I can share the tdg file if needed.