Hi,
I'm currently stuggling at displaying a polygon filled with a repeated texture, which is actually a quad of an image.
Here a quick sketch :
I suppose that a Mesh should be used...
Thanks!
Repeated texture inside a mesh
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- aloisdeniel
- Prole
- Posts: 17
- Joined: Sat Jan 30, 2016 5:57 pm
- Contact:
Repeated texture inside a mesh
My LÖVE libraries : pixelatlas, pixelmap
Re: Repeated texture inside a mesh
OpenGL doesn't expose means to use sub-texture as if it was the whole texture. One way of solving it is using a shader. The other way is to use a whole separate texture. Either way has same data bus overhead since both require an additional GPU draw call, the shader solution will be more computationally intensive to render. Lastly you can indeed use a mesh, but then you'll need to generate sub-quads in the whole thing and generate the whole thing from scratch if the texture coordinates have to move.
- aloisdeniel
- Prole
- Posts: 17
- Joined: Sat Jan 30, 2016 5:57 pm
- Contact:
Re: Repeated texture inside a mesh
Okay thanks!
I don't need dynamic texture coordinates : I think I'm gonna generate image from the area of the original sheet data with a new image ( I've a limited set of textures for these polygons) :
I don't need dynamic texture coordinates : I think I'm gonna generate image from the area of the original sheet data with a new image ( I've a limited set of textures for these polygons) :
Code: Select all
image = love.graphics.newImage( data)
My LÖVE libraries : pixelatlas, pixelmap
Re: Repeated texture inside a mesh
if you don't need a moving texture you can just set the u/v coordinates corretly and it should loop:aloisdeniel wrote:Okay thanks!
I don't need dynamic texture coordinates : I think I'm gonna generate image from the area of the original sheet data with a new image ( I've a limited set of textures for these polygons) :
Code: Select all
image = love.graphics.newImage( data)
Code: Select all
0
.-------1,2
\ \
\ 5,4 ...3
0: Xs, Ys
1: Xl, Ys
2: xs, Ys
3: Xl, Yl
4, Xs, Yl
5: Xl, Yl
Xs/Ys is the top left corner of your texture quad (normalized) and Xl/Yl is the lower-right corner.
Note how you need two vertices (insert two at every texture end) to loop around the texture since you can't go out of range to wrap like with a seperate texture (:setWrapMode).
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot], Semrush [Bot] and 4 guests