2014/07/30

Cube mapping in iOS

When I was searching about offscreen rendering, I found a word ‘cube mapping’.
It looked very interesting, so I tried it.

You have to prepare 6 texture images as most of the tutorial webpages say.
And change your fragment shader like :
{
    highp vec3 ref = reflect(vPosition - eyePosition, vNormal);

    gl_FragColor = textureCube(uTexture, ref);

}
That’s all! This result is here :

torus drawn by cube mapping

This torus has 221,184 vertices. It needed more vertices to show more beautiful surface.
This was drawing at 60 fps in iPhone 5s, but about 35 fps in iPod touch (5G).
Develop | Comments(0) | Trackback(0)
Comment

管理者のみに表示