Skip to content

Initial barn and omni2 light support#1104

Merged
kristiker merged 20 commits into
ValveResourceFormat:masterfrom
dr3fty:barn-lights
Mar 8, 2026
Merged

Initial barn and omni2 light support#1104
kristiker merged 20 commits into
ValveResourceFormat:masterfrom
dr3fty:barn-lights

Conversation

@dr3fty

@dr3fty dr3fty commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

Known issues / missing features:

  • No tile culling
  • Static 8k barn light shadow atlas
  • Performance (both shadow rendering and light rendering itself is "not great")
  • No alpha tested depth pass

@github-actions github-actions Bot added the Renderer Related to the 3D/2D rendering viewer label Mar 6, 2026
@xPaw xPaw added the Enhancement New feature or improvement request label Mar 6, 2026
Comment thread Renderer/Renderer/WorldLightingInfo.cs
@kristiker kristiker linked an issue Mar 6, 2026 that may be closed by this pull request
Comment thread Renderer/Renderer/ShadowAtlasPacker.cs Outdated
Comment on lines +24 to +48
private ShadowAtlasRegion[] regions = [];
private (int Height, int Width, int Index)[] sortBuffer = [];

public Span<ShadowAtlasRegion> Pack(int atlasSize, List<ShadowRequest> requests)
{
var count = requests.Count;
if (count == 0)
{
return [];
}

if (regions.Length < count)
{
regions = new ShadowAtlasRegion[int.Max(count, regions.Length * 2)];
}

if (sortBuffer.Length < count)
{
sortBuffer = new (int, int, int)[int.Max(count, sortBuffer.Length * 2)];
}

for (var i = 0; i < count; i++)
{
sortBuffer[i] = (requests[i].Height, requests[i].Width, i);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a max size can be figured out, then trimmed accordingly so we don't re allocate.

float m_fBarnLightShadowScale;
// PathTraceIndex (short) is not used
uint m_nPathTraceIndex_BarnLightFlags;
mat4x3 m_mBarnIlluminationFromWorld;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should change this to a 3x4

GL.BindSampler((int)ReservedTextureSlots.LightCookieTexture, CookieSamplerClampBorder);

shader.SetTexture((int)ReservedTextureSlots.LightCookieTextureWrap, "g_tLightCookieTextureWrap", BarnLightCookieAtlas);
GL.BindSampler((int)ReservedTextureSlots.LightCookieTextureWrap, CookieSamplerWrap);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we could have used sampler objects, (g_sWrapSampler)

}

entry.DrawCalls ??= CreateDepthOnlyDrawCallCollection();
CollectShadowDrawCalls(lightFrustum, includeStatic: true, includeDynamic: true, entry.DrawCalls);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cached results should be cleared when octree gets dirty. Actually caching makes no sense for dynamic objects... But it makes cpu time increase a lot from inefficient octree queries.

@kristiker kristiker merged commit 559309d into ValveResourceFormat:master Mar 8, 2026
7 checks passed
@kristiker kristiker linked an issue Apr 18, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or improvement request Renderer Related to the 3D/2D rendering viewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for lightcookies Implement light entity baked lightmaps

3 participants