Board index FlightGear Development Effects and shaders

Volumetric grass (was 3D textures and volumetric data)

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

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Thorsten » Fri May 19, 2017 5:13 am

@ Icecode GL

Now that the new devel branch is open, how do you want to proceed? Should I add the existing version for testing and evaluation, do you want to explore reducing the action of the geometry shader for more distant triangles, do you want to add wind effects, should I give it a try?

(And - do you realize the potential otherwise? By just extruding 3-6 layers and using a semi-transparent shrub texture modulated with a Perlin noise heightmap, we can immediately generate low undergrowth like heather or mossy patches.

Maybe even low rocks.)
Thorsten
 
Posts: 11106
Joined: Mon Nov 02, 2009 8:33 am

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Icecode GL » Fri May 19, 2017 9:31 am

If you don't mind I prefer to wait for a while before pushing to the devel branch.

Since people have said they prefer to combine both grass efects (instancing and shell texturing), I think it would be a good idea to change the shell texturing effect to better match how low-cut grass looks. Now that the ground is covered entirely by grass, the instancing method density can be reduced a lot and still give the impression of a grass field, increasing performance.

I'm also not a big fan of adding so much alpha to the grass blades, since it's really obvious even when looking from far away. About wind, I posted my implementation before. If you want to try your own feel free to do so. This is a collaborative project: the one who gets the best results at the lowest performance cost wins. :)
Icecode GL
 
Posts: 541
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Thorsten » Fri May 19, 2017 9:44 am

Note that the instanced grass is a 'power user' thing - I have not found a way to make it work nicely with Classic or Rembrandt, so it will never be on in a FG installation, you'll always have to uncomment the code.

And power users can also change the other textures/parameters to their liking.
Thorsten
 
Posts: 11106
Joined: Mon Nov 02, 2009 8:33 am

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Icecode GL » Fri May 19, 2017 3:23 pm

I've made some changes:

Image

Image

It's completely procedural, no textures needed. Improving it further is just a matter of having some "artistic sense" (which I don't have much) to choose nice colors and noise distributions.
Icecode GL
 
Posts: 541
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Thorsten » Fri May 19, 2017 4:02 pm

I'll have a look (soonish - been release candidate testing today, alas developing FG isn't only having fun with shaders).

Generally - please try heavy fog / low light / wetness. The relatively high alpha I've been using is driven by a need to cheat - we can't fog or light the grass layer properly without having access to tons of varyings, but we can get away with fading it to alpha rather than fog color or flat lighting if the grass layer just enhances a base texture which gets proper light and fog.

We can't do that if the grass layer is supposed to work on its own, in this case I expect fogging issues which are difficult to tackle.
Thorsten
 
Posts: 11106
Joined: Mon Nov 02, 2009 8:33 am

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Icecode GL » Fri May 19, 2017 4:06 pm

What varyings do you need specifically? I'm already passing the interpolated fragment position in model space.
Icecode GL
 
Posts: 541
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Catalanoic » Fri May 19, 2017 5:25 pm

30 FPS (not really but still high) with a full field of grass??! Procedural techniques would have a well deserved place on a FG installation. Congrats to the developer, really nice!
User avatar
Catalanoic
 
Posts: 1055
Joined: Mon Mar 05, 2012 12:33 am
Location: Barcelona (LEBL)
Callsign: Catalanoic
Version: 2017.3
OS: Lubuntu/Windows 7

Re: Volumetric grass (was 3D textures and volumetric data)

Postby erik » Fri May 19, 2017 5:41 pm

Icecode GL wrote in Fri May 19, 2017 3:23 pm:I've made some changes:

Image

Wow, this turns out to be excellent for crops too.

Erik
erik
 
Posts: 1520
Joined: Thu Nov 01, 2007 1:41 pm

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Thorsten » Fri May 19, 2017 5:58 pm

What varyings do you need specifically? I'm already passing the interpolated fragment position in model space.


You have, I believe, the ALS fog function in isolation :mrgreen:

It's a question of performance - you can do all the computations in the fragment shader based on position, but with a lot of layers that's a lot of fragments to go through. Obviously doing (part of) the math in the vertex shader is going to help enormously here, because the number of involved vertices is tiny compared to the number of fragments.

Needs to be tried I guess.

