Board index FlightGear Development Effects and shaders

Improvemts to the water shader?

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

Improvemts to the water shader?

Postby D-ECHO » Tue Jan 05, 2016 9:03 pm

Hi all,
would it be possible to add some kind of "mirror" to the water shader to get images comparable to e.g. this:
Image?
Regards
D-ECHO
User avatar
D-ECHO
 
Posts: 2080
Joined: Sat May 09, 2015 12:31 pm

Re: Improvemts to the water shader?

Postby legoboyvdlp » Tue Jan 05, 2016 9:08 pm

It already is very good; it reflects the sun beautifully. However, is it worth the performance hit?
User avatar
legoboyvdlp
 
Posts: 7675
Joined: Sat Jul 26, 2014 1:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP

Re: Improvemts to the water shader?

Postby MIG29pilot » Tue Jan 05, 2016 9:22 pm

Well of course you could turn it off if it impacted your performance.
User avatar
MIG29pilot
 
Posts: 1473
Joined: Tue May 19, 2015 4:03 pm
Location: 6 feet under Snow
Callsign: MIG29pilot
Version: 2020.1.3
OS: Windows 10

Re: Improvemts to the water shader?

Postby PINTO » Tue Jan 05, 2016 9:43 pm

legoboyvdlp wrote in Tue Jan 05, 2016 9:08 pm:It already is very good; it reflects the sun beautifully. However, is it worth the performance hit?


To some people it definitely would be.
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 961
Joined: Wed Oct 21, 2015 6:28 pm
Callsign: pinto
Version: 2016.3.0
OS: Win10

Re: Improvemts to the water shader?

Postby wkitty42 » Wed Jan 06, 2016 12:03 am

