Board index FlightGear Development Scenery

Agriculture effect and object mask  Topic is solved

Questions and discussion about enhancing and populating the FlightGear world.

Agriculture effect and object mask

Postby montagdude » Mon Apr 13, 2020 4:48 pm

I've noticed that the agriculture effect breaks the object mask, so trees and buildings end up in the wrong spots when the agriculture effect is active. I did a search and saw this mentioned a few times. Is there a technical reason why the object mask can't be updated when the agriculture effect is on, or is it just that no one has implemented that yet? If so, it would be a helpful feature. Thanks.
montagdude
 
Posts: 266
Joined: Tue Dec 31, 2019 7:04 am

Re: Agriculture effect and object mask  

Postby stuart » Mon Apr 13, 2020 7:13 pm

Yes, there's a technical reason.

The object masks are basically textures that use the different channels to define where on the texture is an appropraite place to locate a building, tree etc. You can think of them as overlays on top of the "real" texture.

The agricultural effect procedurally generates fields, so doesn't use a texture at all. Furthermore, the colors are generated in a shader on the GPU, while objects/trees are placed by the CPU. There's no easy way to feed back information to the CPU from the GPU so that the CPU could place trees differently.

-Stuart
G-MWLX
User avatar
stuart
Moderator
 
Posts: 1629
Joined: Wed Nov 29, 2006 10:56 am
Location: Edinburgh
Callsign: G-MWLX

Re: Agriculture effect and object mask

Postby montagdude » Mon Apr 13, 2020 7:20 pm

Thanks again Stuart. I guess the best solution for me will be to try to find images of farm fields without many trees or buildings. Easier said than done, but should be possible.
montagdude
 
Posts: 266
Joined: Tue Dec 31, 2019 7:04 am

Re: Agriculture effect and object mask

Postby stuart » Tue Apr 14, 2020 9:18 am

I take it you are trying to create custom materials for a region without many trees? You could use the agricultural shader and simply reduce the tree density in the materials definition so there are fewer trees?
G-MWLX
User avatar
stuart
Moderator
 
Posts: 1629
Joined: Wed Nov 29, 2006 10:56 am
Location: Edinburgh
Callsign: G-MWLX

Re: Agriculture effect and object mask

Postby frtps » Tue Apr 14, 2020 10:39 am

montagdude wrote in Mon Apr 13, 2020 7:20 pm:Thanks again Stuart. I guess the best solution for me will be to try to find images of farm fields without many trees or buildings. Easier said than done, but should be possible.


An approach I've found quite effective is to use the 'clone' tool in GIMP to overwrite patches of trees/houses/roads with bits of the same photo from somewhere else on the photo. A very handy tool.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Agriculture effect and object mask

Postby montagdude » Tue Apr 14, 2020 1:29 pm

stuart wrote in Tue Apr 14, 2020 9:18 am:I take it you are trying to create custom materials for a region without many trees? You could use the agricultural shader and simply reduce the tree density in the materials definition so there are fewer trees?

It's the Eastern US, so there are a lot of trees, but most of them are already handled by the landcover data I have. Right now I'm trying to get farm land that looks correct for the region, but there are a lot of tradeoffs to deal with. I think using the agriculture effect is the best way to go, but I have to find or create textures that don't have a lot of trees, or else it will look wrong because there would be flat trees in the texture not covered with 3D trees in the sim.
Last edited by montagdude on Tue Apr 14, 2020 1:33 pm, edited 1 time in total.
montagdude
 
Posts: 266
Joined: Tue Dec 31, 2019 7:04 am

Re: Agriculture effect and object mask

Postby montagdude » Tue Apr 14, 2020 1:31 pm

frtps wrote in Tue Apr 14, 2020 10:39 am:
montagdude wrote in Mon Apr 13, 2020 7:20 pm:Thanks again Stuart. I guess the best solution for me will be to try to find images of farm fields without many trees or buildings. Easier said than done, but should be possible.


An approach I've found quite effective is to use the 'clone' tool in GIMP to overwrite patches of trees/houses/roads with bits of the same photo from somewhere else on the photo. A very handy tool.

That does sound handy. I will give it a try.
montagdude
 
Posts: 266
Joined: Tue Dec 31, 2019 7:04 am

Re: Agriculture effect and object mask

Postby montagdude » Tue Apr 14, 2020 4:58 pm

frtps wrote in Tue Apr 14, 2020 10:39 am:
montagdude wrote in Mon Apr 13, 2020 7:20 pm:Thanks again Stuart. I guess the best solution for me will be to try to find images of farm fields without many trees or buildings. Easier said than done, but should be possible.


An approach I've found quite effective is to use the 'clone' tool in GIMP to overwrite patches of trees/houses/roads with bits of the same photo from somewhere else on the photo. A very handy tool.

I tried it and it seems to work well! It has a side effect of introducing some "chaos" into the texture, which seems to make the tiling effect less noticeable. So maybe the agriculture shader is not even needed. Thanks again!
montagdude
 
