Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for compiling without Advanced Lighting #2168

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Engine/source/T3D/levelInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
#include "console/consoleTypes.h"
#include "core/stream/bitStream.h"
#include "scene/sceneManager.h"
#if defined(TORQUE_ADVANCED_LIGHTING)
#include "lighting/advanced/advancedLightManager.h"
#include "lighting/advanced/advancedLightBinManager.h"
#endif
#include "sfx/sfxAmbience.h"
#include "sfx/sfxSoundscape.h"
#include "sfx/sfxSystem.h"
Expand Down Expand Up @@ -101,16 +103,21 @@ LevelInfo::LevelInfo()
mAccuTextureName = "";
mAccuTexture = NULL;

#if defined(TORQUE_ADVANCED_LIGHTING)
// Register with the light manager activation signal, and we need to do it first
// so the advanced light bin manager can be instructed about MRT lightmaps
LightManager::smActivateSignal.notify(this, &LevelInfo::_onLMActivate, 0.01f);
#endif
}

//-----------------------------------------------------------------------------

LevelInfo::~LevelInfo()
{
#if defined(TORQUE_ADVANCED_LIGHTING)
LightManager::smActivateSignal.remove(this, &LevelInfo::_onLMActivate);
#endif

if (!mAccuTexture.isNull())
{
mAccuTexture.free();
Expand Down Expand Up @@ -334,7 +341,7 @@ void LevelInfo::_updateSceneGraph()
// If the level info specifies that MRT pre-pass should be used in this scene
// enable it via the appropriate light manager
// (Basic lighting doesn't do anything different right now)
#ifndef TORQUE_DEDICATED
#if !defined(TORQUE_DEDICATED) && defined(TORQUE_ADVANCED_LIGHTING)
if(isClientObject())
_onLMActivate(LIGHTMGR->getId(), true);
#endif
Expand All @@ -347,7 +354,7 @@ void LevelInfo::_updateSceneGraph()

void LevelInfo::_onLMActivate(const char *lm, bool enable)
{
#ifndef TORQUE_DEDICATED
#if !defined(TORQUE_DEDICATED) && defined(TORQUE_ADVANCED_LIGHTING)
// Advanced light manager
if(enable && String(lm) == String("ADVLM"))
{
Expand Down
4 changes: 4 additions & 0 deletions Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
#include "shaderGen/GLSL/accuFeatureGLSL.h"

// Deferred Shading
#if defined(TORQUE_ADVANCED_LIGHTING)
#include "lighting/advanced/glsl/deferredShadingFeaturesGLSL.h"
#endif

static ShaderGen::ShaderGenInitDelegate sInitDelegate;

Expand Down Expand Up @@ -100,11 +102,13 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureGLSL );

// Deferred Shading
#if defined(TORQUE_ADVANCED_LIGHTING)
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapGLSL );
FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsGLSL );
FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsGLSL );
FEATUREMGR->registerFeature( MFT_DeferredEmptySpec, new DeferredEmptySpecGLSL );
#endif
FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureGLSL( "skybox" ) );
FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureGLSL );
}
Expand Down
5 changes: 4 additions & 1 deletion Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#include "materials/materialFeatureTypes.h"
#include "core/module.h"
// Deferred Shading
#if defined(TORQUE_ADVANCED_LIGHTING)
#include "lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h"
#endif
#include "shaderGen/HLSL/accuFeatureHLSL.h"

static ShaderGen::ShaderGenInitDelegate sInitDelegate;
Expand Down Expand Up @@ -100,12 +102,13 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_ForwardShading, new NamedFeatureHLSL( "Forward Shaded Material" ) );

FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL );

#if defined(TORQUE_ADVANCED_LIGHTING)
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapHLSL );
FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsHLSL );
FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsHLSL );
FEATUREMGR->registerFeature( MFT_DeferredEmptySpec, new DeferredEmptySpecHLSL );
#endif
FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureHLSL( "skybox" ) );
FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureHLSL );
}
Expand Down
4 changes: 4 additions & 0 deletions Templates/BaseGame/game/core/globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@
// SoftShadow - Does a simple soft shadow
// SoftShadowHighQuality
$pref::Shadows::filterMode = "SoftShadow";

/// This is the default list of light managers ordered from
/// most to least desirable for initialization.
$lightManager::defaults = "Advanced Lighting" TAB "Basic Lighting";
24 changes: 17 additions & 7 deletions Templates/BaseGame/game/core/lighting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,26 @@ function initLightingSystems(%manager)
exec( %file );
%file = findNextFile( %pattern );
}

// Try the perfered one first.
%success = setLightManager(%manager);

// Did we completely fail to initialize a light manager?
if (!%success)

// Try to initialize the selected light manager directly
// If this fails, try to initialize the light managers in order from most to least preferable
if (setLightManager(%manager))
{
return true;
}
else
{
for(%i = 0; %i < getFieldCount($lightManager::defaults); %i++)
{
%success = setLightManager(getField($lightManager::defaults, %i));

if (%success)
return true;
}

// If we completely failed to initialize a light
// manager then the 3d scene cannot be rendered.
quitWithErrorMessage( "Failed to set a light manager!" );
quitWithErrorMessage( "Failed to set a light manager!" );
}
}

Expand Down
4 changes: 0 additions & 4 deletions Templates/BaseGame/game/data/defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
/// will try the defaults below.
$pref::lightManager = "";

/// This is the default list of light managers ordered from
/// most to least desirable for initialization.
$lightManager::defaults = "Advanced Lighting";

/// A scale to apply to the camera view distance
/// typically used for tuning performance.
$pref::camera::distanceScale = 1.0;
Expand Down