this has been discussed before (within the last year) and the performance hit is rather huge... it is similar to the difference between rendering (like we do) and ray-tracing (which can't really be done in real time without hugely powerful processing systems)...
"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: 6494
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: Improvemts to the water shader?

Postby vnts » Wed Jan 06, 2016 10:30 am

D-ECHO wrote in Tue Jan 05, 2016 9:03 pm:would it be possible to add some kind of "mirror"


This involves rendering the scene twice, as far as I can see. Once to get the 'mirror' surface image of the scene onto a texture and once for the scene (or it would need some form of screen-space ray tracing (not sure) which would also probably be really expensive, not to mention lots of work).

The problem is the terrain has to be shown on the water surface, as well as clouds. If it was an empty sky, perhaps a very low res light map could be computed once in a while. All objects are coloured a bit by the surrounding scene (skydome+terrain), and the result is a shading that sort of shows the object belong to the scene - sort of like the way cockpit light maps make interior shading more realistic.

I see this type of thing seems to be a popular feature request (there was another thread asking about aircraft rendering comparing to raytraced blender renders). Maybe there is some sort of hack that can create a super low resolution light map which takes skydome color, cloud type/coverage %, and some approximation of average terrain colour based on surrounding landclasses to shade objects at close range that people pay attention to, like aircraft. Some of this could be precomputed and interpolated for a day night cycle at a specific latitude/season, like the skydome - and maybe the results could be somehow blended with precomputed results for just the cloud coverage to reduce computations per frame. This wouldn't really represent the true scene, but it might fool the eye for surfaces of objects that weren't too mirror like (you'd just crudely get sky facing surfaces to be shaded differently from ground facing surfaces, and in-between surfaces, taking into account time of day/cloud coverage). That's possibly close to the best one can hope for (???) in real time, and would probably be a very large amount of work (there's also the consideration whether it's worth the gain).

Kind regards,
vnts
vnts
 
Posts: 171
Joined: Thu Apr 02, 2015 12:29 am

Re: Improvemts to the water shader?

Postby Thorsten » Wed Jan 06, 2016 11:12 am

Maybe there is some sort of hack that can create a super low resolution light map which takes skydome color, cloud type/coverage %, and some approximation of average terrain colour based on surrounding landclasses to shade objects at close range that people pay attention to, like aircraft.


The ALS water shader actually takes reflected sky brightness, cloud cover and sun position into account, in addition to the Fresnel equation for the reflection strength.

Mirror-like reflections are rare in nature, they require a very low viewing angle because otherwise the Fresnel term is small (which is why you'd almost never see them from a cockpit unless you're flying criminally low over water) and they're very expensive to compute.

Makes for a clear 'no'.
Thorsten
 
Posts: 11642
Joined: Mon Nov 02, 2009 8:33 am

Re: Improvemts to the water shader?

Postby MIG29pilot » Wed Jan 06, 2016 2:49 pm

The clearness of reflections, you might say, is inversely proportional to the angle of view and directly proportional to the stillness of the water. So if you happen to be in a seaplane on a clear day, you might see something like this in rl
Image
By the way Thorsten instead of ray tracing and all that for the reflections of single aircraft couldn't some sort of reflect-map be used, like a modified 2d als shadow?
User avatar
MIG29pilot
 
Posts: 1473
Joined: Tue May 19, 2015 4:03 pm
Location: 6 feet under Snow
Callsign: MIG29pilot
Version: 2020.1.3
OS: Windows 10

Re: Improvemts to the water shader?

Postby Thorsten » Wed Jan 06, 2016 5:43 pm

For the aircraft probably yes. For the rest of the scene no.
Thorsten
 
Posts: 11642
Joined: Mon Nov 02, 2009 8:33 am

Re: Improvemts to the water shader?

Postby MIG29pilot » Wed Jan 06, 2016 8:03 pm

(I) Ought to try it.
User avatar
MIG29pilot
 
Posts: 1473
Joined: Tue May 19, 2015 4:03 pm
Location: 6 feet under Snow
Callsign: MIG29pilot
Version: 2020.1.3
OS: Windows 10

Re: Improvemts to the water shader?

Postby MIG29pilot » Wed Jan 06, 2016 8:08 pm

Is there any way for the sim to know what type of terrain you are over (water, desert, et.
) and if you created a new version of shadow.png and 3dshadow.a with colors would that make a "coloured shadow?"
User avatar
MIG29pilot
 
Posts: 1473
Joined: Tue May 19, 2015 4:03 pm
Location: 6 feet under Snow
Callsign: MIG29pilot
Version: 2020.1.3
OS: Windows 10

Re: Improvemts to the water shader?

Postby gsagostinho » Fri Jan 08, 2016 2:54 am

Since we are talking about the water shader, I would like to share an opinion. I love the water effects in FlightGear, but I do find that for a certain time window the water tend to be extremely brown when we have good skies during sunset (e.g. when using Core of High Pressure or High Pressure scenarios). Even if the air pollution is set to none, the result looks strange to me:

Image

With more air pollution, the result gets really orange/brown. Does the water must be coloured uniformly, regardless of the sun's position? If not, then perhaps making the water bluer the further it is from the sun could be a solution. Also, pictures of sunsets are notoriously problematic due to the way the cameras perceive colour and light, but if we look at most if not all of these pictures in this google link below, it seems to me the ocean is always less orange than the sky at the horizon where both touch, which doesn't seem to be the case in the screenshot I posted above:

https://www.google.de/search?tbm=isch&q ... Gxa-vel-AH
User avatar
gsagostinho
 
Posts: 1803
Joined: Thu Jan 15, 2015 6:27 pm
Location: London, UK

Re: Improvemts to the water shader?

Postby Thorsten » Fri Jan 08, 2016 6:30 am

Is there any way for the sim to know what type of terrain you are over (water, desert, et.
) and if you created a new version of shadow.png and 3dshadow.a with colors would that make a "coloured shadow?"


Not for the renderer - but in Nasal (or C++) you can query the terrain at any given location (in Nasal with geodinfo()).

Note however that the geometry for reflections and for casting shadows is very different - in particular a shadow does not change position when you move eye position, a reflection does. Also, my suspicion is that a shadow computed this way will appear way too sharp.

I love the water effects in FlightGear, but I do find that for a certain time window the water tend to be extremely brown when we have good skies during sunset


I think I've struggled by how half a dozen sessions with the water colors in low light. The problem really is to come up with something that works for every case. If you try to fix this lighting situation, you often run into problems with another,

I'm not happy with it as it is, but I know a hundred schemes for illumination which make me even less happy. It's a surprisingly tough problem because so many variables enter (cloud cover, pollution, amount of haze, view angle, base water color, water depth map, water roughness,...) and you need something that blends with the rest of the terrain, fades out the right way and works for all use cases.

I'll probably keep struggling with it, but I can't offer you a quick solution. I don't think there is one.
Thorsten
 
Posts: 11642
Joined: Mon Nov 02, 2009 8:33 am

Re: Improvemts to the water shader?

Postby punkepanda » Fri Jan 08, 2016 2:59 pm

The brownish colour I was complaining about 3 years ago also. ..
I think the problem is that the water colour itself is changing rather than the colour of the reflection.
So without a reflection layer to the water there is probably no way to go about this in a good way.
The brownish colour should mostly appear when seen from a low angle reflecting the colours in the sky and clouds. When seen straight down in the afternoon the water should be almost blackish dark-blueish!

So some kind of a transparent reflection hack is needed to make this appear realistic from different angles. The more straight-down the angle is the more transparent the reflection layer should be when there is no direct sunlight to the surface.
Last edited by punkepanda on Wed Mar 16, 2016 3:26 am, edited 1 time in total.
punkepanda
 
Posts: 237
Joined: Mon Nov 04, 2013 9:11 pm
Callsign: LostFlight
Version: 2.12
OS: Arch Linux

Re: Improvemts to the water shader?

Postby gsagostinho » Fri Jan 08, 2016 4:09 pm

Thorsten wrote in Fri Jan 08, 2016 6:30 am:I think I've struggled by how half a dozen sessions with the water colors in low light. The problem really is to come up with something that works for every case. If you try to fix this lighting situation, you often run into problems with another,

I'm not happy with it as it is, but I know a hundred schemes for illumination which make me even less happy. It's a surprisingly tough problem because so many variables enter [...]


I totally understand that, Thorsten. Anyway, I think the water colour looks fine on most situations, it's really a short window and only with very open skies and good visibility that I see this brown/orange colours, and I think the problem is more how they blend with the terrain rather than the colour themselves (if you are above the ocean, this is much less noticeable than with my screenshot above, for instance).

Cheers!
Gilberto
User avatar
gsagostinho
 
Posts: 1803
Joined: Thu Jan 15, 2015 6:27 pm
Location: London, UK

Next

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 2 guests