Simplify lightmap origin calculation and adjust to cast from center of pixel
This commit is contained in:
parent
f4c4237306
commit
8bde33ebf2
|
@ -211,12 +211,10 @@ class Program
|
||||||
|
|
||||||
ResetLightmap(ambientLight, lightmap);
|
ResetLightmap(ambientLight, lightmap);
|
||||||
|
|
||||||
// Get world position of lightmap (0, 0)
|
// Get world position of lightmap (0, 0) (+0.5 so we cast from the center of a pixel)
|
||||||
var baseU = (4.0f / info.Width) * (renderPoly.TextureBases.Item1 + (0.5f - info.Bases.Item1) * 0.25f);
|
|
||||||
var baseV = (4.0f / info.Height) * (renderPoly.TextureBases.Item2 + (0.5f - info.Bases.Item2) * 0.25f);
|
|
||||||
var topLeft = cell.Vertices[cell.Indices[cellIdxOffset]];
|
var topLeft = cell.Vertices[cell.Indices[cellIdxOffset]];
|
||||||
topLeft -= baseU * (info.Width * 0.25f) * renderPoly.TextureVectors.Item1;
|
topLeft -= renderPoly.TextureVectors.Item1 * (renderPoly.TextureBases.Item1 - info.Bases.Item1 * 0.25f);
|
||||||
topLeft -= baseV * (info.Height * 0.25f) * renderPoly.TextureVectors.Item2;
|
topLeft -= renderPoly.TextureVectors.Item2 * (renderPoly.TextureBases.Item2 - info.Bases.Item2 * 0.25f);
|
||||||
|
|
||||||
foreach (var light in lights)
|
foreach (var light in lights)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue