Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 26th Feb 2023 12:49
Hey everybody,

I was wondering how you would approach a 3D decal system for things like bullet holes, blood, footprints or other kind of imagery that is overlayed on 3D faces.

Any suggestions are very welcome!

Thanks
Regards Sph!nx
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 27th Feb 2023 19:31
There are four ways i can think of right now:
1. Easiest way is to just get the normals of the surface using for example GetObjectRayCastNormalX ect and place a plane/particle with some transparency there but isn't very accurate.
2. Then you could actually draw onto the texture the object is using wich involves a bunch of math, memblocks and would take up to much memory when using it for bullet holes but is very flexible.
3. Doing a part of number 1. but doing some memblock manipulation so the decal goes around corners.
4. The best method would probably be to create a decal shader that you pass the depth and bullet hole image wich then projects the bullet onto the surface.
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 27th Feb 2023 20:14
Thanks janbo!

I can see myself doing option 1. The other options are a bit out of my league, I'm afraid, but I will explore the other options as well.
Regards Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 28th Feb 2023 16:30
Just a thought, I might purchase the appgamekit shader pack for this, but could the forcefield shader be modified somehow for this purpose?

Regards Sph!nx
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 3rd Mar 2023 18:40
While you need a depth render and the projection part of the shield shader it's still alot to do to change it to a decal shader.
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 11th Mar 2023 13:54
Hmm, yeah I can imagine. I think I will use flat objects (instanced) and limit myself to use it on single, flat faces only. Hmmm...
Regards Sph!nx
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 13th Mar 2023 11:12
There are usually multiple ways to produce a given "Effect" within games...
Typically, you can produce a near perfect representation of an effect as it would appear in real-life., but the problem is performance and complexity.

As such many things are streamlined for Real-Time (30Hz / 33.32ms or better) that Games are required to hit to be Playable.
So, what happens is an Approx. approach is used instead that is more Real-Time Performance Friendly and easier to implement.

Sure... Real-Time Projection is going to produce a more accurate result, and on modern hardware isn't too demanding performance wise.
Still the problem of it being a relatively "complex" approach is still there., especially for those new to programming or lack education in Advanced Mathematics.
Don't get me wrong., I will ALWAYS recommend programmers learn Advanced Maths; or at the very least have Math Is Fun or Wolfram Mathworld saved in your favourites.
So, you can either learn the maths behind what you want to do... or jog the old grey matter.

Still, the thing is... Gamers aren't exactly the most observant people.
Remember their focus is usually going to be more on the gameplay., so you can get away with a lot of Smoke & Mirrors to fool them.
The trick isn't to be accurate but minimise anything that might break the illusion.

Let's take Decals as an example here.
A Gamer isn't going to notice that a Bullet Hole Decal hasn't appeared in a perfect Ray from where they've shot... it just has to be "Close Enough", where-as if it is Floating with a Clear Gap to the Surface OR is only partially showing...
Yeah... that they're going to notice as it will instantly break their suspension of disbelief.

As such., we don't have to worry about a perfectly accurate portrayal; instead what we can do is say "If the Ray cast from the Shot is ON a Given Surface... then that's where we place and align the Decal Plane and we keep it within the bounds of said surface.
If we also add some randomness (Rotation and Size) to the Decal Plane, and remember said randomness doesn't have to be BIG; actually it's better if it's subtle; well this adds to the believability of the illusion.
Life is imperfect, and as weird as it sounds; we have to add this imperfection into our approaches because a computer is generally going to produce a perfect result.

If I had the time right now... I'd mock up what I mean in an example.
Still, I will say that most of the time., this is what game development ends up being about; figuring out ways to fake something to be believable.
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 13th Mar 2023 11:56 Edited at: 13th Mar 2023 11:57
Thanks Raven! Yeah, these systems do not need to be super realistic. You descibe something I was thinking about. Simple raycast that would create a flat faced object. There would be a maximum allowed number of decals and when that is reached, the oldest gets deleted when a new one is created.

I'll post my findings when I get there!
Regards Sph!nx

Login to post a reply

Server time is: 2024-04-27 00:30:40
Your offset time is: 2024-04-27 00:30:40