I've actually encountered an interesting dilemma to solve in my project that relates to lighting: determining if the player is obstructed by shadow for stealth mechanics. The traditional ways I've discovered generally involve sampling a clipped area of the scene where the character is, often in a layer only including character models and obstacles, which is squashed using bilinear filtering to a single 1x1 pixel, and the overall brightness value in a colorspace like HSV is then taken to determine if the player is shaded enough to avoid detection. Doing this every frame is too expensive, though, and to make the game feel a bit more fair to the player this check is done less frequently. Some algorithms check a randomly chosen pixel instead, and when enough of these checks have found the player to visible and in enough light in a consistent sequence, maybe the player is finally detected. While this sounds slow on paper, in practice it's very quick and can emulate an npc determining if his eyes are playing tricks on him. And this trick might work for a single player game, but what about multiplayer and online environments? Anyway, this introduces overhead unique to stealth games, like using multiple cameras and combine them into the visuals the game uses just to be able to do this kind of stealth detection.. But I feel like there's got to be a hidden elegant way of solving this dilemma that we haven't considered. Attacking the issue from the GPU side of things, I could imagine one solution may lie in cleverly using custom compute shaders and digging into modifying our rendering pipeline. Another angle, from the CPU perspective, might be greatly simplifying the way light interacts with the game world in a more stylized manner. Perhaps geometric shapes usesd similar to collision areas are designated for being lit or obstructed by shadows. It's an interesting problem and I'd love to see your take on it.
Hey, First I will be very honest with you that I never developed any sort of stealth mechanism so I cannot point you to the best approach. However I will tell you how I would approach the problem. I would first define the detection range for NPCs. If my player is within that range only then I would check the complex detection conditions. Obviously the more complex I make the stealth system the more conditions and overhead will be introduced. Once I am satisfied with the mechanic I would perform a stress test on my targeted platform. Sure it will cost me more time and/or money but I have to pay that price for my limited experience. So let's say I have setup the test where my player is within the detection range of 10 NPCs. So the detection logic would run simultaneously and I will monitor how heavy it is. Depending on the result I will move forward. Let's say the results were not so great. Now I have to decide how much time I should invest to optimise my stealth mechanism. Let's say I decide to invest 2 weeks. After that I would perform another stress test. Only to find out 10% improvement. At that point I have to acknowledge that at the given moment this is the best mechanics I can do. Then I will solve the performance issue from the game design perspective. E.g. I will make sure that in my entire game, at max only 4 NPCs could detect the player simultaneously. Therefore my advice is not to fall into "could have been better" trap. Like you could develop the best system on the planet but that too could have been better. So evaluate cost and returns first. As for multiplayer, it depends how complex my stealth mechanism is. Based on that I have to decide where should I run the NPC logic? On the server or client? Server is generally better to fight against potential cheating. But If that requires passing 10 megabytes of data every frame(server tick) to clients then I have to evaluate if I could get away with running the NPC logic client side.
@@iDigvijaysinhG I really want to upload videos on game development , but I am stuck in tutorial hell of Vulkan. You can see my last community post on why I want to learn Vulkan.
I've actually encountered an interesting dilemma to solve in my project that relates to lighting: determining if the player is obstructed by shadow for stealth mechanics.
The traditional ways I've discovered generally involve sampling a clipped area of the scene where the character is, often in a layer only including character models and obstacles, which is squashed using bilinear filtering to a single 1x1 pixel, and the overall brightness value in a colorspace like HSV is then taken to determine if the player is shaded enough to avoid detection.
Doing this every frame is too expensive, though, and to make the game feel a bit more fair to the player this check is done less frequently. Some algorithms check a randomly chosen pixel instead, and when enough of these checks have found the player to visible and in enough light in a consistent sequence, maybe the player is finally detected. While this sounds slow on paper, in practice it's very quick and can emulate an npc determining if his eyes are playing tricks on him.
And this trick might work for a single player game, but what about multiplayer and online environments?
Anyway, this introduces overhead unique to stealth games, like using multiple cameras and combine them into the visuals the game uses just to be able to do this kind of stealth detection..
But I feel like there's got to be a hidden elegant way of solving this dilemma that we haven't considered.
Attacking the issue from the GPU side of things, I could imagine one solution may lie in cleverly using custom compute shaders and digging into modifying our rendering pipeline.
Another angle, from the CPU perspective, might be greatly simplifying the way light interacts with the game world in a more stylized manner. Perhaps geometric shapes usesd similar to collision areas are designated for being lit or obstructed by shadows.
It's an interesting problem and I'd love to see your take on it.
Hey,
First I will be very honest with you that I never developed any sort of stealth mechanism so I cannot point you to the best approach.
However I will tell you how I would approach the problem.
I would first define the detection range for NPCs. If my player is within that range only then I would check the complex detection conditions.
Obviously the more complex I make the stealth system the more conditions and overhead will be introduced.
Once I am satisfied with the mechanic I would perform a stress test on my targeted platform. Sure it will cost me more time and/or money but I have to pay that price for my limited experience.
So let's say I have setup the test where my player is within the detection range of 10 NPCs. So the detection logic would run simultaneously and I will monitor how heavy it is.
Depending on the result I will move forward.
Let's say the results were not so great. Now I have to decide how much time I should invest to optimise my stealth mechanism.
Let's say I decide to invest 2 weeks. After that I would perform another stress test. Only to find out 10% improvement. At that point I have to acknowledge that at the given moment this is the best mechanics I can do. Then I will solve the performance issue from the game design perspective. E.g. I will make sure that in my entire game, at max only 4 NPCs could detect the player simultaneously.
Therefore my advice is not to fall into "could have been better" trap. Like you could develop the best system on the planet but that too could have been better. So evaluate cost and returns first.
As for multiplayer, it depends how complex my stealth mechanism is. Based on that I have to decide where should I run the NPC logic? On the server or client? Server is generally better to fight against potential cheating. But If that requires passing 10 megabytes of data every frame(server tick) to clients then I have to evaluate if I could get away with running the NPC logic client side.
@ Thanks for the honest and thoughtful response
it's NVidia RTX 😂
😅 on a side note, I have glanced at your channel today. Why did you stop uploading?
@@iDigvijaysinhG I really want to upload videos on game development , but I am stuck in tutorial hell of Vulkan. You can see my last community post on why I want to learn Vulkan.