Board index FlightGear Development Effects and shaders

Plantation effect

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

Plantation effect

Postby frtps » Thu Oct 17, 2019 9:53 am

Rather than use random vegetation I'd like to simulate tree plantations by generating regularly-spaced, almost uniform-height trees, but perhaps with variations in the row directions. Is there any such effect already in the shader directory, or a way to produce it with pre-existing shader variables?
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Plantation effect

Postby Thorsten » Thu Oct 17, 2019 9:57 am

I don't think it exists, but it should be significantly easier to do than the random size patches of trees we have now - essentially just use 1-dim noise.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Plantation effect

Postby vnts » Fri Oct 18, 2019 3:42 pm

Reminds me :) . I wondered about generic instancing effect(s) support when I was tinkering a bit with shaders a while ago. It seemed conceptually useful for many things (?). One that accepts a generic model - which could be 2 quads for trees. It would create an arbitrary 2d grid of objects. A line of trees or windmills would be just a subset. It would also have some random variation in spacing and rotation, as well as object slots that are randomly empty.

The thought came from noticing airports have things like car parks full of simple car models that can hit frame rate disproportionately (maybe needs project3000 to show up?). Airports also tend to have manually placed trees, or various objects. Not sure if manually placed trees miss out on special lighting done by tree shader (season effects too).

Something conceptually along the lines of:

Input to shaders by engine might include: 1. some instance ID, 2. something to distinguish it from other of the effect in view, 3. # rows&columns, 4. location of two diagonally opposite corners of grid, 5. bounding radius/dimensions, 6. min&max spacing variation in both directions, 7. min&max rotation angles & variation, 8. a parameter 0-1 that tweaks the distribution in variation (how common the extremes are), 9. probability of an object slot being empty like , 10. some parameters for random color or texture variation for cars&similar.

1&2 - give a random PRNG seed for each object.
4-9 - supplied by the scenery maker in an XML(?) file distributed via terrasync. 9. can be done by shaders by if convenient (fragment discard statement or maybe collapsing vertices into a point?).
10 - may need variants of shaders unless there's a convenient way to specify masks for colour changes for everything without slow down - via spare mask channels, texture colour lookup tables, texture swaps, or something.

Edit: Random spacing away from airports in uneven terrain is harder, unless the general slope around each object position was also given by the engine, and variation in spacing (or slope) was small.

Grids with varying objects like objects like different vehicle models would be harder, and might be faked with 2-3 uses with different spacing.

Instancing support for manually specified position & rotation might also improve performance since airports often have duplicated objects(?).

Just a thought. Not sure if that's workable, fast, or easy to implement.

(Engine functionality to instance specified models without changing c++ may also be useful for objects bordering straight streets, like rows of streetlamps&road barriers&hedges.)

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

Re: Plantation effect

Postby frtps » Thu Nov 14, 2019 9:55 am

So I've developed some code to produce a "plantation" effect. I expect this could be used for orchards and agroforestry. Not for vineyards unfortunately as the vegetation system instantiates a tree as two planes at right angles.

Image

The code places trees at integer spacings on the x,y coordinate grid in which the triangles are expressed (so I guess on a N-S E-W grid). I've done it this way so that neighbouring triangles and tiles will not have problems with trees getting too close together at the boundaries, as they'll all be on the same underlying grid. The spacing is simply based on the usual wood coverage material property. Things like tree height variation and masks can all be managed through the currently available material properties.

In order to switch on this effect, I think there would have to be a new "plantation" material property. Note that the tree positions (random or regular) are calculated outside the shader system (i.e. the positions are only generated CPU-side once when the tile is loaded).

Does adding a <plantation> boolean material property sound reasonable? Is the N-S E-W grid layout too limiting?
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Plantation effect

Postby Thorsten » Thu Nov 14, 2019 10:15 am

Sweet :D

For a C++ side change and how to interface it, best contact the mailing list for opinions - too few developers check the forum for those things.

(Note that since we position trees in the vertex shader, we could just force them to integer positions there - which might be a less intrusive change).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Plantation effect

Postby icecode » Thu Nov 14, 2019 12:20 pm

Looking nice!

In order to switch on this effect, I think there would have to be a new "plantation" material property.


In my opinion that sounds like a good option. It's an artificial forest but it's still a forest, so a boolean property makes sense to me. It's also very backwards compatible as you could just assume it's false by default.
icecode
 
Posts: 709
Joined: Thu Aug 12, 2010 1:17 pm
Location: Spain
Version: next
OS: Fedora

Re: Plantation effect

Postby Thorsten » Thu Nov 14, 2019 1:03 pm

Actually it could be a more general integer encoding - that could accomodate more complicated future shapes (trees preferably bunched together in groups, ...)
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Plantation effect

Postby GinGin » Thu Nov 14, 2019 1:40 pm

That is a very nice piece of work.
GinGin
 
Posts: 1580
Joined: Wed Jul 05, 2017 11:41 am
Location: Paris
Callsign: Gingin

Re: Plantation effect

Postby wlbragg » Thu Nov 14, 2019 4:26 pm

Looks good, could it also be adapted as row crops?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7587
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Plantation effect

Postby frtps » Thu Nov 14, 2019 11:07 pm

wlbragg wrote in Thu Nov 14, 2019 4:26 pm:Looks good, could it also be adapted as row crops?


No reason you couldn't, all you would do in the material definition is to supply the e.g. corn stalk "tree" texture swatch and other vegetation parameters as per usual. Not sure about the hit on the graphics/CPU from instantiating vegetation at typical crop densities though.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Plantation effect

Postby frtps » Thu Nov 14, 2019 11:10 pm

Thorsten wrote in Thu Nov 14, 2019 10:15 am:Sweet :D

For a C++ side change and how to interface it, best contact the mailing list for opinions - too few developers check the forum for those things.

(Note that since we position trees in the vertex shader, we could just force them to integer positions there - which might be a less intrusive change).


Roger that. I'll switch my attention to the mailing list.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Plantation effect

Postby ludomotico » Fri Feb 28, 2020 12:45 am

I've been playing with the plantation effect and it looks very convincing. Example simulating a small field of vineyards:

Image

At higher altitudes and large fields, if trees have different sizes, the effect also looks very nice:

Image

Even at low altitudes the effect is perfectly acceptable for vineyards, imho. LE01-Avinyonet, at the heart of Penedès. You may have tasted the "Cavas" from the region: Freixenet, Codorniu...

Image

This is only after 30 minutes of testing! I'm sure a better selection of trees will produce even better results.

Thank you very much!
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: Plantation effect

Postby Thorsten » Fri Feb 28, 2020 8:11 am

Nice... :D
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Plantation effect

Postby frtps » Fri Feb 28, 2020 2:25 pm

Those screenshots look great. One thing that I think could be improved is to adjust the amount of height variation (the "forest" effect, I think it is called). Unfortunately, as far as I can tell changing the parameters for this effect in the materials file does not actually change the final displayed heights due to the special code path for creating random trees. I'm having trouble following this code path so I haven't tried to fix it yet.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Plantation effect

Postby wlbragg » Fri Feb 28, 2020 4:18 pm

Is this documented anywhere? A couple code snip-its would be useful.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7587
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Next

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 4 guests