How to use GL_REPEAT to repeat only a selection of a texture atlas? (OpenGL)

前端 未结 6 1783
臣服心动
臣服心动 2021-02-12 19:00

How can I repeat a selection of a texture atlas?

For example, my sprite (selection) is within the texture coordinates:

GLfloat textureC         


        
6条回答
  •  故里飘歌
    2021-02-12 19:30

    While this may be an old topic; here's how I ended up doing it:

    A workaround would be to create multiple meshes, glued together containing the subset of the Texture UV's.

    E.g.: I have a laser texture contained within a larger texture atlas, at U[0.05 - 0.1] & V[0.05-0.1].

    I would then construct N meshes, each having U[0.05-0.1] & V[0.05-0.1] coordinates. (N = length / texture.height; height being the dimension of the texture I would like to repeat. Or easier: the amount of times I want to repeat the texture.)

    This solution would be more cost effective than having to reload texture after texture. Especially if you batch all render calls (as you should).

    (OpenGL ES 1.0,1.1,2.0 - Mobile Hardware 2011)

提交回复
热议问题