What about Decals?

Blitz3D Forums/Blitz3D Programming/What about Decals?

RustyKristi(Posted 2015) [#1]
Hey guys,

I'm looking into old archives and topics and one thing I have noticed is that there are a few discussions or demos about decals. I'm sure B3D (B+ or BMax too) has a very broad array of techniques dealing with 'hands on' graphic stuff, but I seldom see (or none at all) some decent decal tests or examples.

So my questions are:

1) What is the best way to use decals? is it from scratch using quads?
2) Are there functions to manage decals? like time to live or something more in detail?
3) Any demos that are hidden somewhere that I missed searching for a good decal implementation?
4) Any previous libraries (dll or pure blitz) contributed that can still be used in production for a blitz game?


RemiD(Posted 2015) [#2]
I would use a textured quad mesh.
If you plan to have only a few "decals", you can use separate pivots for the positition/orientation and copyentity() for the mesh/texture.
If you plan to have many "decals", a single surface system may be more appropriate, like for particles.

There are several examples in the Blitz3d examples and in the code archives...


RemiD(Posted 2015) [#3]
Also one tip is to firstly oriente the quad so that it faces the same direction than the normal of the picked/collided triangle, and then move it slightly forward (+0.01) so that it prevents zorder problem when the camera is far away.


Yasha(Posted 2015) [#4]
Never really thought about this before, but aren't decals really just particles that never move? You could use a generic particle system and set all animation properties to zero (find one that lets you disable camera-facing), and it would then manage surfaces and lifetime for you the same way it does for other effects.


RustyKristi(Posted 2015) [#5]
Thanks guys for the these info.

@RemiD
I guess I will have to try with the 0.01 position, I was hoping that I could find a good example where I can see it in action.


Never really thought about this before, but aren't decals really just particles that never move? You could use a generic particle system and set all animation properties to zero (find one that lets you disable camera-facing), and it would then manage surfaces and lifetime for you the same way it does for other effects.


Yes, technically and almost all 3D engines as of date provides a decal system to manage decals one form or another. I'm not surprised this was not updated as I see most system can be written directly in blitz without the need of 3rd party libraries.


Rroff(Posted 2015) [#6]
The problem with decals is handling how they work when the decal tris span geometry that isn't all nicely aligned with the impact point. Some games simply clip the decal so that it doesn't extend outside of the tris of the impact point others use a variety of techniques to match them to the surface via sub-division, etc. also there is the consideration of moving objects/geometry and whether they will happen on impact with stuff that can move and how they are parented to it.

I'd also use some kind of single surface system for them rather than having every instance of a decal its own surface. For stuff like bullet impacts, etc. that happen at run time you may want some kind of management system to delete the oldest ones after X time or after a certain number have been created.


RemiD(Posted 2015) [#7]

I'd also use some kind of single surface system for them rather than having every instance of a decal its own surface.


Not sure about that. Copyentity is pretty fast and can probably prevent zorder problem if the decals are far apart...
If depends on how many you want to display.


Rroff(Posted 2015) [#8]
Copyentity itself is fast enough but when your shovelling to the graphics card to render you can encounter a few things like gpu fillrate issues if you aren't using batching type techniques - if necessary you can use multiple surfaces spread out over the game world to reduce any potential ordering issues. Does depend a lot how many you want to use.


Volturna(Posted 2015) [#9]
I'm starting to work on decals in my spaceship project. I want to give player the ability to draw text or symbols in the hull.

So far i've something similar already implemented but its a static mark randomly placed over the hull. I've used brushes with blended textures and it works fine without the z-order problems that you will probably have with quad texture meshes.


RemiD(Posted 2015) [#10]
@Volturna>>If by "brushes with blended textures" you mean that the decals are directly painted on the texels of the texture (or on a texture blended on top of the color texture), that's a way to do it, but the difficulty in this case is to have all meshes (surfaces) unwelded, texelsfilled, uvmapped, in a way that the texel size is uniform (similar to "lightmapping"), else this will look bad...


Volturna(Posted 2015) [#11]
I did it by blending a base texture (hull) with another texture (with alpha), but i did it because all the model is made of 'cubes' with 6 facse so its simple to achive that effect. http://www.blitzbasic.com/Community/posts.php?topic=104839


Now i'm trying to do decals with free placement but the problem is the z-order and the limits of the face to draw.