OpenGL Tutorial

http://www.opengl-tutorial.org/

このサイトの OpenGL チュートリアルが結構よさそうだったので、グラフィックスの勉強を再開するために読んで試しています。

version 3.3 以降の OpenGL についてのチュートリアルらしいです。 サンプルのソースコードもばっちりあるのでありがたいです。

ただいま Tutorial 5 : A Textured Cube なのですが、DXT 圧縮のテクスチャのピクセルを反転して使う方法ってなにがあるんでしょう。

DXT compression comes from the DirectX world, where the V texture coordinate is inversed compared to OpenGL. So if you use compressed textures, you’ll have to use ( coord.v, 1.0-coord.v) to fetch the correct texel. You can do this whenever you want : in your export script, in your loader, in your shader…

DXT 圧縮は Windows の世界からきたから、OpenGL では UV の V を反転させて使わないとらしいですが、

  • シェーダで V を反転させる

くらいしかわかりませんでした。 これだと、他のテクスチャと合わせて使うのがめんどくさくなるので、テクスチャをロードする時点で反転させられないかなーと調べましたが、見つかりませんでした。

WebGL だとあるようです。

http://www.khronos.org/registry/webgl/specs/latest/

UNPACK_FLIP_Y_WEBGL of type boolean
    If set, then during any subsequent calls to texImage2D or texSubImage2D, the source data is flipped along the vertical axis, so that conceptually the last row is the first one transferred. The initial value is false. Any non-zero value is interpreted as true.