- Home /
WeaponCamera shadow fail
Hi, I have a 2 camera setting for a fps game.
The first camera(MainCamera): Clear Flags: Skybox; CullingMask: Everything; FoV: 60; Clipping Planes ->Near = 3 ->Far = 3000; Depth: -1; Rendering Path: Forward; Occlusion Culling; true; HDR: false;
The second camera(WeaponCam): The first camera(MainCamera): Clear Flags: Depth only; CullingMask: Everything; FoV: 60; Clipping Planes ->Near = 0.1 ->Far = 3; Depth: 0; Rendering Path: Forward; Occlusion Culling; true; HDR: false;
The problem is that I cant see near shadows. To understand the problem you should look at the pictures:
The first one shows the normal shadow, but the second picture shows the bug... How can I fix it?
i don't exactly know what's causing this but you do NOT want to rendering everything for a weapon camera. Put all your weapons on separate layers and then set the camera to only render that layer. It doesn't work and it's a waste of processing power. You also probably want to set the near clipping planes to 0.01 for both cameras; otherwise you can get some weird clipping issues.
I use the weapon camera to prevent clipping issues, beacause if I set the near clipping plane lower than 1, I will get z-fighting on terrain and some models...I thought I use 2 cameras, one for range and one to don't look though the wall.
This is how you make a weapon camera.
$$anonymous$$ake a new layer, assign all your objects that will only be rendered by the gun camera to that new layer.
$$anonymous$$ake a new camera, set its Clear Flags to Don't Clear, and set it's culling mask to be the new layer you created for all your guns.
On the main camera, under culling masks, un-check the new layer. Otherwise it will be rendered twice and won't work right.
You can set your FOV to whatever you want.
And boom, the things that are on the new layer will be only rendered by the gun camera and won't clip through things.
I don't know why you're getting weird terrain issues with the clipping planes, but the higher you have it, objects that are close to the camera won't be rendered. Which is usually why you'd want it to be set to 0.01, or 0.1 like you have it; I prefer 0.01. The shadow problem might also be a problem with Unity itself, a bug perhaps. I've had several issues with multiple cameras and lighting. The problem might also be that you're using Depth Only, and not Don't Clear.
Your answer
Follow this Question
Related Questions
Shadow flicker 0 Answers
Shadows and Layers 0 Answers
I have an issue when I go to play my game (screen has a gradient can't see scene) 0 Answers
Two outputs, one camera? 1 Answer
See Shadow but not GameObject 1 Answer