mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-13 22:22:05 +00:00
Yet another env_probe interpolation idea
This commit is contained in:
parent
590cc61c24
commit
05a564228a
5 changed files with 64 additions and 18 deletions
|
@ -193,8 +193,6 @@ public:
|
|||
int lastModifiedFrameNum; // to determine if it is constantly changing,
|
||||
// and should go in the dynamic frame memory, or kept
|
||||
// in the cached memory
|
||||
bool archived; // for demo writing
|
||||
|
||||
|
||||
// derived information
|
||||
idPlane lightProject[4]; // old style light projection where Z and W are flipped and projected lights lightProject[3] is divided by ( zNear + zFar )
|
||||
|
@ -243,18 +241,13 @@ public:
|
|||
int lastModifiedFrameNum; // to determine if it is constantly changing,
|
||||
// and should go in the dynamic frame memory, or kept
|
||||
// in the cached memory
|
||||
bool archived; // for demo writing
|
||||
|
||||
// derived information
|
||||
//idPlane lightProject[4]; // old style light projection where Z and W are flipped and projected lights lightProject[3] is divided by ( zNear + zFar )
|
||||
//idRenderMatrix baseLightProject; // global xyz1 to projected light strq
|
||||
idRenderMatrix inverseBaseProbeProject;// transforms the zero-to-one cube to exactly cover the light in world space
|
||||
|
||||
idBounds globalProbeBounds;
|
||||
|
||||
areaReference_t* references; // each area the light is present in will have a lightRef
|
||||
//idInteraction* firstInteraction; // doubly linked list
|
||||
//idInteraction* lastInteraction;
|
||||
|
||||
idImage* irradianceImage; // cubemap image used for diffuse IBL by backend
|
||||
idImage* radianceImage; // cubemap image used for specular IBL by backend
|
||||
|
|
|
@ -96,7 +96,6 @@ idRenderLightLocal::idRenderLightLocal()
|
|||
index = 0;
|
||||
areaNum = 0;
|
||||
lastModifiedFrameNum = 0;
|
||||
archived = false;
|
||||
lightShader = NULL;
|
||||
falloffImage = NULL;
|
||||
globalLightOrigin = vec3_zero;
|
||||
|
@ -139,7 +138,6 @@ RenderEnvprobeLocal::RenderEnvprobeLocal()
|
|||
index = 0;
|
||||
areaNum = 0;
|
||||
lastModifiedFrameNum = 0;
|
||||
archived = false;
|
||||
references = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -777,8 +777,6 @@ void R_DeriveEnvprobeData( RenderEnvprobeLocal* probe )
|
|||
// compute the probe projection matrix
|
||||
// ------------------------------------
|
||||
|
||||
|
||||
|
||||
idMat3 axis;
|
||||
axis.Identity();
|
||||
|
||||
|
@ -851,12 +849,6 @@ void R_CreateEnvprobeRefs( RenderEnvprobeLocal* probe )
|
|||
|
||||
void R_FreeEnvprobeDefDerivedData( RenderEnvprobeLocal* probe )
|
||||
{
|
||||
// TODO free all the interactions
|
||||
//while( ldef->firstInteraction != NULL )
|
||||
//{
|
||||
// ldef->firstInteraction->UnlinkAndFree();
|
||||
//}
|
||||
|
||||
// free all the references to the envprobe
|
||||
areaReference_t* nextRef = NULL;
|
||||
for( areaReference_t* lref = probe->references; lref != NULL; lref = nextRef )
|
||||
|
|
|
@ -537,6 +537,12 @@ static void R_FindClosestEnvironmentProbes()
|
|||
tr.viewDef->irradianceImage = nearest->irradianceImage;
|
||||
}
|
||||
|
||||
static float oldBarys[3] = {0};
|
||||
static int oldIndexes[3] = {0};
|
||||
static int triIndexes[3];
|
||||
//static int mapIndexes[3];
|
||||
static int timeInterpolateStart = 0;
|
||||
|
||||
// form a triangle of the 3 closest probes
|
||||
idVec3 verts[3];
|
||||
for( int i = 0; i < 3; i++ )
|
||||
|
@ -544,11 +550,23 @@ static void R_FindClosestEnvironmentProbes()
|
|||
verts[i] = viewEnvprobes[0]->parms.origin;
|
||||
}
|
||||
|
||||
bool triChanged = false;
|
||||
for( int i = 0; i < viewEnvprobes.Num() && i < 3; i++ )
|
||||
{
|
||||
RenderEnvprobeLocal* vProbe = viewEnvprobes[i];
|
||||
|
||||
verts[i] = vProbe->parms.origin;
|
||||
triIndexes[i] = vProbe->index;
|
||||
|
||||
if( oldIndexes[i] != triIndexes[i] )
|
||||
{
|
||||
triChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( triChanged )
|
||||
{
|
||||
timeInterpolateStart = Sys_Milliseconds();
|
||||
}
|
||||
|
||||
idVec3 closest = R_ClosestPointPointTriangle( testOrigin, verts[0], verts[1], verts[2] );
|
||||
|
@ -574,6 +592,52 @@ static void R_FindClosestEnvironmentProbes()
|
|||
c = idWinding::TriangleArea( closest, verts[0], verts[1] ) / denom;
|
||||
|
||||
bary.Set( a, b, c );
|
||||
|
||||
#if 0
|
||||
if( triChanged )
|
||||
{
|
||||
int time = Sys_Milliseconds();
|
||||
|
||||
float t = -( timeInterpolateStart - time ) / 5000.0f;
|
||||
|
||||
t = idMath::ClampFloat( 0.0f, 1.0f, t );
|
||||
|
||||
// are there at least 2 old matching indices then interpolate from the old barycentrics over time
|
||||
int nInterpolants = 0;
|
||||
int interpolants[2];
|
||||
int mapIndex[2];
|
||||
for( int i = 0; i < 3 && i < viewEnvprobes.Num(); i++ )
|
||||
{
|
||||
for( int j = 0; j < 3 && j < viewEnvprobes.Num(); j++ )
|
||||
{
|
||||
if( oldIndexes[i] == triIndexes[j] )
|
||||
{
|
||||
interpolants[nInterpolants] = i;
|
||||
mapIndex[nInterpolants] = j;
|
||||
nInterpolants++;
|
||||
}
|
||||
|
||||
if( nInterpolants == 2 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( nInterpolants == 2 )
|
||||
{
|
||||
bary[mapIndex[0]] = Lerp( oldBarys[interpolants[0]], bary[mapIndex[0]], t );
|
||||
bary[mapIndex[1]] = Lerp( oldBarys[interpolants[1]], bary[mapIndex[1]], t );
|
||||
}
|
||||
|
||||
//if( time >= ( timeInterpolateStart + 5000 ) )
|
||||
{
|
||||
oldIndexes[0] = triIndexes[0];
|
||||
oldIndexes[1] = triIndexes[1];
|
||||
oldIndexes[2] = triIndexes[2];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
tr.viewDef->radianceImageBlends.Set( bary.x, bary.y, bary.z, 0.0f );
|
||||
|
|
|
@ -44,7 +44,6 @@ idRenderLightLocal::idRenderLightLocal()
|
|||
index = 0;
|
||||
areaNum = 0;
|
||||
lastModifiedFrameNum = 0;
|
||||
archived = false;
|
||||
lightShader = NULL;
|
||||
falloffImage = NULL;
|
||||
globalLightOrigin = vec3_zero;
|
||||
|
|
Loading…
Reference in a new issue