gpz, on 18 February 2022 - 12:44 AM, said:
During the rewriting of the lights handling code I noticed, that the current headlight shading is quite unrealistic. Let me show you two pictures for comparision. (I hope the pictures will appear for everyone.)
The original shader used
http://www.kepfeltoltes.eu/images/2022/02/18/173Spot_linear_trim.png
In contrast, the PBR method for handling spot lights would be
http://www.kepfeltoltes.eu/images/2022/02/18/466Spot_inverse_sqared_tr.png
Did you guys notice this, and what do you think about it?
The original shader used
- linear distance range attenuation (1 - distance / range), and
- fully-lit pixels within the range (HLSL method step(0, projection) – means either 0 or 1), not counting the cone attenuation around the light cone edges.
http://www.kepfeltoltes.eu/images/2022/02/18/173Spot_linear_trim.png
In contrast, the PBR method for handling spot lights would be
- inverse-squared distance range attenuation (1 / distance²), which is actually how the light attenuates in real world, and
- proportionally lit pixels within the range, calculating how much the surface is perpendicular to the light direction (HLSL method clamp(projection, 0, 1) – means proportional within 0 and 1)
http://www.kepfeltoltes.eu/images/2022/02/18/466Spot_inverse_sqared_tr.png
Did you guys notice this, and what do you think about it?
It's very good Peter.
One of the problems w/ headlights is most .eng files have never updated the light cone definitions in their .eng files to work properly w/ OR. Not having the MSTS source code nobody could figure out what KUJU had actually done and so it was necessary to come up with our own solution. The change affected the radius and angle values. In OR radius describes the radius of the entire circle of light (it might be sphere but I don't recall). Angle describes how much of that will be visible as the headlight. If North American headlights are typical then the correct values to being using are ~ 1600m for radius and 4 for angle (a projection of about about a mile with a spread of 4 degrees on either side of the centerline. That's much further out and MUCH more narrow than what most people use. Your math changes should go a long way to diminishing the intensity of the outer degrees at distant points, which, IMO will be a very big improvement.