idTech 8 style path tracing.

This commit is contained in:
Justin Marshall
2026-05-27 14:08:35 -07:00
parent 41cbd5669b
commit 5d2cb8640d
11 changed files with 1652 additions and 355 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

+4 -1
View File
@@ -4099,7 +4099,8 @@ static classVariableInfo_t glRaytracingLight_t_typeInfo[] = {
{ "float", "pointRadiusPad", (intptr_t)(&((glRaytracingLight_t *)0)->pointRadiusPad), sizeof( ((glRaytracingLight_t *)0)->pointRadiusPad ) },
{ "uint32_t", "iesTextureId", (intptr_t)(&((glRaytracingLight_t *)0)->iesTextureId), sizeof( ((glRaytracingLight_t *)0)->iesTextureId ) },
{ "float", "iesStrength", (intptr_t)(&((glRaytracingLight_t *)0)->iesStrength), sizeof( ((glRaytracingLight_t *)0)->iesStrength ) },
{ "float[2]", "iesPad", (intptr_t)(&((glRaytracingLight_t *)0)->iesPad), sizeof( ((glRaytracingLight_t *)0)->iesPad ) },
{ "int32_t", "areaNum", (intptr_t)(&((glRaytracingLight_t *)0)->areaNum), sizeof( ((glRaytracingLight_t *)0)->areaNum ) },
{ "float", "iesPad", (intptr_t)(&((glRaytracingLight_t *)0)->iesPad), sizeof( ((glRaytracingLight_t *)0)->iesPad ) },
{ NULL, 0 }
};
@@ -4112,6 +4113,8 @@ static classVariableInfo_t glRaytracingLightingPassDesc_t_typeInfo[] = {
{ "DXGI_FORMAT", "normalFormat", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->normalFormat), sizeof( ((glRaytracingLightingPassDesc_t *)0)->normalFormat ) },
{ "ID3D12Resource *", "positionTexture", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->positionTexture), sizeof( ((glRaytracingLightingPassDesc_t *)0)->positionTexture ) },
{ "DXGI_FORMAT", "positionFormat", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->positionFormat), sizeof( ((glRaytracingLightingPassDesc_t *)0)->positionFormat ) },
{ "ID3D12Resource *", "velocityTexture", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->velocityTexture), sizeof( ((glRaytracingLightingPassDesc_t *)0)->velocityTexture ) },
{ "DXGI_FORMAT", "velocityFormat", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->velocityFormat), sizeof( ((glRaytracingLightingPassDesc_t *)0)->velocityFormat ) },
{ "ID3D12Resource *", "outputTexture", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->outputTexture), sizeof( ((glRaytracingLightingPassDesc_t *)0)->outputTexture ) },
{ "DXGI_FORMAT", "outputFormat", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->outputFormat), sizeof( ((glRaytracingLightingPassDesc_t *)0)->outputFormat ) },
{ "uint32_t", "width", (intptr_t)(&((glRaytracingLightingPassDesc_t *)0)->width), sizeof( ((glRaytracingLightingPassDesc_t *)0)->width ) },
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+7 -2
View File
@@ -1714,7 +1714,8 @@ typedef struct glRaytracingLight_s
uint32_t iesTextureId; // optional GL texture containing a lat-long IES profile
float iesStrength; // 0 disables, 1 uses texture as authored
float iesPad[2];
int32_t areaNum; // proc/render portal area, -1 if unknown
float iesPad;
} glRaytracingLight_t;
typedef struct glRaytracingLightingPassDesc_s
@@ -1731,6 +1732,9 @@ typedef struct glRaytracingLightingPassDesc_s
ID3D12Resource* positionTexture;
DXGI_FORMAT positionFormat;
ID3D12Resource* velocityTexture;
DXGI_FORMAT velocityFormat;
ID3D12Resource* outputTexture;
DXGI_FORMAT outputFormat;
@@ -1841,6 +1845,7 @@ void glRaytracingLightingSetAmbient(float r, float g, floa
void glRaytracingLightingSetCameraPosition(float x, float y, float z);
void glRaytracingLightingSetInvViewProjMatrix(const float* m16);
void glRaytracingLightingSetInvViewMatrix(const float* m16);
void glRaytracingLightingSetHistoryReset(int reset);
void glRaytracingLightingSetNormalReconstructSign(float signValue);
void glRaytracingLightingEnableSpecular(int enable);
void glRaytracingLightingEnableHalfLambert(int enable);
@@ -2345,7 +2350,7 @@ extern "C" {
void glRaytracingSetMeshMaterialFlags(glRaytracingMeshHandle_t meshHandle, uint32_t materialFlags);
void glRaytracingSetMeshGlass(glRaytracingMeshHandle_t meshHandle, int isGlass);
void glRaytracingSetMeshAverageColor(glRaytracingMeshHandle_t meshHandle, float r, float g, float b, float a);
void glRaytracingSetMeshProcMetadata(glRaytracingMeshHandle_t meshHandle, uint32_t procFlags, float emissiveR, float emissiveG, float emissiveB, float emissivePower);
void glRaytracingSetMeshProcMetadata(glRaytracingMeshHandle_t meshHandle, uint32_t procFlags, int areaNum, float emissiveR, float emissiveG, float emissiveB, float emissivePower);
// For callers that create raytracing instances directly instead of using the
// shim's glUpdateTopLevelAceelStructure() helper. Glass meshes must also use
+3 -3
View File
@@ -190,7 +190,7 @@ idCVar r_showInteractionScissors( "r_showInteractionScissors", "0", CVAR_RENDERE
idCVar r_showLightCount( "r_showLightCount", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = colors surfaces based on light count, 2 = also count everything through walls, 3 = also print overdraw", 0, 3, idCmdSystem::ArgCompletion_Integer<0,3> );
idCVar r_showPathTraceProfile( "r_showPathTraceProfile", "0", CVAR_RENDERER | CVAR_INTEGER, "report path tracer GPU and estimated ray workload, 1 = once per second, 2 = every frame", 0, 2, idCmdSystem::ArgCompletion_Integer<0,2> );
idCVar r_pathTraceSecondaryLightBudget( "r_pathTraceSecondaryLightBudget", "0", CVAR_RENDERER | CVAR_INTEGER, "secondary GI light budget, 0 = automatic, -1 = full light list" );
idCVar r_pathTraceSecondaryLightCompensation( "r_pathTraceSecondaryLightCompensation", "0.18", CVAR_RENDERER | CVAR_FLOAT, "energy compensation for capped secondary GI lights, 0 = none, 1 = full scale" );
idCVar r_pathTraceSecondaryLightCompensation( "r_pathTraceSecondaryLightCompensation", "0.62", CVAR_RENDERER | CVAR_FLOAT, "energy compensation for capped secondary GI lights, 0 = none, 1 = full scale" );
idCVar r_pathTracePortalWorldCulling( "r_pathTracePortalWorldCulling", "0", CVAR_RENDERER | CVAR_BOOL, "use portal flood to hide/show static world ray tracing instances" );
idCVar r_pathTraceAreaLightCulling( "r_pathTraceAreaLightCulling", "1", CVAR_RENDERER | CVAR_BOOL, "use proc area graph to reduce uploaded path tracing lights" );
idCVar r_pathTraceAreaLightDepth( "r_pathTraceAreaLightDepth", "5", CVAR_RENDERER | CVAR_INTEGER, "proc area neighbor depth for path tracing lights", 0, 8, idCmdSystem::ArgCompletion_Integer<0,8> );
@@ -530,8 +530,8 @@ void R_InitOpenGL( void ) {
// Reset our gamma
R_SetColorMappings();
glRaytracingLightingSetExternalDenoiser(1);
glRaytracingLightingSetPathTracingOptions(256, 2, 1, 1.0f);
glRaytracingLightingSetExternalDenoiser(0);
glRaytracingLightingSetPathTracingOptions(1, 2, 1, 1.0f);
// Create the DXR worlds.
for (int i = 0; i < DXR_WORLD_NUM; i++)
+5 -1
View File
@@ -519,7 +519,10 @@ idRenderModel *idRenderWorldLocal::ParseModel( idLexer *src ) {
// add the completed surface to the model
model->AddSurface( surf );
if (!surf.shader->IsSky() && surf.shader->IsLitMaterial() && surf.shader->SurfaceCastsShadow())
const bool raytraceMetadataSurface =
raytraceMeta.valid &&
( raytraceMeta.flags & ( GL_RAYTRACING_PROC_SURFACE_EMISSIVE | GL_RAYTRACING_PROC_SURFACE_UNLIT ) ) != 0;
if ( !surf.shader->IsSky() && ( ( surf.shader->IsLitMaterial() && surf.shader->SurfaceCastsShadow() ) || raytraceMetadataSurface ) )
{
idRenderModelStatic* modelStatic = (idRenderModelStatic*)model;
dxrWorldModel_t dxrModel;
@@ -535,6 +538,7 @@ idRenderModel *idRenderWorldLocal::ParseModel( idLexer *src ) {
glRaytracingSetMeshProcMetadata(
dxrModel.dxrBottomAcel,
raytraceMeta.flags,
raytraceMeta.areaNum,
raytraceMeta.emissiveColor[0],
raytraceMeta.emissiveColor[1],
raytraceMeta.emissiveColor[2],
+28
View File
@@ -203,6 +203,32 @@ static void RB_DXRAddUniquePathTraceArea(idList<int>& areas, int areaNum)
areas.Append(areaNum);
}
static int RB_DXRSingleReferencedLightArea(const idRenderLightLocal* light)
{
if (!light)
return -1;
int singleArea = -1;
for (const areaReference_t* ref = light->references; ref; ref = ref->ownerNext)
{
if (!ref->area)
continue;
const int areaNum = ref->area->areaNum;
if (singleArea < 0)
{
singleArea = areaNum;
continue;
}
if (singleArea != areaNum)
{
return -1;
}
}
return singleArea;
}
static bool RB_DXRBuildPathTraceLightAreaSet(idRenderWorldLocal* world, idList<int>& areas)
{
areas.Clear();
@@ -325,6 +351,7 @@ void RB_DXDrawInteractions(void)
light.samples = srcLight.noShadows ? 0u : 1u;
light.pointRadiusPad = srcLight.noSpecular ? 1.0f : 0.0f;
light.areaNum = RB_DXRSingleReferencedLightArea(vLight->lightDef);
const idVec3 axisU = RB_DXRNormalizeVec3Safe(RB_DXRTransformLightVector(srcLight.axis, RB_DXRMakeVec3(1.0f, 0.0f, 0.0f)), RB_DXRMakeVec3(1.0f, 0.0f, 0.0f));
const idVec3 axisV = RB_DXRNormalizeVec3Safe(RB_DXRTransformLightVector(srcLight.axis, RB_DXRMakeVec3(0.0f, 1.0f, 0.0f)), RB_DXRMakeVec3(0.0f, 1.0f, 0.0f));
@@ -346,6 +373,7 @@ void RB_DXDrawInteractions(void)
vLight->globalLightOrigin,
r, g, b,
intensity);
light.areaNum = RB_DXRSingleReferencedLightArea(vLight->lightDef);
}
else
{