Add HDR lightmap support

This commit is contained in:
Jarrod Doyle 2024-09-24 16:16:50 +01:00
parent d144bdb6e9
commit 860080ada3
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 6 additions and 0 deletions

View File

@ -213,6 +213,8 @@ class Program
private static void CastScene(Raytracer scene, WorldRep wr, Light[] lights, Vector3 ambientLight) private static void CastScene(Raytracer scene, WorldRep wr, Light[] lights, Vector3 ambientLight)
{ {
var hdr = wr.DataHeader.LightmapFormat == 2;
var cells = wr.Cells; var cells = wr.Cells;
for (var cellIdx = 0; cellIdx < cells.Length; cellIdx++) for (var cellIdx = 0; cellIdx < cells.Length; cellIdx++)
{ {
@ -318,6 +320,10 @@ class Program
var len = dir.Length(); var len = dir.Length();
var slen = len / 4.0f; var slen = len / 4.0f;
var strength = (angle + 1.0f) / slen; var strength = (angle + 1.0f) / slen;
if (hdr)
{
strength /= 2;
}
strength = Math.Min(1.0f, strength); strength = Math.Min(1.0f, strength);
var c = light.color * strength; var c = light.color * strength;