2
\$\begingroup\$

I am creating an engine in opengl. As the distance from the player increases, the width and height of the tiles increase by factors of 2. How can I do this? I am currently just averaging, but I miss some of the peaks and valleys, so the slopes are less intense as the tile size increases. This causes some of the textures relative to slope angle to disappear (e.g. grass isn't formed on large slopes, but at distance everything becomes grassy).

The slopes/textures and lighting are based on my vertex normal map.

Here is pseudo code for my current procedure:

float heightmap[layer][x][y]
float normalmap[layer][x][y]

For i=1; i<num_mipmaps; i++
    For x=0; x<(width>>i); x++
        For y=0; y<(height>>i); y++
            heightmap[i][x][y] = 0;
            For x2=x*2-1; x2<x*2+1; x2++
                For y2=y*2-1; y2<y*2+1; y2++
                    heightmap[i][x][y] += heightmap[i-1][x2][y2];
            heightmap[i][x][y] /= 9;

... then I just calculate all face normals and vertex normals separately for each layer.enter image description here

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Do you mean LOD? \$\endgroup\$
    – Bálint
    Jan 17, 2018 at 16:51
  • \$\begingroup\$ Yes, thank you. I have been looking for this term! \$\endgroup\$
    – Kyy13
    Jan 17, 2018 at 17:15

1 Answer 1

1
\$\begingroup\$

I've not dealt with LOD before. I will say, that I've always wondered if instead of averaging if you did some sort of minimum and maximum values for a group of vertices if that would produce better results?

However, for the bump mapping you might look into LEAN maps. In essence, for downsampling a bump map, they calculate the spread of normals in the higher res version of the map and attempt to reproduce that in the smaller versions.

The method evaluates bumps as part of a shading computation in the tangent space of the polygonal surface rather than in the tangent space of the individual bumps. By operating in a common tangent space, we are able to store information on the distribution of bump normals in a linearly-filterable form compatible with standard MIP and anisotropic filtering hardware.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .