I'm having some difficulty trying to think of a way to do decals on objects that are rendered as polygonal shapes.. Just keeping a table of extra images to be rendered with the object doesn't seem right, the decals would go past the object shape.
Basically I want the decal to be somehow cut to whatever shape the object has, see the attached image.
Sorry if there's an obvious answer.I suspect there is, and a canvas would be involved, but I can't figure it out ..
Decals methods?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- slime
- Solid Snayke
- Posts: 3161
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Decals methods?
One way would go something like this:
It might not be very efficient if you have many polygons with decals, though.
Code: Select all
drawPolygon()
love.graphics.setStencil(drawPolygon)
drawDecal()
love.graphics.setStencil()
Re: Decals methods?
Yes, a stencil makes sense here. If you run inte performance issues, only render with the stencil once by rendering it to a canvas first, and then only draw the canvas to the screen. This will only work if these "decals" don't change every frame.slime wrote:One way would go something like this:
It might not be very efficient if you have many polygons with decals, though.Code: Select all
drawPolygon() love.graphics.setStencil(drawPolygon) drawDecal() love.graphics.setStencil()
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Decals methods?
Thanks, these made a lot of sense. I ended up with using one canvas per object, to which I render the splatter textures with the object's draw method itself as a stencil. As this happens only on collisions and shouldn't happen on many objects at once, it's not causing any problems performance-wise so far.
Maybe so many canvases is a bit of an overkill? They're not very large as a rule, though.
Maybe so many canvases is a bit of an overkill? They're not very large as a rule, though.
Re: Decals methods?
You can have quite a lot of canvases before you run into issues, even on integrated graphics. Especially if they're small.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests