<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Helen on Medium]]></title>
        <description><![CDATA[Stories by Helen on Medium]]></description>
        <link>https://medium.com/@hlngncy?source=rss-6acc84698fcc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nRYwDMp6tM497lTNbXz8PA.jpeg</url>
            <title>Stories by Helen on Medium</title>
            <link>https://medium.com/@hlngncy?source=rss-6acc84698fcc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:43:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hlngncy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Solving Weapon Clipping Issue on HDRP]]></title>
            <link>https://medium.com/@hlngncy/solving-weapon-clipping-issue-on-hdrp-ad1c235f9386?source=rss-6acc84698fcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad1c235f9386</guid>
            <category><![CDATA[rendering]]></category>
            <category><![CDATA[hdrp]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[fps]]></category>
            <dc:creator><![CDATA[Helen]]></dc:creator>
            <pubDate>Sat, 10 Feb 2024 14:58:51 GMT</pubDate>
            <atom:updated>2024-02-10T14:58:51.295Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/619/0*ff7uN_USEzHJtSvw.PNG" /></figure><p>The classic issue in making an FPS game is the weapon clipping problem, where the weapon or arms penetrate other meshes.</p><p>The first solution that comes to mind is a dual-camera system: one camera for rendering first-person arms and weapons, and another camera for rendering the environment. However, in the case of using the High Definition Render Pipeline, this solution is not feasible because HDRP does not support camera stacking. As a result, most camera-related solutions will not work properly for this case.</p><h3>So what we can do about this problem?</h3><p>When I experienced this issue, I wasn’t in a position to handle it with a custom shader or animation to raise the weapon when the player gets too close to walls. The solution I found for my case was much easier and more efficient: using a Custom Pass.</p><h4><strong>What is Custom Pass?</strong></h4><p>Custom Pass is a flexible and powerful feature that enables developers to inject their own rendering logic into the rendering pipeline. This capability allows for the creation of custom effects, optimizations, or any other rendering functionality not provided out-of-the-box by HDRP.</p><p>In our case, Custom Pass allows us to inject the rendering of arms and weapons after rendering the environment meshes. With this approach, weapon clipping is no longer an issue.</p><h3>Application</h3><p><strong>On your scene, create Custom Pass volume:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/0*kOKm8AT-NcefEA2z.gif" /></figure><p><strong>Add Two Draw Renderers Custom Pass and configure:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*eQeMKKJGN2fxTSzR1pJJJw.png" /></figure><p><em>Configurations:</em></p><ol><li><em>With the injection point, we essentially determine when to apply our custom passes.</em></li><li><em>With the layer mask on the custom pass, we decide which layer to affect. In our case, it is the weapon and arms layer.</em></li><li><em>The first custom pass is for rendering our weapon and arms at the front, overriding depth.</em></li><li><em>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.</em></li></ol><p><strong>Remove layer of weapon and arms from culling mask of camera:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*rsn41MXcnTO9I7_4crV2hg.png" /></figure><p>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.</p><h3><strong>Things You Should Consider</strong></h3><h4>Contact Shadows</h4><p>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.</p><p>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.</p><h4>Shaders on Environment</h4><p>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.</p><h4><strong>VFX’s Related to Weapon</strong></h4><p>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.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad1c235f9386" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>