Jump to content

Terrain texture shader?


photo

Recommended Posts

Greetings! 

We are faced with an interesting technical challenge that involves farmfields, and we are considering building a custom texture shader for this feature, because much of our landscape is covered by by this class of terrain.  Specifically, our challenge is:

a. To achieve the direction and flow specific to each farmfield (or at least in a logical manner approximating reality)
b. To ensure these farms remain visually pleasing - which cannot be addressed by our procedural albedo generation methods, which results in good quality, but compressed tiles.  These tiles do not have the resolution needed to present nice farms without being blurred by compression (I have attached a sample procedural tile so this can be understood).  Additionally, although our procedurally built detail masks are excellent for the randomness and variety of organic detail, we cannot make high enough resolution masks for farm details in straight, precise lines, so we have a problem.  

Most farmfields are so geometric, we have created shape files that define them in great detail, and we would like to then use these as bounding boxes for the drawing of higher resolution detailed textures that can fade to lower detail as the player camera moves away to a higher altitude. 

Because Ungine detail layers do not place textures based on direction or bounding box, we are not sure how else to do this besides creating a shader that achieves the necessary detail.  Primarily, we are looking for recommendations or any possible issues with this method before we begin work on a shader.  Does this sound viable?   

image.thumb.png.0c836562b4acee586f4080e79470ca05.png

1147.jpg

Link to comment

Hello David,

Custom Shader can be a good option. Here what I can tell you about possible risks and issues after consulting our render team:

  • Terrain shader seems to be short but quite complicated. It'll take some time to understand, what's going under the hood
  • Modification of terrain details can be performance costly
  • You'll have to maintain this shader manually

If you already decided that shader is your choice, a starting point can be found in data\core\shaders\terrain_global\fragment\deferred.frag. The loop that works with details starts on the 111th line.

However, you have an alternative with decals. You can draw whatever you want on terrain with mesh decal. I assume that the farmland region is relatively flat, so you'll be able to keep radius value low which is performance friendly.

Thanks!

 

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi Morbid,

Thank you for the feedback.  We have thought about decals, but we are unsure how to place these accurately over a wide space, and with enough variation as is required, AND keep the shape that is required.  Is it possible to place them using the landscape tool?  And, if so, how do we specify direction?  And then, how do we "cut them off" based on where the field ends?  These complexities have led us down the shader route, but we would love a nice alternative.  

Link to comment

I'll try to explain possible workflow with decals. It could be time-consuming depending on the number of fields:

  • You'll need flat meshes that follows the shape of the fields
  • The farmland textures of desired resolution
  • An SHP file with lines. Here come some unobvious things. We have a feature that allows placing a NodeReference (can be almost anything inside) on a vector point. The point has no direction. BUT, you can create vector lines with direction and then scatter decals along these lines using point object configuration.
  • The decal will be placed in the first created point of the line, the direction (X-axis) will be "looking" to the second point.
  • I've attached the sample with heightmap and briefly made vector file. You can generate decals and terrain to check how it works. Please, manually fix the paths to the shp and tiff file in the "vector.landscape" file.

Thanks!

decal_point.zip

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Also, we forgot there are mesh decals.  We see this as much easier method than any kind of shader.  It says in the tutorial, "large complex shapes".  This gave us the idea of having large meshes covering several kilometers at a time, and then making these decals. This would be a very easy workflow for us, given that we already have all the shape data and could rapidly refine these in Blender and draw the necessary farm rows.  

(Specific moment in the tutorial)
https://youtu.be/ziYCy9EbgEs?t=150

One question - I see in the tutorial a single texture is used to draw multiple types of lines.  How is this done in the mesh object?  Are mesh components named a certain way?  Clarification on this would be very helpful. 

Thanks!

Link to comment
2 hours ago, david.norlin said:

One question - I see in the tutorial a single texture is used to draw multiple types of lines.  How is this done in the mesh object?  Are mesh components named a certain way?  Clarification on this would be very helpful. 

It's done with UV map. I've attached a sample mesh with a texture used in the tutorial, check it, please.

I'd like to remind you of two important things:

  1. Several kilometers will be okay, but Decals have limitations. They wouldn't work on extreme sizes like tens of kilometers.
  2. Radius is the main decal parameter that affects performance. Try to keep it as low as possible.

Thanks!

decal.zip

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • 4 weeks later...

I think the best would be megatexture approach (bigger distance mega texture, close distance detail textures). This was partially possible with older version of terrain (it was possible to have separate diffuse texture for each terrain chunk, so it was possible to have quite high res overall diffuse texture). If I remember well, megatexture approach was mentioned together with new terrain comming in 2.9?

 

Edited by demostenes
Link to comment
  • 3 weeks later...
×
×
  • Create New...