Board index FlightGear Development Effects and shaders

Screen-Space Reflections

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

Screen-Space Reflections

Postby icecode » Fri Jul 27, 2018 1:29 am

After hitting an important milestone for the Compositor, I couldn't resist to try it out and develop some shaders for it. SSR was the chosen one. :)

The reflections aren't "physically accurate", they are just mixed with the scene at a constant rate. Also the water shader already reflects the sky, so together with SSR it reflects it twice, that's why it looks kind of bright. This is just a proof a concept and has lots of room to improve, but it shows what can be done:

Image

Image
icecode
 
Posts: 709
Joined: Thu Aug 12, 2010 1:17 pm
Location: Spain
Version: next
OS: Fedora

Re: Screen-Space Reflections

Postby wlbragg » Fri Jul 27, 2018 6:18 am

Pretty cool, are those sudo cloud reflections as well?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Screen-Space Reflections

Postby Thorsten » Fri Jul 27, 2018 6:30 am

Nice (though I maintain that you'd see such reflections only in rare occasions when the water is really calm and then usually in lakes...)!

What's the performance footprint - do you render it (well, the fragment part probably) essentially twice, or is it cheaper than that?
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Screen-Space Reflections

Postby icecode » Fri Jul 27, 2018 8:06 am

Pretty cool, are those sudo cloud reflections as well?


Nice catch! Yes, they are. SSR can reflect anything in the scene, including the aircraft (I'll try to get a screenshot showing that later).

Nice (though I maintain that you'd see such reflections only in rare occasions when the water is really calm and then usually in lakes...)!


That's why SSR is the perfect use-case for water reflections. SSR stops reflecting things when they are out of the screen. In the case of water, things other than the water itself start going out the screen when the view angle is high, which matches real life behavior due to fresnel.

What's the performance footprint - do you render it (well, the fragment part probably) essentially twice, or is it cheaper than that?


SSR is basically raytracing, but with a very low iteration count and in a fullscreen quad to maintain interactive framerates. Performance is therefore only dependent on screen resolution, not scene complexity (a good thing since FG is usually CPU bound). In a good implementation (not mine :) ) you could run this pass alone in around 2.5ms in <5 year old hardware, which is much faster than say planar reflections, which require rendering the whole scene twice. Another advantage is that SSR works on basically anything without a performance impact, as long as you supply its normals and some color, so for example you can get real time reflections of the aircraft on a wet runway. I just showed water because it's the most "visible" use-case for SSR.
icecode
 
Posts: 709
Joined: Thu Aug 12, 2010 1:17 pm
Location: Spain
Version: next
OS: Fedora

Re: Screen-Space Reflections

Postby Thorsten » Fri Jul 27, 2018 8:35 am

That's why SSR is the perfect use-case for water reflections.


My nit-pick here has little to do with the implementation :D (which is a big step)

For the wave pattern you see, I believe the reflection would not be seen in the way depicted. But that's by and large a matter of just tuning parameters to the prevailing wave roughness - which you can't possibly have addressed yet at this stage.

(I guess my real point is that in many video games, water reflection are grossly over-exaggerated since they generate a 'this is so cool' effect by users - and I don't really want to do that in ALS).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Screen-Space Reflections

Postby Avionyx » Fri Jul 27, 2018 9:18 am

Looking great.
One thing I've been really looking forward to in FG is cloud reflections on water. It's something that's very visible in a lot of circumstances, especially when VFR under 10,000ft and it would add a huge amount of realism to the sim for me.

Brilliant work, please keep it up and keep us updated :)
Avionyx
 
Posts: 531
Joined: Mon Jan 11, 2010 4:07 pm
Location: EGMD
Callsign: G-AVYX
Version: 2020.4
OS: Manjaro

Re: Screen-Space Reflections

Postby icecode » Fri Jul 27, 2018 10:24 am

Yes, as I said it's not physically accurate. Roughness can be taken into account either via an uniform gaussian blur for things with constant roughness, or via cone tracing for things with different roughness per fragment (PBR).

SSR just provides the reflection color, how you mix it with the scene is completely your choice. You can make it as realistic/exagerated as you want.
icecode
 
Posts: 709
Joined: Thu Aug 12, 2010 1:17 pm
Location: Spain
Version: next
OS: Fedora

Re: Screen-Space Reflections

Postby vnts » Fri Jul 27, 2018 3:35 pm

Icecode GL wrote in Fri Jul 27, 2018 8:06 am:SSR can reflect anything in the scene, including the aircraft (I'll try to get a screenshot showing that later)..

SSR is basically raytracing, but with a very low iteration count and in a fullscreen quad to maintain interactive framerates. Performance is therefore only dependent on screen resolution, not scene complexity

..I just showed water because it's the most "visible" use-case for SSR.

Interesting. Screenspace effects remind of Mirages. Reflection below for deserts & above for polar mirages. Relatively rarely encountered too. Guess screenspace pass means heat shimmer becomes possible for aircraft & lava.

Not sure if reflected terrain disappearing(?) as view moves downwards can be avoided or is too noticeable - if smoothly blended out.

May(?) get away with blending lower resolution SSR. Major aspect of 'glassy water' landings & takeoffs is judging altitude due to lack of ripples (friction increase in smooth water falls under physics not visual).

Can just imagine this with SSR & smooth water.

Kind regards
vnts
 
Posts: 409
Joined: Thu Apr 02, 2015 1:29 am

Re: Screen-Space Reflections

Postby Thorsten » Sat Jul 28, 2018 7:30 am

Yes, as I said it's not physically accurate. Roughness can be taken into account either via an uniform gaussian blur for things with constant roughness, or via cone tracing for things with different roughness per fragment (PBR).


I believe it's like this: The waves in reality have height and slope. What you see when looking over the water as in the example shots is primarily the slope of the waves facing you - because the flat part of the crest is very small due to the perspective and the away-looking part and the trough is obscured.

The reflection condition for the facing slopes is very different from a flat surface though - first it's much farther from the Fresnel enhancement, second it's reflecting something much higher up.

I believe the concept of roughness can only be applied to tiny ripples, but under most conditions not to meter-sized ocean waves.

Which means outside the roughness limit (tiny ripples really), reflections really ought to be absent.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Screen-Space Reflections

Postby icecode » Sat Jul 28, 2018 11:06 am

Not sure if reflected terrain disappearing(?) as view moves downwards can be avoided or is too noticeable - if smoothly blended out.


It can't be avoided unfortunately. Most games use other techniques alongside SSR and they fallback to them when there is not enough SSR data.

I believe the concept of roughness can only be applied to tiny ripples, but under most conditions not to meter-sized ocean waves.


Now I get what you're saying, and you are completely right, yeah. Well, I think FG has some way of distinguishing between ocean water and lake/river water, so SSR should still be useful in some waters.
icecode
 
Posts: 709
Joined: Thu Aug 12, 2010 1:17 pm
Location: Spain
Version: next
OS: Fedora

Re: Screen-Space Reflections

Postby Thorsten » Sat Jul 28, 2018 3:23 pm

Well, I think FG has some way of distinguishing between ocean water and lake/river water, so SSR should still be useful in some waters.


Yes, we can do that. And since you said you can do puddles... that's going to be really interesting.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Screen-Space Reflections

Postby bugman » Sat Jul 28, 2018 3:35 pm

The way this is done in other sims is horrible! You almost never see any reflections in the ocean in real life. Lots of people like such artificial reflections as they look awesome (and a vote here would probably be for it), but it just not reality. However this could be awesome for aircraft with floats landing and taking off from lakes when there is no wind. Also, if you've ever been sailing on a lake, you'll know that the reflections are completely gone when there is any wind of interest.

Regards,
Edward
bugman
Moderator
 
Posts: 1808
Joined: Thu Mar 19, 2015 10:01 am
Version: next

Re: Screen-Space Reflections

Postby wlbragg » Sat Jul 28, 2018 10:55 pm

It is definitely dependent on wind, so as long as that is the condition it would be awesome to have in the effects catalog. There are many time I have seen surface reflection in reality from puddle to ocean. I've seen breathtaking reflections on the leeward side of island (Channel Islands). Albeit in that area it is not very common. But quite common in the deep water lakes in the canyons of So California in the early mornings especially.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 3 guests