Board index FlightGear Development Effects and shaders

Surge of waves shader?

An exciting "new" option in FlightGear, that includes reflections, lightmaps, the particle system etc.. A lot is yet to be discovered/implemented!

Surge of waves shader?

Postby flycanarias » Fri Nov 04, 2016 4:13 pm

Hey folks,
is there any shader which is capable to display the surge of waves close to coastlines? Basically the white foam created by surging waves?
If not, are there some of you talented people who could do this?

P.S.: Should be usable with ALS, because of the ocean depth Color change... Without this, it wouldn't make that much sense...

Thanks in advance...
Canary Islands Custom Scenery
Improvement of the AI Traffic for the Canary Islands Region
RoutePlans for the Eastern Atlantic (Azores, Madeira, Cap Verde, Canaries)
About to open a Binter Canarias VA
flycanarias
 
Posts: 285
Joined: Fri Jun 10, 2016 3:29 pm
Location: EDDF, EDDC, GCFV

Re: Surge of waves shader?

Postby Thorsten » Fri Nov 04, 2016 5:46 pm

The problem is recognizing where to do it. In principle there's some heuristics doing that, but it's not 100% effective (actually, probably more than 40% in reality).
Thorsten
 
Posts: 9141
Joined: Mon Nov 02, 2009 8:33 am

Re: Surge of waves shader?

Postby flycanarias » Fri Nov 04, 2016 6:24 pm

Where is the problem with it? Which parameters does it follow? How is this done on other sims? How is it done in other sims or add ons?
Canary Islands Custom Scenery
Improvement of the AI Traffic for the Canary Islands Region
RoutePlans for the Eastern Atlantic (Azores, Madeira, Cap Verde, Canaries)
About to open a Binter Canarias VA
flycanarias
 
Posts: 285
Joined: Fri Jun 10, 2016 3:29 pm
Location: EDDF, EDDC, GCFV

Re: Surge of waves shader?

Postby wkitty42 » Fri Nov 04, 2016 9:57 pm

the first problem is the coast lines are not accurate... take off at KSFO and fly south down the coast a couple of hundred feet up... there's all kinds of land objects in the water... they're place in the proper place but the coast line is too low bringing the water too far in... power pylons, smoke stacks, roads, buildings, etc... fly all the way to KLAX and stick to the coast line... you'll see it easily...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 3755
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: Surge of waves shader?

Postby Thorsten » Sat Nov 05, 2016 7:05 am

Where is the problem with it? Which parameters does it follow? How is this done on other sims?


Lack of meta-data in the scenery - if you pass the shader a parameter 'draw 70% surf for this pixel' this is a piece of cake to draw.

What we actually know is landclass - typically Ocean. We don't know how far we are from the coast, we don't know which direction the coast is, we just know Ocean.

With the depth map, we're getting the info that we're likely close to the coast, so we can draw shallows and enhance surf. However, it has a resolution of a square kilometer or two, so it's not very precise.

For steep coasts, I discovered by accident that the normal 'bleeds' into the surrounding flat terrain, allowing to flag parts of the coast 'close' to steep shores.

The shader utilizes a combination of both criteria to determine surf, but as I said, it's not stunningly accurate.

It's not a graphics problem, it's getting landclass transition information that the current terrain does not provide. In nextgen terrain when we encode landclass as raster image, we can retrieve the information simply from the meta-texture and the problem is solved.

I don't know in detail how other sims do it, but they need to pass meta-data in some or the other form.
Thorsten
 
Posts: 9141
Joined: Mon Nov 02, 2009 8:33 am

Re: Surge of waves shader?

Postby flycanarias » Sat Nov 05, 2016 10:52 am

All right, so the desired effect will work, when you improve the terrain? Sounds good, but also like a lot of work. Do you already have an approximate release date in mind??
Canary Islands Custom Scenery
Improvement of the AI Traffic for the Canary Islands Region
RoutePlans for the Eastern Atlantic (Azores, Madeira, Cap Verde, Canaries)
About to open a Binter Canarias VA
flycanarias
 
Posts: 285
Joined: Fri Jun 10, 2016 3:29 pm
Location: EDDF, EDDC, GCFV

Re: Surge of waves shader?

Postby Johan G » Sat Nov 05, 2016 11:47 am

It is unfortunately not likely to happen soon.

What Thorsten is trying to explain is that the main issue is that a shader only will be aware of the landclass a pixel to be rendered belong to. It can not tell the landclass of the neighboring pixels. In essence it can not really tell whether it is next to the shoreline or two miles out.

The next question is why there for example is no additional landclass(es) to help such a shader know that it should do water swells. The reason is mainly that the needed data is not redily available (though it would be appreciated if someone found a good source). It would have to be added by an automated process in order to be at least somewhat consistent and not only available in some specific areas. Any data used to build those landclasses from would have compatible with FlightGear's GNU GPLv2 licence and for example allow commercial reuse.

