Sign in to follow this  
Medo Mex

Bullet Impact on Mesh Edge

Recommended Posts

This is how i do it, with help of physic library that i use, this is for static meshes, with dynamic it would be a bit different (never had time to try that also):
1. Get impact/hit point and face normal on that mesh
2. Create AABB based on decal size and that point
3. Get triangle list from AABB intersecting that mesh (in my case NewtonTreeCollisionGetVertexListTriangleListInAABB function)
4. Clip that triangles with AABB (search Sutherland-Hodgman algo for that), before that you could skip/discard triangles that are dot(hitFaceNormal, currentFaceNormal) < threshold
5. Generate uv coords, this i can't get right for now
6. Done

Edited by belfegor

Share this post


Link to post
Share on other sites

I know that he uses forward renderer, but i am interseted in other techniques for deferred one, and i see you have something interesting to write about that, so please share. biggrin.png

 

I'm curious as well.

 

At one point I was dealing with a game what had highly detailed meshes used for rendering and exceptionally simplified meshes used for collision.  This meant the normal solution of projecting and clipping your decal against the collision geometry resulted a decal that was rarely consistent with the topology of the rendered object.  Obviously you can solve this by giving your decal system access to the render geometry for the purposes of projecting and clipping but this wasn't practical; the computational geometry code wanted triangles in a specific format that didn't mix well with rendering so there was a huge memory overhead.  Our render was deferred which meant easy access to the depth buffer and a normal buffer, for this reason the decision was made to render decals as boxes and use various tricks in the pixel shader to create the illusion of decals being projected onto the scene.  Essentially UV coordinates would be tweaked based on the result of a ray cast.  It worked fairly well but had some view dependent artifacts (sliding) that were distracting if you zoomed in on and rotated around a decal that had been projected onto a particularly complicated depth buffer topology.  There was also the issue of two dynamic objects overlapping, if one of the objects had a decal stuck to it in the region of the overlap the decal would appear on the other object; this only happened when the collision response was faulty so it wasn't that big a deal.

 

Anyway, waiting for Hodgman's insight...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this