FPS character gun & clipping

Are there any know tricks in UE4 (4.13 to be exact) that allows us to have FPS character gun that is not clipped by walls ?

For example our character have very long riffle (say it’s 1 meter long) and when you get close to the wall the barrel of it penetrates the wall with looks ugly.

Are there any solutions for this ? (previously in my own engine I’v tricked this in vertex shader (passed slightly offseted .z coorninate of projected vertex coord)), but since UE4 is deferred and probably relies on proper Z value for retrieving worldspace position from ZBuffer this trick will not work.
Other solutions that comes to my mind require modyfying of engine source, but meybe there is already some neat trick that allows us to have gun that is not clipped by walls ?

i don’t see what would stop you from using the vertex shader to scale the gun towards the camera when it gets too close to a wall. It’s called World Position Offset in the material.

world position offset outputs data in WORLD space (finally in vertex factory it bails out to something like WorldPosition + WorldPositionOffset)
my trick in my own engine was
float4 ProjectionSpacePosition = mul(CameraProjectionMatrix, WorldPosition);
ProjectionSpacePosition.z *= SomeScalingFactor;
so it’s a bit different now (and i see no possibility of injecting code AFTTER the muliplication by projection matrix happend in vertex factory vertex shader template)

again that would be wrong, next pass (lighting) would not know anything about our nasty trick and when world position is recovered from ZBuffor, then it will be fundamentally wrong thus produce bad realtime lighting/specular

it is very much true that the lighting/specular would be off, but i am not sure if it would actually be very noticeable in actual gameplay. obviously depends on your game, but i would not dismiss it without trying it first - especially since it’s very easy to implement.

The problem is the scale of the weapon exceeds the far plane clipping of the camera. The easy fix is to under scale the parent component in the viewport of the BP down until it fits with in the far plane and pull it closer to the camera.