If there would be a focused effort on adding additional landclasses, in essence putting any other projects aside it would probably still take current developers weeks or more probably moths to implement such a feature.

If you really, and I really mean really, want the feature, I recommend the usual path to add a brand new feature, reading in, experimemt and slowly add it yourself. It may sound like an attempt to put you off, but it really is not. Scratching this itch might take some years, but it may very well be worth it. Other people before have gone from nothing to adding much appreciated funtionality to FlightGear.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5255
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Surge of waves shader?

Postby Thorsten » Sat Nov 05, 2016 2:50 pm

Do you already have an approximate release date in mind??


No. This is at proof of concept stage.
Thorsten
 
Posts: 9141
Joined: Mon Nov 02, 2009 8:33 am

Re: Surge of waves shader?

Postby flycanarias » Sat Nov 05, 2016 3:33 pm

Well, I had the same thought of creating different landclasses for coastal regions... But that would, apart from the massive time and work effort, lead to the problem that a change by weather would be difficult, right?

After my unsatisfying question, how other sims do it, I asked myself, how nature is doing it!
After some research on the net, I know that the time when a wave breaks is dependent on its heigh and the depth of the sea below it...
In general, when the wave is higher than the sea below, it breaks, and shows the foam we'd like to implement.
But as waves are just textures and shaders right now, we can not get any waves' heigh.
Some further research brought me to the point that, physically, the waves get higher due to the wind! The stronger the wind is, the higher are the waves.
And that leads me to the fact, that: the higher the waves are, the farer they break from the coast!
Now my conclusion: The wind that puts our airplane into turbulence, is the same "thing" that indicates where a wave breaks. And the ocean depths we need to give the water these beautiful colours, the ones we take from OceanDepth, are, just like Johan told us, those responsible for wave breaking on the other hand.
What does all this mean?
We don't need landclasses, but we do the following:
We connect the weather (wind) with the ocean depth, and set this as a piece of code.
E.g. At this specific strength of wind, "xx" average waves are "xy" high. (This data is freely available from different research studies, so this won't be a huge problem...) Now we tell the program to compare the "fictional" wave heigh to the ocean below it. Kind of like: "Wave heigh < Ocean Depth = no shader" or "Wave heigh > Ocean depth = display the white foam shader on the sea"
So we wouldn't make it dependant on data the program can't deal with, but with data we already have.
Now I don't really know how the OceanDepth Database "colours" the water, if it implements the depth as a parameter, or how it works.
But if we don't have the parameter, we replace the condition "depth" by the colour...
Can this maybe work?
Canary Islands Custom Scenery
Improvement of the AI Traffic for the Canary Islands Region
RoutePlans for the Eastern Atlantic (Azores, Madeira, Cap Verde, Canaries)
About to open a Binter Canarias VA
flycanarias
 
Posts: 285
Joined: Fri Jun 10, 2016 3:29 pm
Location: EDDF, EDDC, GCFV

Re: Surge of waves shader?

Postby Thorsten » Sat Nov 05, 2016 6:20 pm

"Wave heigh < Ocean Depth = no shader" or "Wave heigh > Ocean depth = display the white foam shader on the sea"


As I tried to indicate, a bit more sophisticated than this is how it works right now (the shader knows the wave height...)
Thorsten
 
Posts: 9141
Joined: Mon Nov 02, 2009 8:33 am

Re: Surge of waves shader?

Postby flycanarias » Sat Nov 05, 2016 7:07 pm

So sorry if this sounds a little silly right now, but I still don't get the reason why it's not working everywhere? If that what we both described is how it works, then why it needs the coastline?? If the shader follows the rule we described, it doesn't need the coast to "know if there is a coastline somewhere"?? And why landclasses? Doesn't the rule sets up the shader on the ocean?

@Thorsten: If this is too much to explain here on the thread, it would be very nice if you could explain it to me via direct message.
Canary Islands Custom Scenery
Improvement of the AI Traffic for the Canary Islands Region
RoutePlans for the Eastern Atlantic (Azores, Madeira, Cap Verde, Canaries)
About to open a Binter Canarias VA
flycanarias
 
Posts: 285
Joined: Fri Jun 10, 2016 3:29 pm
Location: EDDF, EDDC, GCFV

Re: Surge of waves shader?

Postby Thorsten » Sat Nov 05, 2016 7:13 pm

If that what we both described is how it works, then why it needs the coastline?


I don't think I said it needs the coastline.

And why landclasses?Doesn't the rule sets up the shader on the ocean?


Well, that's what a landclass does.

but I still don't get the reason why it's not working everywhere?


Resolution of the depth map. It doesn't give you the depth for the pixel you're looking at, it gives you the average depth of the 2x2 km square around it. So whether this answer is good depends on how well the actual depth is represented by the coarse average we have - sometimes it works, often it does not.

You could theoretically solve the problem by using a better depth map - if you find one in public domain and find a way not to blow GPU memory using it.
Thorsten
 
Posts: 9141
Joined: Mon Nov 02, 2009 8:33 am


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 2 guests