two really big problems with decals

Blitz3D Forums/Blitz3D Programming/two really big problems with decals

1. When you load your decal, enable UV clamping. Make sure the edges of the decal are transparent if you are using a decal with an alpha map, or black, if you are using a decal you want to multiply with what is behind it.

2. For each triangle that falls within the decal, copy that triangle to a new mesh or a new surface within your terrain mesh.

3. Set the texture coordinates for the triangle. If the trangle falls partially outside your decal region, then your coordinates might be less than 0, or greater than 1. Pretend that the decal tiles.


The UV clamping ensures that the decal will NOT actually appear to tile. And if you have a lot of small triangles in your terrain, then it won't really matter if you have a little extra area being textured with an invisible texture.


Where you really need to worry about clipping the triangles so they fit the region exactly is when you have a large flat wall in a first person shooter and you want to put a scorche mark or shadow on that. Then you'll get a lot of overdraw form the extra invisible areas, and you don't want that.

I made a clipping system which can handle clipping polygons so you can do very precise decals with no overlapping stuff. It's free, and you may request it from me via email, but it's very advanced. If you don't know what a plane equation is, then you might not be able to figure it out. I don't want to be proividing lots of support to everyone, but I will answer a question or two. It's a real nice system though.

[edit]
I see you know aobut that UV clamping method... Well, you're free to use my lib if you want. It does "sutherland-hodgeman clipping". It is the fastest clipping algorithm out there and very robust. It'll do what you want if you can figure out how to set up the clipping planes. I'll step you though the basics if you need me to.
[/edit]

[edit2]
Oh and btw... The system will automatically build your new polygons for you, and set the UV coordinates as needed based on the originals.
And you could use a decal of any shape with any number of sides.
[/edit]