Terrain rendering optimization.

Now the terrain is rendered using “Queue” = “Geometry-99”. When you use the Frame Debugger you will see it’s being rendered before all the geometry.

Wouldn’t it be better if it was rendered after all the geometry? It would mean, that the depth buffer is already filled with a lot of pixels from the geometry and most of those pixels are closer to the camera, so a lot of pixels from the terrain would be culled. It should increase the performance.

My questions are:

  1. Why is the terrain rendered before all the geometry? Front to back rendering is faster and terrain is in the background most of the time, so Terrain should be rendered as a last geometry object.
  2. How to change this? I have tried to use Terrain.materialTemplate.renderQueue = 2500 (the standard value of terrain is 1901), but for some reason it doesn’t affect the rendering order. I have also tried to edit the “Nature/Terrain/Diffuse”, I have used the source of the shader, changed the queue and then used this new shader in the materialTemplate. It didn’t help. I would probably have to edit some other shaders too. I think one way or the other it’s possible to make the terrain render as the last object. But before wasting any more time finding how I would like to know why isn’t this the standard behavior?

I think the possible answer is this: sometimes the terrain is in the background but many times it’s in the foreground and it’s more optimal to render it first.

Digging this up because it’s still relevant : most of the time, terrain is covered, being it by vegetation, buildings, or anything. I never saw an engine where it would make sense to render terrain first. We have a level where baked occlusion culling is broken (bug already sent to QA like a month ago…) and having terrain rendered first only makes the performance worst…

Did anybody find a solution to force terrain to be rendered last? I also tried changing the layer in the material but it still has no effect. I searched for a way to move the terrain to a different sorting layer but couldn’t find a way to.

You need to change the queue of the other objects. Since the queue of the terrain is according to my first post Geometry-99 (2000 - 99 = 1901), change the queue of the other objects to 1900 or less and the terrain should be rendered as the last object (at least in theory).

Yes, in theory, changing the render queue should fix the error. But I just tried it and neither changing the render order of the terrain (with a custom material) or changing the render order of the objects in front of it change anything, terrain is always rendered first :frowning: