0

When rendering an equirectangular encoded 360 texture, there is usually a lookup like

u = atan(x,z)
v = acos(y) 

The equirectangular texture is already very prefiltered. Just turning on mipmaping does not work. u is not continuous and the texture itself has non uniform data in uv. And creating mipmaps with a 2x2 box downsample is also not right for the equirectangular.

But assuming the 2x2 box for miplevels, and hardware mipmap lookup, is there a good way to compute either lod or gradients that makes any sense?

Using just dFdx(v) and dFdy(v) kind of works to handle small viewports. But there must be a better way?

Yakov Galka
  • 70,775
  • 16
  • 139
  • 220
starmole
  • 4,974
  • 1
  • 28
  • 48

1 Answers1

1

You can generate the mipmaps with glGenerateTextureMipmap() function and use the texture(tex, uv) lookup function. It will already do the job.

You should, however, normalize the uv coordinates so that they are in the [0,1] range:

u = atan(x,z)
v = acos(y)
uv = uv/6.283185 + .5
Yakov Galka
  • 70,775
  • 16
  • 139
  • 220
  • I left normalization out - it does not matter for derivatives. Just turning on mip maps like that does not work. That's the question :) glGenerate will just do a 2x2 box filter. But eqirect is already pre filtered. – starmole Apr 29 '17 at 02:21
  • @starmole: did you try that? Why it doesn't work? What do you mean by saying that your texture is already prefiltered? Don't you just load it as a 2d raster image? Can you post a sample file? My approach will definitely work for the sample file you linked -- it doen't matter if it's 'eqirect', 'webmerc' or 'lambcyl'. – Yakov Galka Apr 29 '17 at 07:00