How to Fix Weapon Clipping in Unity
Вставка
- Опубліковано 20 лип 2021
- I was messing around with this little FPS that I have apparently started writing - and I came across a clipping issue, whereby walking into an object causes half the weapon to disappear. So I wanted to see how to the Unity team solved this issue, and having a look at Unities FPS Microgame it seems they took the approach I explained in the video.
___________________________________________________
Subscribe: / @tvtig
____________________________________________________ - Наука та технологія
If this isn't working for anyone, your project might be using URP (Universal Render Pipeline). If this is the case, you need to set the weapon camera "Render Type" to "Overlay", and then on the main camera, under "Stack", click + under the cameras tab, and add the overlay weapons camera to the stack.
God send thank you.
Thank you.
where you find this option?? its not anywhere in the inspector of cam
You're a fucking legend dude! Thank you so much!
Thank youuuu, you save me from working on a scrpt to fix it
im on unity 2020.3.31f1, set the weaponcam clear flags to depth only for it to work
i did this and it showed up in the little window in the editor but when i went to play the game, it didnt show up. and when i exited, it was no longer in the window in the preview.
Thank you!!
This one solved my problem thanks
thank you
ur a god thx
good ol' smoke and mrrr
Lol at least I know you watch right till the end.
i dont see Background Type in the camera settings. where is it?
Thank you.
Thank you so much its working fine!
if it renders only one of them - make sure to adjust the depth of the weapon cam so they are not the same
Old video I know, but is there anyway to make this work for HDRP?
Short and clear.
Yeah, it's a classic solution. The problem is that the weapon will not receive any shadows from the world, as the world geometry is on another layer (
Players won't care about that honestly, they'd lose the immersion if the weapon was clipping
@@stylie473joker5 Cascade shading really adds detail as probelit is too basic. I'm sure there's a better solution to this problem, it's not just clipping vs this.
@@redragon1229 I found a solution in HDRP i'm using two Custom passes to draw the weapon on top of everything while still keeping post processing and other details (as always remove the weapon layer from the camera and add it to the passes to make them render only the weapon), the depth test of one of the passes has to be set to "Always" while the other to "Less equal", and sorting to "Everything" for both; also the injection point has to be "After opaque depth and normal" or SAAO will render on top of the weapon when the weapon is on top of an object with SAAO.
I don't know if this method is perfect but so far it works great hope that helps.
@@stylie473joker5 Awesome! A video tutorial would be perfect.
I also have an idea - In continuation to this video: duplicate the entire level geometry and set "Only shadows" in the MeshRenderer + put it on the "weapon" layer. It will significantly increase DrawCall number, so you need to combine all the meshes into one - it's pretty simple.
Very hacky but should work
what if i dont have enviroment settings to change background type in my Weapon Camera?
Same
I believe change Clear Flags to Don't Clear
game dev is all about smoke n mrr :D
Thanks man
Thankyou So Much
Very cool 😊
One thing is that when I drop the weapon on the ground and go around a corner I can still see the weapon
Make it change layer if it's dropped
That's fine, but when I run it's like the weapon duplicates. Can it be fixed?
Disable "Weapons" layer rendering on the main camera
thank you
ty
this is the worst way for performance hit. unless you targetting high end devices.
I hate that I google for HDRP and this shows up. Like it's great that you can do this but it's annoying as hell I can't do this on HDRP..
Hey man - sorry about that, have you taken a look at this article? www.intetic.com/blogs/unity-hdrp-render-object-on-top-of-everything/
more zooms please...
That's not a good solution, you would probably want to do smth else with this. Why is this bad? Cause u don't see clipping, but it happens. Imagine that now u may want to shoot enemy at close range, but weapon will fall into enemy collider and your shots won't be registered, cause bullet collision doesn't work from inside of enemy collider.
The proper way to do this is through creating a custom shader for the materials on the weapon to always be rendered on top, or to move the weapon out of the way when you're close to a wall via a raycast check
"game dev is all about smoking marijua-"
Lol
i agree as a stoner
nope not working
Bruh just enable the mesh collisions and job done