I’ve rendered a scene into an FBO and then applied the texture directly to a geom::Cube with Cinders stock texture shader. Rendering the cube on top of the scene looks as follows:
My biggest surprise is that the texture is backwards on all sides. Is this normal?
I know that flipping the texture coordinate mapping would solve this, but I feel like mapping a the FBO texture directly on to a cube without fiddling with the texcoords would have the texture not be backwards?
It would seem that this is a lovely top-left v. bottom-left co-ordinate issue - i.e. unrelated to Cinder specifically. More details here:
I expect the easiest approach is likely to flip the texture coordinates in anticipation of the image being upside-down / reversed from a typical texture, in the renderbuffer. Will update when I have a final solution.
The temporary solution ended up being hard-coding some new texture co-ordinates when rotating textures, and flipping some to compensate for OpenGL’s interpretation of co-ordinates.
The code below shows one (semi-)hacky approach on how to do this. Note that the code assumes indexing for the surfaces it wants to rotate. A more robust solution, would detect the proper indices by observing the normals for the vertices and picking the 4 vertices matching a particular direction.
Hopefully this helps anyone else playing around with geom’s and TexCoords!