Compare commits
2 Commits
3edc5eb758
...
651243d91f
Author | SHA1 | Date |
---|---|---|
|
651243d91f | |
|
8864993463 |
|
@ -564,8 +564,8 @@ public class LightMapper
|
||||||
}
|
}
|
||||||
|
|
||||||
var visibleSet = settings.FastPvs switch {
|
var visibleSet = settings.FastPvs switch {
|
||||||
true => pvs.ComputeVisibilityFast(lightCellMap[i]),
|
true => pvs.ComputeVisibilityFast(cellIdx),
|
||||||
false => pvs.ComputeVisibilityExact(_lights[i].Position, lightCellMap[i], _lights[i].Radius)
|
false => pvs.ComputeVisibilityExact(_lights[i].Position, cellIdx, _lights[i].Radius)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Log.Information("Light {i} sees {c} cells", i, visibleSet.Count);
|
// Log.Information("Light {i} sees {c} cells", i, visibleSet.Count);
|
||||||
|
@ -1068,16 +1068,17 @@ public class LightMapper
|
||||||
// TODO: direction should already be normalised here
|
// TODO: direction should already be normalised here
|
||||||
private bool TraceSunRay(Vector3 origin, Vector3 direction)
|
private bool TraceSunRay(Vector3 origin, Vector3 direction)
|
||||||
{
|
{
|
||||||
// Avoid self intersection
|
|
||||||
origin += direction * MathUtils.Epsilon;
|
|
||||||
|
|
||||||
var hitResult = _scene.Trace(new Ray
|
var hitResult = _scene.Trace(new Ray
|
||||||
{
|
{
|
||||||
Origin = origin,
|
Origin = origin,
|
||||||
Direction = Vector3.Normalize(direction),
|
Direction = Vector3.Normalize(direction),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hitResult)
|
// If origin is very close to a wall, the initial trace to the sun sometimes misses the wall. Now that we have
|
||||||
|
// backface culling enabled in Embree, this can result in reaching a sky when we shouldn't.
|
||||||
|
// By doing another occlusion trace in the reverse direction we fix this. Any backfaces we passed through in
|
||||||
|
// the initial trace become frontfaces to be occluded by.
|
||||||
|
if (hitResult && !TraceOcclusion(_scene, hitResult.Position + hitResult.ErrorOffset * hitResult.Normal, origin))
|
||||||
{
|
{
|
||||||
return _triangleTypeMap[(int)hitResult.PrimId] == SurfaceType.Sky;
|
return _triangleTypeMap[(int)hitResult.PrimId] == SurfaceType.Sky;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class PotentiallyVisibleSet
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var visibleCells = new HashSet<int>();
|
var visibleCells = new HashSet<int> { cellIdx };
|
||||||
foreach (var edgeIdx in _graph[cellIdx].EdgeIndices)
|
foreach (var edgeIdx in _graph[cellIdx].EdgeIndices)
|
||||||
{
|
{
|
||||||
var edge = _edges[edgeIdx];
|
var edge = _edges[edgeIdx];
|
||||||
|
|
Loading…
Reference in New Issue