Newlight Directionality Fix

If you liked this item, please rate it up on Steam Workshop page.

Author: Jofoyo

Last revision: 14 Feb, 2024 at 01:56 UTC

File size: 2.95 MB

On Steam Workshop

Description:
Update: Soon this mod will be rendered obsolete by an upcoming patch as the half-lambert calculations will have been fixed. However, many materials will still benefit from this parameter, and other now fixed parameters. Stay tuned for an upcoming sequel post patch.

Update 3: This patch is now released

This mod edits EVERY model material in the game! If you have other mods, there will be conflicts if it edits any default materials!
This mod adds a hidden unused parameter to every models material that can in some cases extensively improves dynamic lighting and shadows on models that use phong shading without any additional performance costs. Without this newly added parameter, newlights will shine on a phong shaded model from BOTH directions of a newlight, creating unexpected and ugly results! You will mainly see differences in Xen, especially in areas with lots of models, and where newlights have shadows disabled.

Technical Explanation

Sources standard model lighting comes with a hacky way of boosting ambient lighting on characters and props. This is called half-lambertian lighting. The light is wrapped around the edges of a model which gives the lighting a softer appearance, prevents overly harsh shadows from normal maps. This was implemented as an easy and performant way to improve the appearance of lighting, at a cost of realism.
Consequentially, newlights also had half-lambertian lighting implemented. However, it is currently left in a broken state. The result is that meshes with $phong or $halflambert get lit from ALL sides perpendicular to newlights, including ones with opposing normals. Shadows help to mask this bug, but it still appears glaringly incorrect.
As it turns out however, the aforementioned command existed, which disables halflambert for newlights, but not regular lights!

A small album showcasing the issue with comparison to Blenders realtime renderer https://imgur.com/a/5iy2Nhf

Limitations and Caveats
  • As explained, this will only affect models that use $halflambert, which mostly means things with specularity/phong.
  • Some areas may not quite be lit the same as they may have depended on the bug. Notably areas entirely lit by newlights may seemingly lack ambient lighting and have overly dark shadows.
  • Xen plant lights for instance have shadows on the bulbs as they did not use illumtextures.
  • I used an automated process to mass add the parameter, as such some materials will actually be more desirable with the effect off, notably plants, and anything that uses nocull.

For Modders

To implement this fix in your own mods, add this parameter anywhere within your models VMTs. You only need to add this if you are using $phong or $halflambert. This parameter does not need to be added to lightmappedgeneric or similar as it doesn’t use either. If you are a mapper, be sure to supplement your newlights with regular lights for better ambient lighting.

"$halflambert_gbuffer_off" "1"

Mod folder is Steamsteamappsworkshopcontent362890

This commands existence was brought to my attention by Rimas and this fix will be included in the chapter 5 release of Black Mesa: Blue Shift!