Posts: 266
Joined: Tue Dec 31, 2019 7:04 am

Re: Agriculture effect and object mask

Postby frtps » Wed Apr 15, 2020 7:19 am

Another GIMP tool that I found useful for constructing textures is the Filters -> Map -> Make Seamless effect. This makes the picture tile seamlessly at the cost of introducing some blurriness internally. Depending on the texture the blurriness may not matter.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Agriculture effect and object mask

Postby Thorsten » Wed Apr 15, 2020 6:12 pm

This makes the picture tile seamlessly at the cost of introducing some blurriness internally.


Use with care - this tends to increase tiling.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Agriculture effect and object mask

Postby vnts » Thu Apr 16, 2020 2:46 pm

The texture resyntheiser plugin may be useful: (tutorial link , dl win , dl linux). :mrgreen: These are in menu->filters->map or enhance.

The enhance->'heal transparency' tool can fill in holes by analysing the surrounding texture for buildings or trees. I used it a bit when making mockup textures for a shader building facade idea. It can even copy-in small features.

The 'heal transparency' is likely not good enough to make textures visually continuous by putting copies of textures side by side and 'healing' the border region after making it transparent.

The map->uncrop tool seemingly can create and fill-in a border. That is, select a box leaving a x% border large enough to be a field, crop image to selection, and then uncrop enlarging by x%. Not used it before.

The map->resynthesise tool will /recreate/ the entire image preserving larger scale features! Maybe useful to create several variant textures with their own vegetation masks - by using different aerial images of the same land class, or maybe by applying several times if quality isn't degraded too much. That should further reduce the same-ness.

AIUI the perceived sameness needs a texture large enough so a large scale 'unit' repeats. The unit could be fields of similar quality, combinations of different types of fields with contrasting colours, or combinations of fields and woodlands. Some large scale features like a large part of the texture being dry/parched can ruin the illusion, as can singular features. AIUI Such large scale or singular features can be done shader-side with noise or textures.

This is a resynthesiser reconstruction of a existing fgdata texture with different settings: album. It does a reasonable job, and is tileable.

Edit: After playing around with it, for our purposes the best results are with minimum sensitivity to outliers to preserve detail density. I get /excellent/ results with the test texture.

Original: https://i.imgur.com/lEhqlIZ.jpg

Sensitivity: 0.01, neighborhood size: 100 (max), search thoroughness: 500 (max): https://i.imgur.com/rAk7tXJ.jpg

Applying again on previous output to get a 2nd texture for variety (reasonable results): https://i.imgur.com/Hts5Ulv.jpg

It does take a few minutes for a 2048 by 2048 texture. Can be left to run in background. Using a smaller part of a texture to test will be faster.

A possible manual version(?) for comparison or to fix problem areas: select and delete fields on all borders by using 'intelligent scissors' selection tool and/or the free select tool (slow). Manually tile the texture in a big image. Copy/paste from a collection of individual fields (slow to make) into deleted border areas with rotations. Spaces in-between fields can be filled with whatever lies in-between like dirt/trees/bushes. Only two borders need to be done: the filled-in areas from adjacent textures can be moved to fill the other side.

I'm not a digital artist, so there might be better or more elegant ways of using tools in this plugin to solve this.

The issue is there is 1 mask for 1 vegetation type (AIUI?). Agriculture has at least 2 types: crops & wind barrier trees lining fields. Also striking features that occur less often need to be deleted to keep small textures tileable.

A GPU side procedural agriculture effect with lots of variety & detail might(?) be able to randomly segment & rotate both the texture /and/ the vegetation mask. Each crop field would have a ID mask with a number from 0-255. The ID mask could be easily used as a PRNG seed giving random crop orientation, different crop & agriculture types, crop cycles/rotation, and bare fields. This would preserve crop fields, field boundaries, and windbreak trees. But it would need lots of vegetation to be created at the highest density needed for windbreaks/woodlands/crops. The tree vertex shader could snap to a grid, change from crops to trees, or discard based on the same re-mixing of the mask texture. Every way seems to have unavoidable drawbacks.

Kind regards
Last edited by vnts on Fri Apr 17, 2020 1:30 pm, edited 2 times in total.
vnts
 
Posts: 409
Joined: Thu Apr 02, 2015 1:29 am

Re: Agriculture effect and object mask

Postby Thorsten » Thu Apr 16, 2020 5:04 pm

A GPU side procedural agriculture effect with lots of variety & detail might(?) be able to randomly segment & rotate both the texture /and/ the vegetation mask.


The effect does that with the texture, but the placement mask isn't evaluated on the GPU, it is only evaluated on the CPU at terrain loading time, so no effect can influence it.

The idea to compute tree positions on the GPU isn't en vogue :D
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am


Return to Scenery

Who is online

Users browsing this forum: No registered users and 8 guests