2
\$\begingroup\$

I have this weird effect when rendering small objects at a long distance. I already tried using anisotropic filtering but maybe I am not doing it right.

Material script:

material Platform/Border
{
  technique
  {
    pass
    {
      ambient 0 1 0.824 1.0
      cull_hardware none
      cull_software none 
      lighting on
      texture_unit
      {
        filtering anisotropic
        max_anisotropy 8
        texture white-pixel.png
      }
    }
  }
}

Screenshots:

first screenshot

second screenshot

How to solve this?

\$\endgroup\$
9
  • 1
    \$\begingroup\$ Are you talking about the edges of the cuboids missing? Looks like mipmapping issues. \$\endgroup\$
    – House
    Aug 27, 2013 at 18:39
  • \$\begingroup\$ @Byte56 Yes, the edges look distorted (some parts are black where they should be greenish) \$\endgroup\$
    – Pacha
    Aug 27, 2013 at 18:47
  • \$\begingroup\$ And it changes based on the distance and angle of the camera? Check out this question: gamedev.stackexchange.com/questions/30275/… \$\endgroup\$
    – House
    Aug 27, 2013 at 18:48
  • 1
    \$\begingroup\$ For this kind of look I imagine you'd get better results by drawing the edges explicitly using lines, rather than relying on a texture. \$\endgroup\$ Aug 27, 2013 at 18:53
  • 2
    \$\begingroup\$ @Pacha Can you edit the question to describe more how you're building the boxes? If the edges are done with polygons, it might help to make them wider as the box gets further away, trying to ensure they always appear at least 1 pixel wide on screen. \$\endgroup\$ Aug 27, 2013 at 20:05

1 Answer 1

3
\$\begingroup\$

This will happen if you use textures for outlines instead of actual primitives (i.e. lines). You are fighting with twice the aliasing when you use textures to achieve this.

First the sample rate of filled primitives decreases with distance given perspective projection and second the effective sample neighborhood used for texture filtering becomes larger with distance. It can become so large, in fact, that a thin (i.e. single-texel wide) detail is completely lost despite filter interpolation.

The ideal solution would be to implement bilateral filtering for your textures (this usually gives better results than even SSAA or MSAA in this special case), but the far simpler solution is simply to use lines for the outline. Alternatively, you could use a technique I have outlined in an answer on Stack Overflow.

Now, since you're using Ogre, I have a feeling that none of the more sophisticated solutions I outlined are going to work for you. One last ditch effort would be to exaggerate the width of the border in your outline texture in lower mipmap levels (assuming Ogre gives you control over the mipmaps). Also make sure you use a clamp to edge address/wrap mode.

I should also point out that if Ogre lets you control mipmap LOD bias, you might try a negative bias for the outline texture.

\$\endgroup\$

You must log in to answer this question.

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