Skip to content

Commit

Permalink
First step at generating multiple env probes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeckebans committed May 16, 2020
1 parent 71d768c commit 804c16d
Show file tree
Hide file tree
Showing 11 changed files with 482 additions and 14 deletions.
10 changes: 5 additions & 5 deletions base/renderprogs/postprocess.ps.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ struct PS_OUT
};
// *INDENT-ON*

#define USE_CHROMATIC_ABERRATION 0
#define USE_CHROMATIC_ABERRATION 1
#define Chromatic_Amount 0.075

#define USE_TECHNICOLOR 0 // [0 or 1]

#define Technicolor_Amount 0.5 // [0.00 to 1.00]
#define Technicolor_Amount 1.0 // [0.00 to 1.00]
#define Technicolor_Power 4.0 // [0.00 to 8.00]
#define Technicolor_RedNegativeAmount 0.88 // [0.00 to 1.00]
#define Technicolor_GreenNegativeAmount 0.88 // [0.00 to 1.00]
Expand All @@ -62,9 +62,9 @@ struct PS_OUT
#define Vibrance 0.5 // [-1.00 to 1.00]
#define Vibrance_RGB_Balance float3( 1.0, 1.0, 1.0 )

#define USE_CAS 1
#define USE_CAS 0

#define USE_DITHERING 0
#define USE_DITHERING 1
#define Dithering_QuantizationSteps 8.0 // 8.0 = 2 ^ 3 quantization bits
#define Dithering_NoiseBoost 1.0
#define Dithering_Wide 1.0
Expand Down Expand Up @@ -604,7 +604,7 @@ void main( PS_IN fragment, out PS_OUT result )
#endif

#if USE_CHROMATIC_ABERRATION
ChromaticAberrationPass2( color );
ChromaticAberrationPass( color );
#endif

#if USE_TECHNICOLOR
Expand Down
4 changes: 4 additions & 0 deletions neo/renderer/OpenGL/RenderBackend_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,7 @@ void idRenderBackend::StereoRenderExecuteBackEndCommands( const emptyCommand_t*
{
case RC_NOP:
break;

case RC_DRAW_VIEW_GUI:
case RC_DRAW_VIEW_3D:
{
Expand All @@ -1950,12 +1951,15 @@ void idRenderBackend::StereoRenderExecuteBackEndCommands( const emptyCommand_t*
}
}
break;

case RC_SET_BUFFER:
SetBuffer( cmds );
break;

case RC_COPY_RENDER:
CopyRender( cmds );
break;

case RC_POST_PROCESS:
{
postProcessCommand_t* cmd = ( postProcessCommand_t* )cmds;
Expand Down
1 change: 1 addition & 0 deletions neo/renderer/RenderBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4398,6 +4398,7 @@ void idRenderBackend::FogAllLights()
{
return;
}

renderLog.OpenMainBlock( MRB_FOG_ALL_LIGHTS );
renderLog.OpenBlock( "Render_FogAllLights", colorBlue );

Expand Down
54 changes: 52 additions & 2 deletions neo/renderer/RenderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012-2016 Robert Beckebans
Copyright (C) 2012-2020 Robert Beckebans
Copyright (C) 2014-2016 Kot in Action Creative Artel
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Expand Down Expand Up @@ -98,6 +98,7 @@ SURFACES
class idRenderWorldLocal;
struct viewEntity_t;
struct viewLight_t;
struct viewEnvprobe_t;

// drawSurf_t structures command the back end to render surfaces
// a given srfTriangles_t may be used with multiple viewEntity_t,
Expand Down Expand Up @@ -269,9 +270,20 @@ class RenderEnvprobeLocal : public RenderEnvprobe
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 inverseBaseLightProject;// transforms the zero-to-one cube to exactly cover the light in world space

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

// temporary helpers
int viewCount; // if == tr.viewCount, the envprobe is on the viewDef->viewEnvprobes list
viewEnvprobe_t* viewEnvprobe;
};
// RB end

Expand Down Expand Up @@ -441,6 +453,34 @@ struct viewEntity_t
dynamicShadowVolumeParms_t* dynamicShadowVolumes;
};

// RB: viewEnvprobes are allocated on the frame temporary stack memory
// a viewEnvprobe contains everything that the back end needs out of an RenderEnvprobeLocal,
// which the front end may be modifying simultaniously if running in SMP mode.

// this structure will be especially helpful when we switch RBDOOM-3-BFG to forward cluster shading
// because then we can evaluate all viewEnvprobes properly in each pixel shader along with all other lighting information
struct viewEnvprobe_t
{
viewEnvprobe_t* next;

// back end should NOT reference the lightDef, because it can change when running SMP
RenderEnvprobeLocal* envprobeDef;

// for scissor clipping, local inside renderView viewport
// scissorRect.Empty() is true if the viewEntity_t was never actually
// seen through any portals
idScreenRect scissorRect;

// R_AddSingleEnvprobe() determined that the light isn't actually needed
bool removeFromList;

idVec3 globalOrigin; // global envprobe origin used by backend

idRenderMatrix inverseBaseLightProject; // the matrix for deforming the 'zeroOneCubeModel' to exactly cover the light volume in world space
idImage* irradianceImage; // cubemap image used for diffuse IBL by backend
idImage* radianceImage; // cubemap image used for specular IBL by backend
};
// RB end

const int MAX_CLIP_PLANES = 1; // we may expand this to six for some subview issues

Expand Down Expand Up @@ -529,7 +569,7 @@ struct viewDef_t
int numDrawSurfs; // it is allocated in frame temporary memory
int maxDrawSurfs; // may be resized

viewLight_t* viewLights; // chain of all viewLights effecting view
viewLight_t* viewLights; // chain of all viewLights effecting view
viewEntity_t* viewEntitys; // chain of all viewEntities effecting view, including off screen ones casting shadows
// we use viewEntities as a check to see if a given view consists solely
// of 2D rendering, which we can optimize in certain ways. A 2D view will
Expand All @@ -547,6 +587,15 @@ struct viewDef_t
// crossing a closed door. This is used to avoid drawing interactions
// when the light is behind a closed door.
bool* connectedAreas;

// RB: collect environment probes like lights
viewEnvprobe_t* viewEnvprobes;

// RB: nearest probe for now
idRenderMatrix inverseBaseEnvProbeProject; // the matrix for deforming the 'zeroOneCubeModel' to exactly cover the environent probe volume in world space
idImage* irradianceImage; // cubemap image used for diffuse IBL by backend
idImage* radianceImage; // cubemap image used for specular IBL by backend
// RB end
};


