Board index FlightGear Development Scenery

Procedural Texturing Question

Questions and discussion about enhancing and populating the FlightGear world.

Procedural Texturing Question

Postby wlbragg » Tue Apr 22, 2014 4:35 pm

Kansas is coming along. I have a couple questions about procedural texturing below..
Most of the grassland, deciduous and crop textures are new ones I made in an attempt to better match the terrain in the different parts of KS.

Eastern KS
Image

South Central KS
Image

Western KS
Image

It's the cropland in western KS that I have some questions about.

Using the "Overlay texture" method,
How much of a "flat" scene is overlaid using the default 0.5 transition_model?
Is there any difference using 0 transition_model assuming there is no gradient?
If you use more than one "Overlay texture" entries, how is the percentage of overlay divided up between them?

I think I could get better results using this method if I could control how much overlay percentage each entry can have.

Also, do the water-inland.eff completely override whatever texture you assign in the materials.xml? It seems like no matter what different texture I try to use for Stream and Lake, they are ignored unless I remove the .eff files influence.
If not to difficult to answer, why is this and how does it work?
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5451
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Procedural Texturing Question

Postby Thorsten » Wed Apr 23, 2014 6:26 am

How much of a "flat" scene is overlaid using the default 0.5 transition_model?


About 50% by the overlay layer, and then a controllable fraction by the detail layer.

In case you're wondering, here's the overlay code - noise is always a number between 0 and 1, and mix_factor in the end is what determines the resulting texture - if it's 0, the normal texture is drawn, if it's 1 the overlay is drawn, and the smoothstep in the second to last line basically says 0 below the noise 0.5 and 1 above 0.54, blended between.

Code: Select all
nSum =  0.18 * (2.0 * noise_2000m + 2.0 * noise_1500m + noise_500m);
nSum = mix(nSum, 0.5, max(0.0, 2.0 * (transition_model - 0.5)));
nSum = nSum + 0.4 * (1.0 -smoothstep(0.9,0.95, abs(steepness)+ 0.05 * (noise_50m - 0.5))) * min(1.0, 2.0 * transition_model);
mix_factor = smoothstep(0.5, 0.54, nSum);
texel = mix(texel, mix_texel, mix_factor);

Is there any difference using 0 transition_model assuming there is no gradient?


No, not for a flat surface. At 0.5 you would get gradients drawn in addition if they're there, otherwise not.

If you use more than one "Overlay texture" entries, how is the percentage of overlay divided up between them?


Base texture, overlay and detail layer are drawn in that order, so the higher layers always hide the lower layers. The overlay can be reduced by making it more gradient-like, then for a flat surface it will occupy less than 50%. The detail layer has a bias factor to control its coverage directly.

I think I could get better results using this method if I could control how much overlay percentage each entry can have.


Kansas does seem pretty flat, so what about pushing the transition model to the more gradient-like region? That will reduce the percentage.

Admittedly I'm reluctant to introduce many more parameters. I have about a dozen which would be useful in one context or the other, but it's always a drain in performance to add another feature. So I'd rather wait and see whether playing with the transition model can't get you where you want to be.

