
28918.11 Texture MIP Level Selection
18.11 Texture MIP Level Selection
If we do not choose an appropriate texture MIP level selection in the vertex shader, the
terrain may look odd and exhibit more visible morph transitions due to aliasing. At the
current setting, the innermost grid matches the resolution of the texture. We will use a
MIP factor that matches the grids closely.
Listing 18.10 Calculating the MIP level.
float getMiplevel(vec2 position, float texelSize){
float dist = max(abs(position.x), abs(position.y));
float cellSize = startGridScale/(gridSize*2.0);
float correction = log2(cellSize/texelSize);
float distanceLevel = max(0.0,