Game Development Community

T3D 1.2 - Remove the Basic Lighting

by Alfio Saitta · in Torque 3D Professional · 04/02/2012 (11:22 pm) · 2 replies

After a long discussion on the IRC server, i decided to help a user to remove from the T3D, the basicLighting to leave the place only to the advancedLighting. Finding the solution was easier than expected, by adjusting the projectGenerator and some modifications to the source. Here are the steps:

1] On the file Tools/projectGenerator/libs/Torque3D.conf around the line 86, comment or remove the line:
includeModule( 'basicLighting' );

2] On the file Tools/projectGenerator/classes/Torque3D.php around the line 100, comment or remove the line:
includeModule( 'basicLighting' );

3] In the file source/lighting/advanced/advancedLightManager.cpp after:
....
#include "renderInstance/renderPrePassMgr.h"
#include "materials/materialManager.h"
#include "math/util/sphereMesh.h"
#include "console/consoleTypes.h"
#include "scene/sceneRenderState.h"

add:
#ifndef TORQUE_BASIC_LIGHTING
F32 AdvancedLightManager::smProjectedShadowFilterDistance = 40.0f;
#endif

4] In the file source/lighting/advanced/advancedLightManager.h after:
....
   GFXVertexBufferHandle<LightVertex> getSphereMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives );
   GFXVertexBufferHandle<LightVertex> getConeMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives );

   LightShadowMap* findShadowMapForObject( SimObject *object );

add:
#ifndef TORQUE_BASIC_LIGHTING
	static F32 getShadowFilterDistance() { return smProjectedShadowFilterDistance; }
#endif

and after:
....
   U32 mConePrimitiveCount;

   LightingShaderConstants* getLightingShaderConstants(GFXShaderConstBuffer* shader);

add:
#ifndef TORQUE_BASIC_LIGHTING
	/// This is used to determine the distance
	/// at which the shadow filtering PostEffect
	/// will be enabled for ProjectedShadow.
	static F32 smProjectedShadowFilterDistance;
#endif

5] On the file source/lighting/common/projectedShadow.cpp change this:
....
#include "lighting/basic/basicLightManager.h"
....

with this:
....
#ifdef TORQUE_BASIC_LIGHTING
#include "lighting/basic/basicLightManager.h"
#else
#include "lighting/advanced/advancedLightManager.h"
#endif
....

and this:
....
   GFX->popActiveRenderTarget();

   // If we're close enough then filter the shadow.
   if ( camDist < BasicLightManager::getShadowFilterDistance() )
   {
      if ( !smShadowFilter )
      ....

with this:
....
   GFX->popActiveRenderTarget();

   // If we're close enough then filter the shadow.
#ifdef TORQUE_BASIC_LIGHTING
   if ( camDist < BasicLightManager::getShadowFilterDistance() )
#else
   if ( camDist < AdvancedLightManager::getShadowFilterDistance() )
#endif
   {
      if ( !smShadowFilter )
      ....

6] Save and close all
7] Regenerate the project with the My Projects/YOUR PROJECT NAME/generateProjects.bat
8] Reopen the project on the VS, and rebuild all

img684.imageshack.us/img684/7317/immaginejk.th.jpg

I hope nobody finds problems during execution. For me everything worked at the first attempt.

#1
04/03/2012 (6:04 pm)
Any improvement in CPU on the client by doing this Alfio?
#2
04/03/2012 (11:01 pm)
No, any improvement worthy of note.

For many projects is recommended to leave the Basic Lighting. Especially since you have to run in older hardware, or do not need a high-impact graphics (eg cellshading or cartoon style games).

In any case, making the above modifications, leaves you the opportunity to build their own project with the inclusion of the BasicLighting, adding this line to your configuration file (My Projects/YOUR PROJECT NAME/buildFiles/config/project.conf):

includeModule( 'basicLighting' );