0

I have a texture which is a grid of smaller textures and which I am not able in this application to split into individual files. I need to tile these subtextures over a model.

Splitting the geometry could work, but would increase scene complexity and potentially introduce visual artifacts if thin triangles are generated.

Allocating new textures copied from the original at runtime could work, but would increase texture-memory usage and would involve stale data if the primary texture changes (which I cannot detect in this application).

If there really is no way to directly bind a subtexture to allow OpenGL tiling to work, what would be the next best way to do it?

JAKJ
  • 289
  • 1
  • 4
  • 14
  • You could use a fragment shader program to translate texture coordinates into a lookup of the subtexture. – MvG Aug 14 '12 at 21:25
  • That seems like massive overkill and might interfere with the application's existing rendering pipeline, unless there is a simple way to do this one specific thing in isolation. – JAKJ Aug 14 '12 at 21:32

1 Answers1

1

If you need to do this, the correct way is to use a fragment shader to tile your texture coordinates directly.

That seems like massive overkill and might interfere with the application's existing rendering pipeline

The only way it would interfere is if you're not using fragment shaders. And if you're not... you should be.

Modern hardware design doesn't generally add fixed functionality anymore; it's all about giving shaders more power and options. If you need a feature, "code it in a shader" is generally the correct solution.

But if you're not allowed to use shaders, the only alternative is to modify your geometry, as you suggested.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • I suppose it's worth a shot, then, to see if such a thing can be added to the application without gumming up the works. I would appreciate if you could provide a more-directed starting point than can Google, as I doubt I truly have the time and resources right now to learn the entire shader subsystem for this one problem. – JAKJ Aug 15 '12 at 02:33
  • @JAKJ, there is a tool called [ShaderGen](http://www.mew.cx/glsl/shadergen/) which auto-generates shader code to duplicate the workings of the fixed functionality pipeline. Lacking a suitable Windows install, I've never actually used it myself, but it might be worth a try as a starting point. – MvG Aug 15 '12 at 08:08