is there a way to tile a texture in a cube geometry, like with WrapMode.Repeat and scaleTextureCoordinates(X,Y), but instead of tiles with the same width and height, irregular tiles like these?
Tiles from a specific column have the same width, and tiles from a specific row have the same height.
I need to do this at runtime, I cannot create the texture previously, I have the texture of a simple tile.
can you modify the TexCoord parameters in your code? with that it’s simple to do, just generate a nonregular, ever increasing sequence. Maybe others have better solutions.
In my code i know how many rows and columns the texture needs and the width and height of every specific tile
for regular tiles I was using the scaleTextureCoordinates(X,Y), where I pass the number of columns and rows, but how do I specify the width and height of every column and row?
hmm… maybe I misunderstood your usecase…
But you always have the chance to generate the final texture from you base texture on the fly using a BufferedImage for example (not available on Android though AFAIK), and it’s not really that hard and does not cost much in speed, if you don’t need to recalculate the widths every frame.
Ok, I’ll try to do it that way. I was hoping there was an option of setting the texture coordinates buffer or something like that.
thanks for the answers!
misunderstand again, sorry
of course you can set the texture coordinates buffer, that was my first solution about, I just called it TexCoords (I did not remember it was a buffer in code). What type of Geometry are you trying to apply this texture on?
I suggest using a custom shader, since with texcoords you need vertexes at every possible position where the pepeating happens else, while in the shader you can do that calulcation in the fragment shader.
(just give it like 6x6 uniforms where you set the respective size in 0-1 range)
It is a cube. If I wanted to repeat the texture 4x4, knowing every column is not a 25% of the total width, but for example 10%, 20%, 30% and 40% of the total width, how can I specify the texCoords?
I’m quite inexpert on shaders, I suppose I should read all the tutorials but is there a base to start with this?
for a cube you should go the shader way, as suggested, cause it does not have enough texture coords for you to use.
you can find some info on the tutorials page under Materials, Light, Shadow. And you can also take a peek at the builtin materials for reference.