2

このコード行で自動的に生成されたミップマップで得られた品質に完全には満足していません:

glTexParameterf(GL10.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL10.GL_TRUE);

ゲームで使用されるすべてのテクスチャに対して、テクスチャのさまざまなスケーリングされたバージョンを (Gimp を使用して) 作成することを考えました。たとえば、ボールのテクスチャの場合、次のようになります。

ball256.png 256x256 ピクセル

ボール128.png 128x128ピクセル

ball64.png 64x64 ピクセル

ball32.png 32x32 ピクセル

ball16.png 16x16 ピクセル

1.いい考えだと思いますか?

2.これらすべての画像から 1 つのミップマップ テクスチャを作成するにはどうすればよいですか?

4

1 に答える 1

6

This is not only a good idea, but it is a pretty standard practice (particularly in Direct3D)!

OpenGL implementations tend to use a standard box filter (uniformly weighted) when you generate mipmaps. You can use a nice tent fiter (bilinear) or even cubic spline (bicubic) when downsampling textures in image editing suites. Personally, I would prefer a lanczos filter since this is going to be done offline.

You may already be aware of this, but Direct3D has a standard texture format known as DDS (Direct Draw Surface) which allows you to pre-compute and pre-compress every mipmap level at content creation time instead of load-time. This decreases compressed texture load time and more importantly allows for much higher quality sample reconstruction during downsampling into each LOD. OpenGL also has a standardized format that does the same thing: KTX. I brought up Direct3D because although OpenGL has a standardized format very few people seem to know about it; DDS is much more familiar to most people.

If you do not want to use the standardized format I mentioned above, you can always load your levels of detail one-at-a-time manually by calling glTexImage2D (..., n, ...) where n is the LOD (0 is the highest resolution level-of-detail). You would do this in a loop for each LOD when you create your texture, this is actually how things like gluBuild2DMipmaps (...) work.

于 2013-11-13T02:16:20.813 に答える