DarkestHour icon indicating copy to clipboard operation
DarkestHour copied to clipboard

Vehicle shadows are inconsistent & some vehicles have very odd shaped shadows

Open handsm opened this issue 6 years ago • 3 comments

Pointed out by @cmbasnett

Some vehicles appear to have odd shadows that don't match the vehicle, for example the Greyhound armoured car:

ghshadow_before

handsm avatar Aug 07 '17 11:08 handsm

The problem is caused by the inconsistent positioning of the mesh origin in vehicle hull meshes. The vehicle actor's world location is where its mesh origin is, so the way the vehicle is rigged directly affects how it is positioned in the world.

A shadow projector actors, attached to the vehicle to generate its shadow, position themselves relative to the vehicle's world location, i.e. relative to where the mesh origin is. In the unreal shadow projector class they position themselves a hard coded 5 Unreal units (approx 83mm) above the vehicle's location.

Many vehicles have their origin positioned on the natural centre of the hull, sort of where its centre of gravity would be. So in the Z axis the origin is about midway up the hull geometry. Personally, I prefer this method as it gives a more natural location for the vehicle. RO vehicles are rigged this way. But some other DH vehicles have their origin on the ground, with a Z position of zero.

This means that some vehicle shadow projectors position themselves just above the ground, while others are up in the air.

handsm avatar Aug 07 '17 11:08 handsm

Added a simple system to fix this in commit https://github.com/DarklightGames/DarkestHour/commit/f8f1ebaf85cc44dcbf009b31737eb6234e4fa8e6.

But individual vehicles still need working through and assigning a suitable setting.

I've added a new DHShadowProjector class, which uses a ShadowZOffset float variable for the vertical position offset for the shadow, replacing the literal value of +5 that's hard-coded into UpdateShadow() in ShadowProjector parent class. When a vehicle spawns and calls its own UpdateShadow(), this now spawns the new DHShadowProjector actor and passes it its ShadowZOffset value.

Have also removed a couple of things from the projector's UpdateShadow() for efficiency, as it gets is called every tick. It no longer update shadow rotation each tick, as it never changes, so we now do it once in the projector's InitShadow(). Also the RootMotion block as that bool is never true so it never applies.

Example of Greyhound with a much improved shadow (no change committed, so still looks wrong in game):

ghshadow_after

handsm avatar Aug 07 '17 11:08 handsm

Not critical for v8. Could maybe work through after code lock, as it doesn't affect anything else. Just fiddly and time consuming.

handsm avatar Sep 27 '17 17:09 handsm