Search code examples
androidtexturesopengl-es-2.0

OpenGl ES 2.0 putting a texture on a single face


I have a cube which I can render as a single colour or as a textured cube.

How would I texture just a single face and leave the rest of the cube a single colour

I have played about with the shader, I have also only included texture corrds for the first face.

Any ideas?


Solution

  • The basic answer is that you would have to create two separate meshes, one with a shader that renders a solid color, and one with a shader that renders a texture. And then draw each of them in separate draw calls.

    If you want to save yourself from an extra draw call and shader, you could create a texture atlas, where there is a small white area on the texture that you map to the solid color faces with appropriate texture coordinates, and then map the area with the image you want to the textured face.