One thing to keep in mind is that you should not rely too much on overlays though - users running at lower quality settings will only see the base texture, so the base texture should be meaningful for the landclass (otherwise there'd be nice tricks hiding a special landclass through a high coverage of the detail texture...)
Thorsten
 
Posts: 11580
Joined: Mon Nov 02, 2009 8:33 am

Re: Procedural Texturing Question

Postby wlbragg » Wed Apr 23, 2014 2:25 pm

Thank you Thorsten for you reply.

users running at lower quality settings will only see the base texture

Good tip, I have a tendency to forget about other hardware setups.


If multiple base textures are defined ...
Will the program use them all?
Does it only use one per block?
Does it pick them at random whenever it needs to lay down a new block?

If multiple "Overlay" textures are defined does it use only one per block or multiple (however many are defined) per block?


Kansas does seem pretty flat, so what about pushing the transition model to the more gradient-like region? That will reduce the percentage

I'm actually needing to "increase" the percentage.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5451
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Procedural Texturing Question

Postby Thorsten » Wed Apr 23, 2014 2:35 pm

Code: Select all
If multiple base textures are defined ...
Will the program use them all?
Does it only use one per block?
Does it pick them at random whenever it needs to lay down a new block?


That's fairly old code, and early attempt at de-tiling. I suspect FG randomly chooses one per tile/block and only one per tile/block.

If multiple "Overlay" textures are defined does it use only one per block or multiple (however many are defined) per block?


You mean something like

Code: Select all
<texture-set>
 <texture>base_texture.png</texture>
 <texture n="12">overlay_texture.png</texture>
 <texture n="12">other_overlay_texture.png</texture>
</texture-set>


I have not planned for any such case, nor have I tried - I suspect the last overwrites all others. I basically tried to get away from defining multiple base texture - it doesn't really work for de-tiling and it doubles (triples,...) the amount of texture memory needed.

I'm actually needing to "increase" the percentage.


So if the overlay is to be the most prominent landcover, why not make it the base texture and change the current base texture to an overlay?
Thorsten
 
Posts: 11580
Joined: Mon Nov 02, 2009 8:33 am

Re: Procedural Texturing Question

Postby wlbragg » Thu Apr 24, 2014 2:47 am

You mean something like

Yes, that is what I meant.

So if the overlay is to be the most prominent landcover, why not make it the base texture and change the current base texture to an overlay?

There is no difference doing this. It needs a third prominent to effectively break up the tiling. Swapping one for the other doesn't help.

Multiple "Overlay" textures is what is needed for that particular type of crop. It still wouldn't be perfect as some of the breaks between the two (or potentially three) textures can look a little odd. But I think it looks better than the tiling.

You already allow for as many as 4 added texture files to be loaded at any given time
Code: Select all
High-Res texture
Overlay texture
Gradient texture
Grain texture


For example, madagascar uses three extra texture files.
Code: Select all
<texture>Terrain/tundra-hawaii.png</texture>
<texture n="11">Terrain/rainforest-hawaii.png</texture>
<texture n="12">Terrain/shrub-hawaii.png</texture>
<texture n="15">Terrain/airport_grass2.png</texture>


So, if you could have even two different "Overlay" textures break up the base, randomly, each covering 33%, I think it would go far to affect the tiling of this difficult crop type.
Using your example, which is what I meant,
Code: Select all
<texture-set>
 <texture>base_texture.png</texture>.........33%
 <texture n="12">overlay_texture.png</texture>.........33%
 <texture n="12">other_overlay_texture.png</texture>.........33%
</texture-set>

It would break up most of the tiling and still be less than what is acceptable for " madagascar" for example.
If it's not available then that's that.
Now I know what I have to work with and will have to live within that boundary.

P.S. Look closely at that last picture and you can see where the "Overlay" texture breaks up the tiling. I think a little more would be helpful.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5451
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Procedural Texturing Question

Postby Thorsten » Thu Apr 24, 2014 5:42 am

There is no difference doing this. It needs a third prominent to effectively break up the tiling. Swapping one for the other doesn't help.


Um... for the problem you initially outlined it does. If you have a technique which allows you to draw a base texture and 0-50% coverage of the overlay texture, and you want 80% coverage of the overlay texture, you achieve that by drawing the overlay texture as base layer and drawing 20% of the old base texture as overlay layer.

For example, madagascar uses three extra texture files.


That's not how these things work internally. Every landclass always uses six texture layers (base, overlay, detail, grain, slope and dot) - if you don't see them or set them to void, it just means there's a small completely transparent texture used. OpenGL doesn't go easily for optional texture loading - a bit simplified, if you want to use one texture more, write a new shader, if you want to use one less, write a new shader.

Multiple "Overlay" textures is what is needed for that particular type of crop. It still wouldn't be perfect as some of the breaks between the two (or potentially three) textures can look a little odd. But I think it looks better than the tiling.


It'd definitely help if you tell me what kind of effect you want to achieve (aka show me an aerial picture of the area, or a gimp-made mockup, or...). Otherwise I keep answering your questions without actually going into the direction you want to achieve...

The current toolkit is actually pretty poor for agriculture because it's essentially developed for natural landclasses. I think to break tiling in agricultural patterns, we need domain segmentation rather than Perlin noise, i.e. this needs to go via a dedicated shader effect. My initial idea was to rotate textures inside domains, but of course also overlays could be swapped inside domains. On the other hand, agricultural patterns probably do not need a dot texture or a detail overlay texture.
Thorsten
 
Posts: 11580
Joined: Mon Nov 02, 2009 8:33 am

Re: Procedural Texturing Question

Postby wlbragg » Thu Apr 24, 2014 12:46 pm

Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5451
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Procedural Texturing Question

Postby wlbragg » Thu Apr 24, 2014 5:12 pm

It just dawned on me this thread is more fitting for the shader/effects category, I apologize for starting it in general scenery. Feel free to relocate it if possible.

For clarifications sake,

and you want 80% coverage of the overlay texture


I never wanted 80% in one texture. In this context I wanted 66% total divided up to two different overlay textures each with 33% apiece. If that number was ever stated as 80% then I would have requested the extra 80% be divided up to four different overlay textures, for a total of five all having approx. 20% including the base texture.

It all boils down to what your trying to achieve in the thread domain segmentation. Same outcome, only the method your trying to achieve is way better and more versatile.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5451
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Procedural Texturing Question

Postby Thorsten » Tue May 06, 2014 5:42 am

The first version of the agriculture effect is now on GIT.

You use it by declaring

Code: Select all
    <effect>Effects/agriculture</effect>


in the landclass definition. The configuration is done in the <parameters> section as for the normal terrain shader. Since the agriculture effect is switched on in the rendering dialog, you can make both a normal and an agriculture effect declaration, parameters and textures are separate. If you want to use an overlay texture, it needs to have the number 16

A configuration block looks like this

Code: Select all
<overlay_fraction>0.5</overlay_fraction>
<overlay_scale>1000.0</overlay_scale>
<rotation_flag>0</rotation_flag>
<rotation_scale>2000.0</rotation_scale>
<distortion_factor>0.3</distortion_factor>


overlay_fraction [0-1]: percentage of the terrain that should be covered by the overlay texture
overlay_scale: approx size scale of the patches for the overlay texture (actual patches can be ~50% larger or smaller)
rotation_flag (integer) [0-2]: 0: never rotate any texture 1: rotate by random angle per domain 2: rotate by 0,90,180 or 270 degrees on;y
rotation_scale: approx size of the patches in which textures are rotated
distortion_factor[0-1]: how much does the shape of the domains deviate from a square?

Please try it out and give feedback!
Thorsten
 
Posts: 11580
Joined: Mon Nov 02, 2009 8:33 am

Re: Procedural Texturing Question

Postby wlbragg » Tue May 06, 2014 6:24 am

Wow, can't wait to use it. I'll report back soon.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5451
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480


Return to Scenery

Who is online

Users browsing this forum: No registered users and 3 guests