You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
Putting decals (blood, bullet holes, etc.) is one thing (and there's plenty of previous threads about that), but how would you place a decal on a mesh? I'm making a space game, and when a missile or laser or something hits a ship, I'd like to show a blast mark there on a ship.
The best way I can think of doing this is to have a second texture that starts as completely transparent, then apply blast mark decals as needed. This texture could then be blended onto the final image using a shader. My current problems are
How would I control the size of the decals? The texture size can have nothing to do with the model size, so if I placed the same sized decal on two differently sized ships, the resulting final blast mark would be totally different sizes.
How would I get texture coordinates at a point? The collision manager allows you to ray cast to find a triangle and which scene node you collided with, but that's it. I saw an example in the DirectX SDK of the a DirectX picker that also gives UV coordinates of the collision point.
I know this is an extremely common effect (pretty much on any modern FPS to put blood on the characters). Does anyone know the common implementation?
I'd rather create new triangles (or better, quads) for decals and bind them to ship model position. This should work fine for all non-animated meshes. If you want to put your decals on animated models as well, you can try to bind your quads to the given triangle of your model.
But if I use a flat quad, wouldn't the decal, i.e. a scorch mark, look bad from a side angle? And making a copy of the local geometry of the mesh around the impact point sounds expensive.
slavik262 wrote:But if I use a flat quad, wouldn't the decal, i.e. a scorch mark
Well, right, but such flat quads are a very cheap for creation/rendering, they are used by eg Quake III engine, (altrough everything depends on the quality of effect that you want to achieve).
How does, say, Counterstrike Source or Team Fortress 2 do it? Blood decals regularly appear on the characters themselves and appear to wrap around the mesh, not just be a flat quad.
Bate wrote:Maybe you could use a second transparent texture layer and dynamically paint the bloodstains into it. Then just blend it with the color texture.
Sounds good in theory -- not sure how to actually get a specific region from the uv coords, though.
This was my original idea almost exactly, but like I said in my OP,
How would I control the size of the decals? The texture size can have nothing to do with the model size, so if I placed the same sized decal on two differently sized ships, the resulting final blast mark would be totally different sizes.
How would I get texture coordinates at a point? The collision manager allows you to ray cast to find a triangle and which scene node you collided with, but that's it. I saw an example in the DirectX SDK of the a DirectX picker that also gives UV coordinates of the collision point.
What i suggest :
-Write a decal scene node, which will be called each time you shoot, here is a site where can have more information on implementaing decals : http://www.flipcode.com/archives/Decals_Explained.shtml
-Add a bump and transparent layer to your decal scenenode, so it could be much more realistic.
Anyway, seems like the implementation would be rather difficult that way. Getting the uv coords of a point would be cool though (also in general). Do you think it would be possible to implement that "DX picker" you mentioned? I didn't stumble upon it yet.
Never take advice from someone who likes to give advice, so take my advice and don't take it.
@Bate I don't know how it would be possible in Irrlicht. Maybe the Devs have somtething to say about it?
@Iyad - I don't mind shaders - I'm using them heavily in my project. Your first link is just the quad surface I was talking about above - I'm leaning away from that. I looked at the second link, though and all it explains is how the lighting and coloring is done, not how the textures are actually applied.