Looking at your shots, this actually looks more like lawn than like grass - I'm living on a farm, as I write looking out of the window onto the summer horse paddocks - we need to get this quite a bit more messy.

But the beauty of a procedural approach is that we'll do this property-configurable, and then we can target this to the landclass in question :-)
Thorsten
 
Posts: 11106
Joined: Mon Nov 02, 2009 8:33 am

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Icecode GL » Fri May 19, 2017 6:53 pm

30 FPS (not really but still high) with a full field of grass??!


Actually it's a solid 60, I was running 3 FlightGear instances accidentally. :P

Obviously doing (part of) the math in the vertex shader is going to help enormously here, because the number of involved vertices is tiny compared to the number of fragments.


We are not as limited as we think in terms of passing info from the GS to the FS. It's true that we would have to reduce the max number of layers but there is not a noticeable difference between 30 layers and say 24, and that would give us at least 2 additional 4-dimensional vectors to pass. Still, many things can be tricked. For example I assume you might need normals - just use a vector pointing up since airfields aren't at an angle 99% of the time.

Looking at your shots, this actually looks more like lawn than like grass - I'm living on a farm, as I write looking out of the window onto the summer horse paddocks - we need to get this quite a bit more messy.


I live in a kinda big city so I'm not used to seeing wild grass, that might have influenced a lot. :) But as you said, everything will be property driven so hopefully people can contribute their own "grasses".
Icecode GL
 
Posts: 541
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Johan G » Sat May 20, 2017 7:41 pm

This looks like an interesting feature to follow the development of. :D

Also, this have never happened to me: :lol:
Icecode GL wrote in Fri May 19, 2017 6:53 pm:Actually it's a solid 60, I was running 3 FlightGear instances accidentally. :P
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: 5529
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: Volumetric grass (was 3D textures and volumetric data)

Postby Thorsten » Sun May 21, 2017 9:34 am

@Icecode GL

I've just looked at your repository to have a look at your latest code, but there's still my version with distance to fragment is passed rather than full fragment coordinates. Where should I look instead?
Thorsten
 
Posts: 11106
Joined: Mon Nov 02, 2009 8:33 am

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Icecode GL » Sun May 21, 2017 11:10 am

Sorry, I forgot to push the changes to the repo. Everything should be working now.
Icecode GL
 
Posts: 541
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Icecode GL » Sun May 21, 2017 11:19 am

There are some depth issues I can't seem to fix. It should work properly but it doesn't:

Image

The grass layers from behind show in front of the nearer ones. But if you turn around and look at the edge from the other side, or even change the angle a bit, it works as intended:

Image
Icecode GL
 
Posts: 541
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Volumetric grass (was 3D textures and volumetric data)

Postby Thorsten » Mon May 22, 2017 11:53 am

It's completely procedural, no textures needed. Improving it further is just a matter of having some "artistic sense" (which I don't have much) to choose nice colors and noise distributions.


It's unfortunately not that simple. Please don't take the following comparison in the wrong way, the point is not to down-play your effords but to illustrate why I think we should really render this on top of a base layer.

From mid-distance, individual blades invisible:

Your solution (full grass):

Image

My solution (overlay with LOD):

Image

After having had a procedural color variation on a hires texture on the airport keep for a while, we decided to discard the strategy some two years ago for the reason seen here - not enough variation. A texture can bring in much more structures which are hard to capture by Perlin noise, for instance tracks of vehicles or erosion.

From large distance with seasonal variations:

Full grass:

Image

Overlay with LOD:

Image

Unfortunately ALS has a lot of post-processing options runtime on the textures - you need to achieve a seamless match with all of them. Late autumn and winter in the overlay is easy - we discard the whole overlay and show only the base texture. In your scheme, that's considerably harder.

From close distance, individual blades visible:

Full grass:

Image

Overlay with LOD:

Image

Unfortunately airport keep terrain may be sloped - and the shell texturing seems to not handle this gracefully - you can look through slopes in the scheme. The overlay handles the same problem much more gracefully.

So unless you come up with a really good case for full grass, I think I'm going to stay with the overlay / LOD scheme which draws blades out to 1 km max. - which is also going to have an edge in arid areas where you want to create patches of grass and bare soil inbetween.
Thorsten
 
Posts: 11106
Joined: Mon Nov 02, 2009 8:33 am

PreviousNext

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 0 guests