Fix FPS Weapon Clipping and FOV Distortion WITHOUT CAMERA STACKING. using Unity URP.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
are you guys uh I'm gonna show you how I don't introduce clipping and also maintain my fov at whatever I want for my FPS models uh without affecting like the actual game a lot of people use camera stacking where you stack One camera that renders everything but the FPS meshes and one that does however that is incurs a performance cost because you are forcing the scene to render twice and not happy not good right obviously if you're on a small game like who cares but if you care about performance consider doing this especially if your world has a lot of mesh is um or you just care about performance like in general because you know like me I like I I care a lot about it even if it doesn't actually matter like my friends will be like uh why are you trying to optimize this when it only uses one percent of the CPU and you have like thousands of projectiles on screen and I'll tell them um because what if I want Millions anyways so you go to your Erp assets um if you I really don't know the difference between these two other than this one references the thing that you need it'll be your I just used the Erp High Fidelity renderer because you know I want to look nice and I assume if my game's optimized I can run High Fidelity even on like not that great a devices considering this isn't too complex High Fidelity of a game anyways but regardless what you do I'm gonna remove what I have right now here so I can show you guys as it is right now I have a player right and if I look at them he doesn't have his gun rendered because well it's not rendering on the same layer it's running on a different layer right and as you guys normally know if you do have a camera right and you go into your settings um you can not render your FPS view right and then you make a camera that does run into the FPS View what I do is you you put your FPS materials I have them here under my if I have them I have them under my camera I cannot find my camera that's awkward oh here it is FPS camera um if you see here I have this gun uh but you can't see it interesting well you you would be able to see it but you can see it's invisible like you can see the mesh outline there um and that's because I put it on this FPS View and in the settings asset I'm choosing not to render the FPS View all right so you're going to want to do that you want to put all the stuff you want to render in your FPS like your gun your hands whatever right on their own layer then you're going to untick them from both the transparent and opaque layer mask and then what you're going to want to do is see this button is ADD renderer feature and you want to click it and render objects experimental I mean it's been experimental since like for as long as I know but it works no problem that I've seen I use it and this allows you to render an object uh with separate settings than you would other objects um when when I say objects like you don't get to pick the actual objects it just renders a layer differently than the other layers it's the best way I can put it I'm going to choose this for my FPS View [Music] um I'm going to call this opaques oh okay okay opaque um and I'm gonna call this uh all that right and you'll see why in a second I'm going to set this one to rendering before rendering opaques and I'm going to set the layer mask to my FPS models right now you can see it and then I am going to go into the overrides and if you see here it looks kind of funky right it's not set up right because it's set for a different fov because right now in fps game you typically like to have your fov really high like 90 for example I have mine at 90. I prefer 90 to like 100. um because you get to see more right and seeing more lets you hit sick flicks so when I go to the camera I'll select that and I can change the fob to 40. that's the one I like and it can keep your gun mesh and other meshes at like not that stretched high fov but then as well if this doesn't do anything to prevent clipping right now so right now this will just make it so the mashes are not affected by the fov allowing you to like effectively overwrite it here in order to oh and one more thing you probably also want to do the transparents so if you add the another one you can do the same thing I'll just copy this and I'm not going to include the depth well I'll include the depth why not and this is not opaque this is transparent set it to after rendering transparence and this is then transparent and the layer mask I have for this uh will be my FPS materials FPS layer and in the overrides I'll do the same camera this mesh in particular I don't think has any transparent mesh but I do this because if you ever do happen to add something that does have transparent mesh it'll also take care of it for you without having to change any settings um I don't think it's particularly useful for my case but I'm going to do it so you guys know how to do it and right we set our camera to 40. so now our FPS is good so you can see here if I load in you know our FPS doesn't affect it but we have clipping oh no how do we fix that well normally you'd use two cameras and that method it's not great well it's easy but it's not great for performance at least I've heard that so we're going to do is we're gonna go and check these check this depth option and this will let us effectively override because like okay the fact that it's clipping is because you know in the world the mesh is going through our like the gun is going through the wall like in the game the gun is going through the wall and like preventing that from happening is like uh kind of a pain so instead making it so it just renders the gun and it like artificially sets the depth to like not care about anything and just render it regardless if it's through the wall or not through the wall and just be like yeah render this dude no matter what I don't care at the like depth of whatever Adept it is I don't care right so we're running the depth and this one will be set to less equal no it actually won't it'll be set to always right and our gun is gonna look a bit funky right you're gonna be like what that looks weird right and don't worry um this will be fixed after we right I'm gonna do the same thing to this one always right which won't affect you because I don't have any transparent mesh on here again but you might um I'll tap this one down and then we're going to add another render objects and copy our previous one and we're going to change this to less equal depth and everything else Remains the Same we do need to override the camera still because if we don't you'll notice it might leave some artifacts oh wait we need to select this so you'll see yeah it renders the gun twice like oh you're like oh my gosh it's rendering the gun twice um this needs to occur in order to not have this these artifacts that are left behind and I will set the fob to be fov to be the same all right so now our thing gets fixed so it looks a lot nicer but we still need to overhead depth and we'll leave it at less equal um actually I'm not sure if I need to override depth but I'm just going to leave a check because it works uh and I'm also going to do the same thing for my wrong button same thing for my transparence so this is going to be this one's set to after and Ringo pigs but it needs to be before rendering opaques because of like shadows and stuff um all I know is that's what I was that's what I learned from other tutorials and I'm gonna I'm gonna copy the transparent one and paste that there and then this is going to be the last equal back right I'm going to set this to after rendering transparency okay change the name what glass equals there you go now it's happy and transparent and our FPS view layer and we're going to set the depth to the less equal and then the camera will be at 40 like usual and now if I run it Tada wait I will fix that quickly what did I do wrong that was funny moment I didn't actually do what I wanted uh let me make sure I selected these right 40 40. last equal and always um you know what I might it might actually supposed to be after it picks if I'm not mistaken actually tick and there you have it no clipping um I'm assuming that worked because the wall is opaque and if I'm set to rendering after the opaques even if the depth of this pistol goes revolver goes through the wall it will not care because I'm I I'm overriding the depth features so there you have it how to do it without camera stacking
Info
Channel: Wolfey Gamedev
Views: 3,287
Rating: undefined out of 5
Keywords: Unity, Camera Stacking, FPS, FPS Weapons Bug, FPS weapon distortion, Weapon clipping, weapon fov, render weapons layer, URP clipping weapon, weapon clips through wall
Id: TTZSxt28FkY
Channel Id: undefined
Length: 11min 19sec (679 seconds)
Published: Sat Feb 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.