Wodo
3 min readFeb 13, 2024

--

How to Fix Weapon Clipping in FPS Games?

Overcoming Weapon Clipping in FPS Games: A Creative Solution

In the realm of first-person shooter (FPS) game development, a pervasive challenge that often vexes developers is the issue of weapon clipping. This occurs when the in-game weapon or character’s arms intersect or penetrate other game objects or the game environment itself, breaking immersion and affecting the player’s experience.

Traditionally, developers might lean towards a dual-camera setup — one dedicated to rendering the first-person arms and weapons, and another for the environment. However, this method hits a snag within the confines of the High Definition Render Pipeline (HDRP), as HDRP’s architecture does not support the stacking of cameras. This limitation necessitates a more innovative approach to circumvent the clipping conundrum.

Introducing the Custom Pass Solution

When faced with the clipping challenge, our team discovered a remarkably straightforward yet effective solution: the utilization of a Custom Pass. Custom Passes are a testament to the flexibility and power of HDRP, offering developers the means to inject bespoke rendering logic into the pipeline. This functionality is not just limited to creating unique visual effects or optimizations but extends to resolving common issues such as clipping.

Wodo Gaming’s young and talented game developer Helen Şevval Gençay shared the solution with the game development world.

Application

On your scene, create Custom Pass volume:

Add Two Draw Renderers Custom Pass and configure:

Configurations:

  1. With the injection point, we essentially determine when to apply our custom passes.
  2. With the layer mask on the custom pass, we decide which layer to affect. In our case, it is the weapon and arms layer.
  3. The first custom pass is for rendering our weapon and arms at the front, overriding depth.
  4. The second custom pass is for achieving depth on our arms and weapon. Otherwise, the back and front faces of them will be rendered at the same level of depth.

Remove layer of weapon and arms from culling mask of camera:

And voila! Now your player’s arms and weapon will not clip with other objects. But it may not end here. In some cases, depending on your project, some rendering issues might occur.

Things You Should Consider

Contact Shadows

In case you are using contact shadows, this setup can cause problems. The contact shadows will be rendered in front of your weapon and arms. To address this, you can override the custom pass’s execute function to ignore contact shadows. However, this requires you to learn more about custom passes.

If you prefer a simpler solution, you can disable contact shadows by going to your scene’s light source and disabling contact shadows in the shadows section.

Shaders on Environment

If you are using shaders other than the built-in ones, this can create another problem. Make sure that you have checked your shader’s rendering pass and configured the custom pass or shader to achieve the desired rendering order.

VFX’s Related to Weapon

You may face issues with the appearance of your muzzle flash or any related VFX attached to your weapon and arms. Even if the layer of the VFX objects is not the same as your weapon and arms, they might still be affected.

About the author: Helen Şevval Gençay’s
See the original article:

Solving Weapon Clipping Issue on HDRP

--

--

Wodo

Wodo Gaming is an open-source platform where gamers and game developers come together to develop next-generation techs and blockchain games.