Splat texture scaling with distance

I want to change the terrain shader so that there are two scales you set when setting the texture scale. One would be for drawing the terrain close to the player, the other for farther away, since you do not need as much detail if the texture is far away. Then I would like it to fade between both of them at a certain distance away. I saw this post on the blender artists forum and would like to port that feature of it to jmonkey. The source of that blender game engine shader can be found here. So, for the past two weeks I have been trying to learn glsl to be able to write my own shaders. I also read through the wiki parts about how jmonkey uses shaders and such. I would like to ask if this feature is already available and if someone could help me implement it.

Thanks!

What do you mean by texture scale? you mean having like a 2048x2048 for near and a 512x512 for far distance?

There shouldn’t have to be two copies of each diffuse texture. When drawing the texture on the terrain, if it is a certain distance away from the camera, draw the texture at a larger scale. In the BGE script, it blends between the two states to make it less noticeable. In this video of the blender game engine terrain shader script from above you can kind of see the effect. The idea is to improve performance. Due to my limited graphics knowledge, this may not even improve performance, I really don’t know.

OK so I see what you are talking about. it’s at the very end of the video right? about texture tiling.
I guess it’s more for an artistic effect than for performance. You can tile a texture as much as you want performance will be the same.
IMO that’s just so that the texture doesn’t look like a plain color at far far away distance.
@Sploreg what do you think?

1 Like

There’s a lot of ways to go about improving the terrain textures from far off. One that I like is the fading of the detail textures as posted on the wolfire blog. The texture tiling approach in that video is quite intriguing actually, and could produce some nice results.
I can provide you some hints, however I’m going to be AFK for the next week, or on and off randomly, as I move cities.

To start, each splat texture has a scale. You could try hard-coding a lod threshold that will automatically blend a lower detail texture with the higher one and then later add in a user-defined parameter. Starting at line 210 in TerrainLighting.frag the splatting takes place. I would ignore the tri-planar mapping section for now and see how it looks without that.

1 Like

Thanks! I will look into it, and whats the tri-planar section do? Sorry, as you can probably tell I am pretty new to glsl.

What is currently on the to-do list for terrain, if there is one?

Actually if you read the comments on the blog post the emerging idea to enhance the process is the one showcased in the video you posted.
So basically to avoid to have obvious tile pattern, the tiles are made bigger with the distance.

Triplanar mapping is to avoid stretching in the texture map on steep slopes.

1 Like