Expand Down Expand Up @@ -1026,6 +1075,7 @@ extern idCVar r_testGammaBias; // draw a grid pattern to test gamma levels

extern idCVar r_singleLight; // suppress all but one light
extern idCVar r_singleEntity; // suppress all but one entity
extern idCVar r_singleEnvprobe; // suppress all but one envprobe
extern idCVar r_singleArea; // only draw the portal area the view is actually in
extern idCVar r_singleSurface; // suppress all but one surface on each entity
extern idCVar r_shadowPolygonOffset; // bias value added to depth test for stencil shadow drawing
Expand Down
4 changes: 2 additions & 2 deletions neo/renderer/RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,6 @@ In split screen mode the rendering size is also smaller.
*/
void idRenderSystemLocal::PerformResolutionScaling( int& newWidth, int& newHeight )
{

float xScale = 1.0f;
float yScale = 1.0f;
resolutionScale.GetCurrentResolutionScale( xScale, yScale );
Expand Down Expand Up @@ -1057,7 +1056,7 @@ void idRenderSystemLocal::CaptureRenderToImage( const char* imageName, bool clea
common->Printf( "write DC_CAPTURE_RENDER: %s\n", imageName );
}
}
idImage* image = globalImages->GetImage( imageName );
idImage* image = globalImages->GetImage( imageName );
if( image == NULL )
{
image = globalImages->AllocImage( imageName );
Expand Down Expand Up @@ -1093,6 +1092,7 @@ void idRenderSystemLocal::CaptureRenderToFile( const char* fileName, bool fixAlp

guiModel->EmitFullScreen();
guiModel->Clear();

RenderCommandBuffers( frameData->cmdHead );

#if !defined(USE_VULKAN)
Expand Down
5 changes: 2 additions & 3 deletions neo/renderer/RenderSystem_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ idCVar r_screenFraction( "r_screenFraction", "100", CVAR_RENDERER | CVAR_INTEGER
idCVar r_usePortals( "r_usePortals", "1", CVAR_RENDERER | CVAR_BOOL, " 1 = use portals to perform area culling, otherwise draw everything" );
idCVar r_singleLight( "r_singleLight", "-1", CVAR_RENDERER | CVAR_INTEGER, "suppress all but one light" );
idCVar r_singleEntity( "r_singleEntity", "-1", CVAR_RENDERER | CVAR_INTEGER, "suppress all but one entity" );
idCVar r_singleEnvprobe( "r_singleEnvprobe", "-1", CVAR_RENDERER | CVAR_INTEGER, "suppress all but one environment probe" );
idCVar r_singleSurface( "r_singleSurface", "-1", CVAR_RENDERER | CVAR_INTEGER, "suppress all but one surface on each entity" );
idCVar r_singleArea( "r_singleArea", "0", CVAR_RENDERER | CVAR_BOOL, "only draw the portal area the view is actually in" );
idCVar r_orderIndexes( "r_orderIndexes", "1", CVAR_RENDERER | CVAR_BOOL, "perform index reorganization to optimize vertex use" );
Expand Down Expand Up @@ -1210,7 +1211,6 @@ void R_EnvShot_f( const idCmdArgs& args )

for( i = 0 ; i < 6 ; i++ )
{

ref = primary.renderView;

extension = envDirection[ i ];
Expand All @@ -1219,7 +1219,7 @@ void R_EnvShot_f( const idCmdArgs& args )
ref.viewaxis = axis[i];
fullname.Format( "env/%s%s", baseName, extension );

tr.TakeScreenshot( size, size, fullname, blends, &ref, TGA );
tr.TakeScreenshot( size, size, fullname, blends, &ref, PNG );
}

// restore the original resolution, axis and fov
Expand Down Expand Up @@ -1851,7 +1851,6 @@ to skybox textures ( forward, back, left, right, up, down)
*/
void R_TransformEnvToSkybox_f( const idCmdArgs& args )
{

if( args.Argc() != 2 )
{
common->Printf( "USAGE: envToSky <basename>\n" );
Expand Down
2 changes: 1 addition & 1 deletion neo/renderer/RenderWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ void idRenderWorldLocal::GenerateAllInteractions()
int size = interactionTableWidth * interactionTableHeight * sizeof( *interactionTable );
interactionTable = ( idInteraction** )R_ClearedStaticAlloc( size );

// itterate through all lights
// iterate through all lights
int count = 0;
for( int i = 0; i < this->lightDefs.Num(); i++ )
{
Expand Down
Loading

0 comments on commit 804c16d

Please sign in to comment.