Ok so the title doesn't properly explain what I mean.
So my game has a repeating stone texture, which is overlayed on it self at a bigger scale so that it's easier to see it when it's zoomed out, as well as giving it a distinct style.
However, as people were saying they were getting performance issues, I'm now using meshes instead of canvases to draw the rocks, and I'm unsure if there's an efficient way to achieve the same effect.
The best I can think of is drawing the mesh twice with the UVs changed, but I have a feeling there might be a better way.
Efficient way to apply two textures to the same mesh?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Efficient way to apply two textures to the same mesh?
I haven't done it before, but it's possible to use 2 different UV values with custom vertex attributes that you send to a shader.
Re: Efficient way to apply two textures to the same mesh?
I think that you need to make two meshes with alpha transparency and draw the both of them.
Re: Efficient way to apply two textures to the same mesh?
He's using the same texture, just different UV's. So it should be possible with only one mesh and a shader.
- slime
- Solid Snayke
- Posts: 3161
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Efficient way to apply two textures to the same mesh?
Even if you had multiple textures, you don't need multiple meshes for that because you can sample from multiple textures within the same shader.
Re: Efficient way to apply two textures to the same mesh?
You can give transparency as a vertex attribute right?
Dragon
Re: Efficient way to apply two textures to the same mesh?
Each vertex already has RGBA vertex color attributes that you can use.
Re: Efficient way to apply two textures to the same mesh?
You mean 2 different UV sets for multi texturing? I've never done it myself but I would search the web for GLSL shaders from others who have done multi texturing like light mapping or AO before and adapt it to Love2D.
Custom vertex attributes and how to use them, is explained in the Wiki.
But I think you don't even need a second pair of UV values, because you could probably just multiply the original UV coordinates with a scaling factor and mix the two resulting images together, inside of the shader.
You can find formulas to mix / blend images, similar to Photoshop blending modes, online.
Like I said, I've never done it before, so everything I said is just theoretical knowledge. But it sounds right
Custom vertex attributes and how to use them, is explained in the Wiki.
But I think you don't even need a second pair of UV values, because you could probably just multiply the original UV coordinates with a scaling factor and mix the two resulting images together, inside of the shader.
You can find formulas to mix / blend images, similar to Photoshop blending modes, online.
Like I said, I've never done it before, so everything I said is just theoretical knowledge. But it sounds right
Re: Efficient way to apply two textures to the same mesh?
Oh right, shaders , I just tried that and it worked super easily with my limited shader knowledge. I have no clue why I find it so hard to think of them to solve problems.UnixRoot wrote: ↑Mon Jun 19, 2023 6:57 am You mean 2 different UV sets for multi texturing? I've never done it myself but I would search the web for GLSL shaders from others who have done multi texturing like light mapping or AO before and adapt it to Love2D.
Custom vertex attributes and how to use them, is explained in the Wiki.
But I think you don't even need a second pair of UV values, because you could probably just multiply the original UV coordinates with a scaling factor and mix the two resulting images together, inside of the shader.
You can find formulas to mix / blend images, similar to Photoshop blending modes, online.
Like I said, I've never done it before, so everything I said is just theoretical knowledge. But it sounds right
Dragon
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 5 guests