Merge branch 'development' into snapwork

This commit is contained in:
Azaezel 2017-03-05 22:58:29 -06:00
commit f8a81d2634
1598 changed files with 146720 additions and 91 deletions

View file

@ -60,7 +60,7 @@ MODULE_END;
WindDeformationGLSL::WindDeformationGLSL()
: mDep( "shaders/common/gl/wind.glsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/wind.glsl" ))
{
addDependency( &mDep );
}

View file

@ -60,7 +60,7 @@ MODULE_END;
WindDeformationHLSL::WindDeformationHLSL()
: mDep( "shaders/common/wind.hlsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/wind.hlsl" ))
{
addDependency( &mDep );
}

View file

@ -670,8 +670,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
//shader model 4.0 is enough for the generic shaders
const char* shaderModel = "4.0";
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/colorV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/colorP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorP.hlsl"));
shaderData->setField("pixVersion", shaderModel);
shaderData->registerObject();
mGenericShader[GSColor] = shaderData->getShader();
@ -680,8 +680,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/modColorTextureV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/modColorTextureP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureP.hlsl"));
shaderData->setField("pixVersion", shaderModel);
shaderData->registerObject();
mGenericShader[GSModColorTexture] = shaderData->getShader();
@ -690,8 +690,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/addColorTextureV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/addColorTextureP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureP.hlsl"));
shaderData->setField("pixVersion", shaderModel);
shaderData->registerObject();
mGenericShader[GSAddColorTexture] = shaderData->getShader();
@ -700,8 +700,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/textureV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/textureP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureP.hlsl"));
shaderData->setField("pixVersion", shaderModel);
shaderData->registerObject();
mGenericShader[GSTexture] = shaderData->getShader();

View file

@ -154,8 +154,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
ShaderData *shaderData;
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/colorV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/colorP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorP.hlsl"));
shaderData->setField("pixVersion", "3.0");
shaderData->registerObject();
mGenericShader[GSColor] = shaderData->getShader();
@ -164,8 +164,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/modColorTextureV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/modColorTextureP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureP.hlsl"));
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "3.0");
shaderData->registerObject();
@ -175,8 +175,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/addColorTextureV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/addColorTextureP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureP.hlsl"));
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "3.0");
shaderData->registerObject();
@ -186,8 +186,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/textureV.hlsl");
shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/textureP.hlsl");
shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureV.hlsl"));
shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureP.hlsl"));
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "3.0");
shaderData->registerObject();

View file

@ -42,9 +42,9 @@ using namespace Torque;
S32 GFXTextureManager::smTextureReductionLevel = 0;
String GFXTextureManager::smMissingTexturePath("core/art/missingTexture");
String GFXTextureManager::smUnavailableTexturePath("core/art/unavailable");
String GFXTextureManager::smWarningTexturePath("core/art/warnmat");
String GFXTextureManager::smMissingTexturePath(Con::getVariable("$Core::MissingTexturePath"));
String GFXTextureManager::smUnavailableTexturePath(Con::getVariable("$Core::UnAvailableTexturePath"));
String GFXTextureManager::smWarningTexturePath(Con::getVariable("$Core::WarningTexturePath"));
GFXTextureManager::EventSignal GFXTextureManager::smEventSignal;

View file

@ -780,8 +780,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
ShaderData *shaderData;
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/colorV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/colorP.glsl");
shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/colorV.glsl"));
shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/colorP.glsl"));
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();
mGenericShader[GSColor] = shaderData->getShader();
@ -790,8 +790,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/modColorTextureV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/modColorTextureP.glsl");
shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/modColorTextureV.glsl"));
shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/modColorTextureP.glsl"));
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();
@ -801,8 +801,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/addColorTextureV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/addColorTextureP.glsl");
shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/addColorTextureV.glsl"));
shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/addColorTextureP.glsl"));
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();
@ -812,8 +812,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
Sim::getRootGroup()->addObject(shaderData);
shaderData = new ShaderData();
shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/textureV.glsl");
shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/textureP.glsl");
shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/textureV.glsl"));
shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/textureP.glsl"));
shaderData->setSamplerName("$diffuseMap", 0);
shaderData->setField("pixVersion", "2.0");
shaderData->registerObject();

View file

@ -48,10 +48,10 @@ ConsoleDocClass( ShaderData,
"// Used for the procedural clould system\n"
"singleton ShaderData( CloudLayerShader )\n"
"{\n"
" DXVertexShaderFile = \"shaders/common/cloudLayerV.hlsl\";\n"
" DXPixelShaderFile = \"shaders/common/cloudLayerP.hlsl\";\n"
" OGLVertexShaderFile = \"shaders/common/gl/cloudLayerV.glsl\";\n"
" OGLPixelShaderFile = \"shaders/common/gl/cloudLayerP.glsl\";\n"
" DXVertexShaderFile = $Core::CommonShaderPath @ \"/cloudLayerV.hlsl\";\n"
" DXPixelShaderFile = $Core::CommonShaderPath @ \"/cloudLayerP.hlsl\";\n"
" OGLVertexShaderFile = $Core::CommonShaderPath @ \"/gl/cloudLayerV.glsl\";\n"
" OGLPixelShaderFile = $Core::CommonShaderPath @ \"/gl/cloudLayerP.glsl\";\n"
" pixVersion = 2.0;\n"
"};\n"
"@endtsexample\n\n"
@ -109,8 +109,8 @@ void ShaderData::initPersistFields()
"@tsexample\n"
"singleton ShaderData( FlashShader )\n"
"{\n"
"DXVertexShaderFile = \"shaders/common/postFx/flashV.hlsl\";\n"
"DXPixelShaderFile = \"shaders/common/postFx/flashP.hlsl\";\n\n"
"DXVertexShaderFile = $shaderGen::cachePath @ \"/postFx/flashV.hlsl\";\n"
"DXPixelShaderFile = $shaderGen::cachePath @ \"/postFx/flashP.hlsl\";\n\n"
" //Define setting the color of WHITE_COLOR.\n"
"defines = \"WHITE_COLOR=float4(1.0,1.0,1.0,0.0)\";\n\n"
"pixVersion = 2.0\n"

View file

@ -373,3 +373,20 @@ DefineConsoleFunction( mGetAngleBetweenVectors, F32, (VectorF vecA, VectorF vecB
{
return MathUtils::getAngleBetweenVectors(vecA, vecB);
}
DefineConsoleFunction(mGetSignedAngleBetweenVectors, F32, (VectorF vecA, VectorF vecB, VectorF norm), (VectorF::Zero, VectorF::Zero, VectorF::Zero),
"Returns signed angle between two vectors, using a normal for orientation.\n"
"@param vecA First input vector."
"@param vecB Second input vector."
"@param norm Normal/Cross Product vector."
"@returns Angle between both vectors in radians."
"@ingroup Math")
{
if (vecA.isZero() || vecB.isZero() || norm.isZero())
{
Con::errorf("mGetSignedAngleBetweenVectors - Error! Requires all 3 vectors used to be non-zero!");
return 0;
}
return MathUtils::getSignedAngleBetweenVectors(vecA, vecB, norm);
}

View file

@ -371,6 +371,18 @@ F32 getAngleBetweenVectors(VectorF vecA, VectorF vecB)
return angle;
}
F32 getSignedAngleBetweenVectors(VectorF vecA, VectorF vecB, VectorF norm)
{
// angle in 0-180
F32 angle = getAngleBetweenVectors(vecA, vecB);
F32 sign = mSign(mDot(norm, mCross(vecA, vecB)));
// angle in -179-180
F32 signed_angle = angle * sign;
return signed_angle;
}
//-----------------------------------------------------------------------------
void transformBoundingBox(const Box3F &sbox, const MatrixF &mat, const Point3F scale, Box3F &dbox)

View file

@ -161,6 +161,11 @@ namespace MathUtils
///
F32 getAngleBetweenVectors(VectorF vecA, VectorF vecB);
/// Returns the angle between two given vectors, utilizing a normal vector to discertain the angle's sign
///
/// Angles is in RADIANS
///
F32 getSignedAngleBetweenVectors(VectorF vecA, VectorF vecB, VectorF norm);
/// Simple reflection equation - pass in a vector and a normal to reflect off of
inline Point3F reflect( Point3F &inVec, Point3F &norm )

View file

@ -51,6 +51,7 @@ mModuleId(StringTable->EmptyString()),
mSynchronized( false ),
mDeprecated( false ),
mCriticalMerge( false ),
mOverrideExitingObjects(false),
mModuleDescription( StringTable->EmptyString() ),
mAuthor(StringTable->EmptyString()),
mModuleGroup(StringTable->EmptyString()),
@ -91,6 +92,7 @@ void ModuleDefinition::initPersistFields()
addProtectedField( "Synchronized", TypeBool, Offset(mSynchronized, ModuleDefinition), &setSynchronized, &defaultProtectedGetFn, &writeSynchronized, "Whether the module should be synchronized or not. Optional: If not specified then the module is not synchronized." );
addProtectedField( "Deprecated", TypeBool, Offset(mDeprecated, ModuleDefinition), &setDeprecated, &defaultProtectedGetFn, &writeDeprecated, "Whether the module is deprecated or not. Optional: If not specified then the module is not deprecated." );
addProtectedField( "CriticalMerge", TypeBool, Offset(mCriticalMerge, ModuleDefinition), &setDeprecated, &defaultProtectedGetFn, &writeCriticalMerge, "Whether the merging of a module prior to a restart is critical or not. Optional: If not specified then the module is not merge critical." );
addProtectedField( "OverrideExistingObjects", TypeBool, Offset(mOverrideExitingObjects, ModuleDefinition), &setOverrideExistingObjects, &defaultProtectedGetFn, &writeOverrideExistingObjects, "Controls if when this module is loaded and the create function is executed, it will replace existing objects that share names or not.");
addProtectedField( "Description", TypeString, Offset(mModuleDescription, ModuleDefinition), &setModuleDescription, &defaultProtectedGetFn, &writeModuleDescription, "The description typically used for debugging purposes but can be used for anything." );
addProtectedField( "Author", TypeString, Offset(mAuthor, ModuleDefinition), &setAuthor, &defaultProtectedGetFn, &writeAuthor, "The author of the module." );
addProtectedField( "Group", TypeString, Offset(mModuleGroup, ModuleDefinition), &setModuleGroup, &defaultProtectedGetFn, "The module group used typically when loading modules as a group." );

View file

@ -89,6 +89,7 @@ private:
bool mSynchronized;
bool mDeprecated;
bool mCriticalMerge;
bool mOverrideExitingObjects;
StringTableEntry mModuleDescription;
StringTableEntry mAuthor;;
StringTableEntry mModuleGroup;
@ -141,6 +142,8 @@ public:
inline bool getDeprecated( void ) const { return mDeprecated; }
inline void setCriticalMerge( const bool mergeCritical ) { if ( checkUnlocked() ) { mCriticalMerge = mergeCritical; } }
inline bool getCriticalMerge( void ) const { return mCriticalMerge; }
inline void setOverrideExistingObjects(const bool overrideExistingObj) { if (checkUnlocked()) { mOverrideExitingObjects = overrideExistingObj; } }
inline bool getOverrideExistingObjects(void) const { return mOverrideExitingObjects; }
inline void setModuleDescription( const char* pModuleDescription ) { if ( checkUnlocked() ) { mModuleDescription = StringTable->insert(pModuleDescription); } }
inline StringTableEntry getModuleDescription( void ) const { return mModuleDescription; }
inline void setAuthor( const char* pAuthor ) { if ( checkUnlocked() ) { mAuthor = StringTable->insert(pAuthor); } }
@ -206,6 +209,8 @@ protected:
static bool setDeprecated(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setDeprecated(dAtob(data)); return false; }
static bool writeDeprecated( void* obj, StringTableEntry pFieldName ) { return static_cast<ModuleDefinition*>(obj)->getDeprecated() == true; }
static bool writeCriticalMerge( void* obj, StringTableEntry pFieldName ){ return static_cast<ModuleDefinition*>(obj)->getCriticalMerge() == true; }
static bool setOverrideExistingObjects(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setOverrideExistingObjects(dAtob(data)); return false; }
static bool writeOverrideExistingObjects(void* obj, StringTableEntry pFieldName) { return static_cast<ModuleDefinition*>(obj)->getOverrideExistingObjects() == true; }
static bool setModuleDescription(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setModuleDescription(data); return false; }
static bool writeModuleDescription( void* obj, StringTableEntry pFieldName ) { return static_cast<ModuleDefinition*>(obj)->getModuleDescription() != StringTable->EmptyString(); }
static bool setAuthor(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setAuthor(data); return false; }

View file

@ -429,7 +429,22 @@ bool ModuleManager::loadModuleGroup( const char* pModuleGroup )
if ( pScopeSet->isMethod( pLoadReadyModuleDefinition->getCreateFunction() ) )
{
// Yes, so call the create method.
Con::executef( pScopeSet, pLoadReadyModuleDefinition->getCreateFunction() );
//But first, check if we're overriding objects, and if so, set our console var to make that happen while we exec our create function
if (pLoadReadyModuleDefinition->getOverrideExistingObjects())
{
String redefineBehaviorPrev = Con::getVariable("$Con::redefineBehavior");
Con::setVariable("$Con::redefineBehavior", "replaceExisting");
Con::executef(pScopeSet, pLoadReadyModuleDefinition->getCreateFunction());
//And now that we've executed, switch back to the prior behavior
Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
}
else
{
//Nothing to do, just run the create function
Con::executef(pScopeSet, pLoadReadyModuleDefinition->getCreateFunction());
}
}
}
else

View file

@ -411,10 +411,6 @@ bool PostEffect::onAdd()
texFilename[0] == '#' )
continue;
// If '/', then path is specified, open normally
if ( texFilename[0] != '/' )
texFilename = scriptPath.getFullPath() + '/' + texFilename;
// Try to load the texture.
bool success = mTextures[i].set( texFilename, &PostFxTextureProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ) );
if (!success)

View file

@ -236,7 +236,7 @@ void BumpFeatGLSL::setTexData( Material::StageData &stageDat,
ParallaxFeatGLSL::ParallaxFeatGLSL()
: mIncludeDep( "shaders/common/gl/torque.glsl" )
: mIncludeDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
{
addDependency( &mIncludeDep );
}

View file

@ -30,7 +30,7 @@
PixelSpecularGLSL::PixelSpecularGLSL()
: mDep( "shaders/common/gl/lighting.glsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/lighting.glsl" ))
{
addDependency( &mDep );
}

View file

@ -830,7 +830,7 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
//****************************************************************************
DiffuseMapFeatGLSL::DiffuseMapFeatGLSL()
: mTorqueDep("shaders/common/gl/torque.glsl")
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl"))
{
addDependency(&mTorqueDep);
}
@ -1975,7 +1975,7 @@ void ReflectCubeFeatGLSL::setTexData( Material::StageData &stageDat,
//****************************************************************************
RTLightingFeatGLSL::RTLightingFeatGLSL()
: mDep( "shaders/common/gl/lighting.glsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/lighting.glsl" ))
{
addDependency( &mDep );
}
@ -2190,7 +2190,7 @@ ShaderFeature::Resources RTLightingFeatGLSL::getResources( const MaterialFeature
//****************************************************************************
FogFeatGLSL::FogFeatGLSL()
: mFogDep( "shaders/common/gl/torque.glsl" )
: mFogDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
{
addDependency( &mFogDep );
}
@ -2321,7 +2321,7 @@ ShaderFeature::Resources FogFeatGLSL::getResources( const MaterialFeatureData &f
//****************************************************************************
VisibilityFeatGLSL::VisibilityFeatGLSL()
: mTorqueDep( "shaders/common/gl/torque.glsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
{
addDependency( &mTorqueDep );
}
@ -2487,7 +2487,7 @@ void RenderTargetZeroGLSL::processPix( Vector<ShaderComponent*> &componentList,
//****************************************************************************
HDROutGLSL::HDROutGLSL()
: mTorqueDep( "shaders/common/gl/torque.glsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
{
addDependency( &mTorqueDep );
}
@ -2508,7 +2508,7 @@ void HDROutGLSL::processPix( Vector<ShaderComponent*> &componentList,
#include "T3D/fx/groundCover.h"
FoliageFeatureGLSL::FoliageFeatureGLSL()
: mDep( "shaders/common/gl/foliage.glsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/foliage.glsl" ))
{
addDependency( &mDep );
}
@ -2654,7 +2654,7 @@ void ParticleNormalFeatureGLSL::processVert(Vector<ShaderComponent*> &componentL
//****************************************************************************
ImposterVertFeatureGLSL::ImposterVertFeatureGLSL()
: mDep( "shaders/common/gl/imposter.glsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/imposter.glsl" ))
{
addDependency( &mDep );
}

View file

@ -37,8 +37,8 @@ void ShaderGenPrinterGLSL::printShaderHeader( Stream& stream )
stream.write( dStrlen(header1), header1 );
// Cheap HLSL compatibility.
const char* header3 = "#include \"shaders/common/gl/hlslCompat.glsl\"\r\n";
stream.write( dStrlen(header3), header3 );
String header3 = String("#include \"") + String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/hlslCompat.glsl\"\r\n");
stream.write(dStrlen(header3), header3.c_str());
const char* header4 = "\r\n";
stream.write( dStrlen(header4), header4 );

View file

@ -268,7 +268,7 @@ void BumpFeatHLSL::setTexData( Material::StageData &stageDat,
ParallaxFeatHLSL::ParallaxFeatHLSL()
: mIncludeDep( "shaders/common/torque.hlsl" )
: mIncludeDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
{
addDependency( &mIncludeDep );
}

View file

@ -30,7 +30,7 @@
PixelSpecularHLSL::PixelSpecularHLSL()
: mDep( "shaders/common/lighting.hlsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/lighting.hlsl" ))
{
addDependency( &mDep );
}

View file

@ -853,7 +853,7 @@ Var* ShaderFeatureHLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
//****************************************************************************
DiffuseMapFeatHLSL::DiffuseMapFeatHLSL()
: mTorqueDep("shaders/common/torque.hlsl")
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl"))
{
addDependency(&mTorqueDep);
}
@ -2168,7 +2168,7 @@ void ReflectCubeFeatHLSL::setTexData( Material::StageData &stageDat,
//****************************************************************************
RTLightingFeatHLSL::RTLightingFeatHLSL()
: mDep( "shaders/common/lighting.hlsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/lighting.hlsl" ))
{
addDependency( &mDep );
}
@ -2383,7 +2383,7 @@ ShaderFeature::Resources RTLightingFeatHLSL::getResources( const MaterialFeature
//****************************************************************************
FogFeatHLSL::FogFeatHLSL()
: mFogDep( "shaders/common/torque.hlsl" )
: mFogDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
{
addDependency( &mFogDep );
}
@ -2514,7 +2514,7 @@ ShaderFeature::Resources FogFeatHLSL::getResources( const MaterialFeatureData &f
//****************************************************************************
VisibilityFeatHLSL::VisibilityFeatHLSL()
: mTorqueDep( "shaders/common/torque.hlsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
{
addDependency( &mTorqueDep );
}
@ -2681,7 +2681,7 @@ void RenderTargetZeroHLSL::processPix( Vector<ShaderComponent*> &componentList,
//****************************************************************************
HDROutHLSL::HDROutHLSL()
: mTorqueDep( "shaders/common/torque.hlsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
{
addDependency( &mTorqueDep );
}
@ -2702,7 +2702,7 @@ void HDROutHLSL::processPix( Vector<ShaderComponent*> &componentList,
#include "T3D/fx/groundCover.h"
FoliageFeatureHLSL::FoliageFeatureHLSL()
: mDep( "shaders/common/foliage.hlsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/foliage.hlsl" ))
{
addDependency( &mDep );
}
@ -2848,7 +2848,7 @@ void ParticleNormalFeatureHLSL::processVert(Vector<ShaderComponent*> &componentL
//****************************************************************************
ImposterVertFeatureHLSL::ImposterVertFeatureHLSL()
: mDep( "shaders/common/imposter.hlsl" )
: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/imposter.hlsl" ))
{
addDependency( &mDep );
}

View file

@ -70,7 +70,7 @@ MODULE_END;
TerrainFeatGLSL::TerrainFeatGLSL()
: mTorqueDep( "shaders/common/gl/torque.glsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
{
addDependency( &mTorqueDep );
}
@ -297,8 +297,8 @@ U32 TerrainBaseMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) co
}
TerrainDetailMapFeatGLSL::TerrainDetailMapFeatGLSL()
: mTorqueDep( "shaders/common/gl/torque.glsl" ),
mTerrainDep( "shaders/common/terrain/terrain.glsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" )),
mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.glsl" ))
{
addDependency( &mTorqueDep );
@ -667,8 +667,8 @@ U32 TerrainDetailMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd )
TerrainMacroMapFeatGLSL::TerrainMacroMapFeatGLSL()
: mTorqueDep( "shaders/common/gl/torque.glsl" ),
mTerrainDep( "shaders/common/terrain/terrain.glsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" )),
mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.glsl" ))
{
addDependency( &mTorqueDep );

View file

@ -69,7 +69,7 @@ MODULE_END;
TerrainFeatHLSL::TerrainFeatHLSL()
: mTorqueDep( "shaders/common/torque.hlsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
{
addDependency( &mTorqueDep );
}
@ -315,8 +315,8 @@ U32 TerrainBaseMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) co
}
TerrainDetailMapFeatHLSL::TerrainDetailMapFeatHLSL()
: mTorqueDep( "shaders/common/torque.hlsl" ),
mTerrainDep( "shaders/common/terrain/terrain.hlsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" )),
mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.hlsl" ))
{
addDependency( &mTorqueDep );
@ -692,8 +692,8 @@ U32 TerrainDetailMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd )
TerrainMacroMapFeatHLSL::TerrainMacroMapFeatHLSL()
: mTorqueDep( "shaders/common/torque.hlsl" ),
mTerrainDep( "shaders/common/terrain/terrain.hlsl" )
: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" )),
mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.hlsl" ))
{
addDependency( &mTorqueDep );

View file

@ -103,10 +103,26 @@ bool Platform::displaySplashWindow( String path )
bool Platform::closeSplashWindow()
{
SDL_DestroyTexture(gSplashTexture);
SDL_FreeSurface(gSplashImage);
SDL_DestroyRenderer(gSplashRenderer);
SDL_DestroyWindow(gSplashWindow);
if (gSplashTexture != nullptr)
{
SDL_DestroyTexture(gSplashTexture);
gSplashTexture = nullptr;
}
if (gSplashImage != nullptr)
{
SDL_FreeSurface(gSplashImage);
gSplashImage = nullptr;
}
if (gSplashRenderer != nullptr)
{
SDL_DestroyRenderer(gSplashRenderer);
gSplashRenderer = nullptr;
}
if (gSplashWindow != nullptr)
{
SDL_DestroyWindow(gSplashWindow);
gSplashWindow = nullptr;
}
return true;
}

View file

@ -0,0 +1 @@
# Project-specific Cmake configurations go here

View file

@ -0,0 +1 @@
for /R %%a IN (*.dae) do IF EXIST "%%~pna.cached.dts" del "%%~pna.cached.dts"

View file

@ -0,0 +1,15 @@
#!/bin/sh
cd "`dirname "$0"`"
for i in $(find . -type f \( -iname "*.dae" \))
do
len=$((${#i} - 4))
file=${i:0:$len}.cached.dts
if [ -e $file ]
then
echo "Removing ${file}"
rm $file
fi
done

View file

@ -0,0 +1,6 @@
for /R %%a IN (*.cs) do IF EXIST "%%a.dso" del "%%a.dso"
for /R %%a IN (*.cs) do IF EXIST "%%a.edso" del "%%a.edso"
for /R %%a IN (*.gui) do IF EXIST "%%a.dso" del "%%a.dso"
for /R %%a IN (*.gui) do IF EXIST "%%a.edso" del "%%a.edso"
for /R %%a IN (*.ts) do IF EXIST "%%a.dso" del "%%a.dso"
for /R %%a IN (*.ts) do IF EXIST "%%a.edso" del "%%a.edso"

View file

@ -0,0 +1,19 @@
#!/bin/sh
cd "`dirname "$0"`"
for i in $(find . -type f \( -iname "*.cs" \))
do
file=${i}.dso
if [ -e $file ]
then
echo "Removing ${file}"
rm $file
fi
file=${i}.edso
if [ -e $file ]
then
echo "Removing ${file}"
rm $file
fi
done

View file

@ -0,0 +1,6 @@
del /s prefs.cs
del /s config.cs
del /s banlist.cs
del /s config.cs.dso
del /s prefs.cs.dso
del /s banlist.cs.dso

View file

@ -0,0 +1,3 @@
#!/bin/sh
find "`dirname "$0"`" -type f \( -name "prefs.cs" -or -name "config.cs" -or -name "banlist.cs" -or -name "prefs.cs.dso" -or -name "config.cs.dso" -or -name "banlist.cs.dso" \) -exec rm {} \;

View file

@ -0,0 +1,7 @@
REM Delete procedural shaders
del /q /a:-R game\shaders\procedural\*.*
REM Delete dumped shader disassembly files
del /q /s /a:-R *_dis.txt

View file

@ -0,0 +1,4 @@
#!/bin/sh
cd "`dirname "$0"`"
rm -rf game/shaders/procedural/*.*

View file

@ -0,0 +1 @@
<exports/>

View file

@ -0,0 +1,436 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Source groups.
//-----------------------------------------------------------------------------
singleton SFXDescription( AudioMaster );
singleton SFXSource( AudioChannelMaster )
{
description = AudioMaster;
};
singleton SFXDescription( AudioChannel )
{
sourceGroup = AudioChannelMaster;
};
singleton SFXSource( AudioChannelDefault )
{
description = AudioChannel;
};
singleton SFXSource( AudioChannelGui )
{
description = AudioChannel;
};
singleton SFXSource( AudioChannelEffects )
{
description = AudioChannel;
};
singleton SFXSource( AudioChannelMessages )
{
description = AudioChannel;
};
singleton SFXSource( AudioChannelMusic )
{
description = AudioChannel;
};
// Set default playback states of the channels.
AudioChannelMaster.play();
AudioChannelDefault.play();
AudioChannelGui.play();
AudioChannelMusic.play();
AudioChannelMessages.play();
// Stop in-game effects channels.
AudioChannelEffects.stop();
//-----------------------------------------------------------------------------
// Master SFXDescriptions.
//-----------------------------------------------------------------------------
// Master description for interface audio.
singleton SFXDescription( AudioGui )
{
volume = 1.0;
sourceGroup = AudioChannelGui;
};
// Master description for game effects audio.
singleton SFXDescription( AudioEffect )
{
volume = 1.0;
sourceGroup = AudioChannelEffects;
};
// Master description for audio in notifications.
singleton SFXDescription( AudioMessage )
{
volume = 1.0;
sourceGroup = AudioChannelMessages;
};
// Master description for music.
singleton SFXDescription( AudioMusic )
{
volume = 1.0;
sourceGroup = AudioChannelMusic;
};
//-----------------------------------------------------------------------------
// SFX Functions.
//-----------------------------------------------------------------------------
/// This initializes the sound system device from
/// the defaults in the $pref::SFX:: globals.
function sfxStartup()
{
echo( "\nsfxStartup..." );
// If we have a provider set, try initialize a device now.
if( $pref::SFX::provider !$= "" )
{
if( sfxInit() )
return;
else
{
// Force auto-detection.
$pref::SFX::autoDetect = true;
}
}
// If enabled autodetect a safe device.
if( ( !isDefined( "$pref::SFX::autoDetect" ) || $pref::SFX::autoDetect ) &&
sfxAutodetect() )
return;
// Failure.
error( " Failed to initialize device!\n\n" );
$pref::SFX::provider = "";
$pref::SFX::device = "";
return;
}
/// This initializes the sound system device from
/// the defaults in the $pref::SFX:: globals.
function sfxInit()
{
// If already initialized, shut down the current device first.
if( sfxGetDeviceInfo() !$= "" )
sfxShutdown();
// Start it up!
%maxBuffers = $pref::SFX::useHardware ? -1 : $pref::SFX::maxSoftwareBuffers;
if ( !sfxCreateDevice( $pref::SFX::provider, $pref::SFX::device, $pref::SFX::useHardware, %maxBuffers ) )
return false;
// This returns a tab seperated string with
// the initialized system info.
%info = sfxGetDeviceInfo();
$pref::SFX::provider = getField( %info, 0 );
$pref::SFX::device = getField( %info, 1 );
$pref::SFX::useHardware = getField( %info, 2 );
%useHardware = $pref::SFX::useHardware ? "Yes" : "No";
%maxBuffers = getField( %info, 3 );
echo( " Provider: " @ $pref::SFX::provider );
echo( " Device: " @ $pref::SFX::device );
echo( " Hardware: " @ %useHardware );
echo( " Max Buffers: " @ %maxBuffers );
echo( " " );
if( isDefined( "$pref::SFX::distanceModel" ) )
sfxSetDistanceModel( $pref::SFX::distanceModel );
if( isDefined( "$pref::SFX::dopplerFactor" ) )
sfxSetDopplerFactor( $pref::SFX::dopplerFactor );
if( isDefined( "$pref::SFX::rolloffFactor" ) )
sfxSetRolloffFactor( $pref::SFX::rolloffFactor );
// Restore master volume.
sfxSetMasterVolume( $pref::SFX::masterVolume );
// Restore channel volumes.
for( %channel = 0; %channel <= 8; %channel ++ )
sfxSetChannelVolume( %channel, $pref::SFX::channelVolume[ %channel ] );
return true;
}
/// Destroys the current sound system device.
function sfxShutdown()
{
// Store volume prefs.
$pref::SFX::masterVolume = sfxGetMasterVolume();
for( %channel = 0; %channel <= 8; %channel ++ )
$pref::SFX::channelVolume[ %channel ] = sfxGetChannelVolume( %channel );
// We're assuming here that a null info
// string means that no device is loaded.
if( sfxGetDeviceInfo() $= "" )
return;
sfxDeleteDevice();
}
/// Determines which of the two SFX providers is preferable.
function sfxCompareProvider( %providerA, %providerB )
{
if( %providerA $= %providerB )
return 0;
switch$( %providerA )
{
// Always prefer FMOD over anything else.
case "FMOD":
return 1;
// Prefer OpenAL over anything but FMOD.
case "OpenAL":
if( %providerB $= "FMOD" )
return -1;
else
return 1;
// choose XAudio over DirectSound
case "XAudio":
if( %providerB $= "FMOD" || %providerB $= "OpenAL" )
return -1;
else
return 0;
case "DirectSound":
if( %providerB !$= "FMOD" && %providerB !$= "OpenAL" && %providerB !$= "XAudio" )
return 1;
else
return -1;
default:
return -1;
}
}
/// Try to detect and initalize the best SFX device available.
function sfxAutodetect()
{
// Get all the available devices.
%devices = sfxGetAvailableDevices();
// Collect and sort the devices by preferentiality.
%deviceTrySequence = new ArrayObject();
%bestMatch = -1;
%count = getRecordCount( %devices );
for( %i = 0; %i < %count; %i ++ )
{
%info = getRecord( %devices, %i );
%provider = getField( %info, 0 );
%deviceTrySequence.push_back( %provider, %info );
}
%deviceTrySequence.sortfkd( "sfxCompareProvider" );
// Try the devices in order.
%count = %deviceTrySequence.count();
for( %i = 0; %i < %count; %i ++ )
{
%provider = %deviceTrySequence.getKey( %i );
%info = %deviceTrySequence.getValue( %i );
$pref::SFX::provider = %provider;
$pref::SFX::device = getField( %info, 1 );
$pref::SFX::useHardware = getField( %info, 2 );
// By default we've decided to avoid hardware devices as
// they are buggy and prone to problems.
$pref::SFX::useHardware = false;
if( sfxInit() )
{
$pref::SFX::autoDetect = false;
%deviceTrySequence.delete();
return true;
}
}
// Found no suitable device.
error( "sfxAutodetect - Could not initialize a valid SFX device." );
$pref::SFX::provider = "";
$pref::SFX::device = "";
$pref::SFX::useHardware = "";
%deviceTrySequence.delete();
return false;
}
//-----------------------------------------------------------------------------
// Backwards-compatibility with old channel system.
//-----------------------------------------------------------------------------
// Volume channel IDs for backwards-compatibility.
$GuiAudioType = 1; // Interface.
$SimAudioType = 2; // Game.
$MessageAudioType = 3; // Notifications.
$MusicAudioType = 4; // Music.
$AudioChannels[ 0 ] = AudioChannelDefault;
$AudioChannels[ $GuiAudioType ] = AudioChannelGui;
$AudioChannels[ $SimAudioType ] = AudioChannelEffects;
$AudioChannels[ $MessageAudioType ] = AudioChannelMessages;
$AudioChannels[ $MusicAudioType ] = AudioChannelMusic;
function sfxOldChannelToGroup( %channel )
{
return $AudioChannels[ %channel ];
}
function sfxGroupToOldChannel( %group )
{
%id = %group.getId();
for( %i = 0;; %i ++ )
if( !isObject( $AudioChannels[ %i ] ) )
return -1;
else if( $AudioChannels[ %i ].getId() == %id )
return %i;
return -1;
}
function sfxSetMasterVolume( %volume )
{
AudioChannelMaster.setVolume( %volume );
}
function sfxGetMasterVolume( %volume )
{
return AudioChannelMaster.getVolume();
}
function sfxStopAll( %channel )
{
// Don't stop channel itself since that isn't quite what the function
// here intends.
%channel = sfxOldChannelToGroup( %channel );
if (isObject(%channel))
{
foreach( %source in %channel )
%source.stop();
}
}
function sfxGetChannelVolume( %channel )
{
%obj = sfxOldChannelToGroup( %channel );
if( isObject( %obj ) )
return %obj.getVolume();
}
function sfxSetChannelVolume( %channel, %volume )
{
%obj = sfxOldChannelToGroup( %channel );
if( isObject( %obj ) )
%obj.setVolume( %volume );
}
/*singleton SimSet( SFXPausedSet );
/// Pauses the playback of active sound sources.
///
/// @param %channels An optional word list of channel indices or an empty
/// string to pause sources on all channels.
/// @param %pauseSet An optional SimSet which is filled with the paused
/// sources. If not specified the global SfxSourceGroup
/// is used.
///
/// @deprecated
///
function sfxPause( %channels, %pauseSet )
{
// Did we get a set to populate?
if ( !isObject( %pauseSet ) )
%pauseSet = SFXPausedSet;
%count = SFXSourceSet.getCount();
for ( %i = 0; %i < %count; %i++ )
{
%source = SFXSourceSet.getObject( %i );
%channel = sfxGroupToOldChannel( %source.getGroup() );
if( %channels $= "" || findWord( %channels, %channel ) != -1 )
{
%source.pause();
%pauseSet.add( %source );
}
}
}
/// Resumes the playback of paused sound sources.
///
/// @param %pauseSet An optional SimSet which contains the paused sound
/// sources to be resumed. If not specified the global
/// SfxSourceGroup is used.
/// @deprecated
///
function sfxResume( %pauseSet )
{
if ( !isObject( %pauseSet ) )
%pauseSet = SFXPausedSet;
%count = %pauseSet.getCount();
for ( %i = 0; %i < %count; %i++ )
{
%source = %pauseSet.getObject( %i );
%source.play();
}
// Clear our pause set... the caller is left
// to clear his own if he passed one.
%pauseSet.clear();
}*/

View file

@ -0,0 +1,162 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
function createCanvas(%windowTitle)
{
if ($isDedicated)
{
GFXInit::createNullDevice();
return true;
}
// Create the Canvas
$GameCanvas = new GuiCanvas(Canvas)
{
displayWindow = $platform !$= "windows";
};
// Set the window title
if (isObject(Canvas))
{
Canvas.setWindowTitle(%windowTitle @ " - " @ $pref::Video::displayDevice);
configureCanvas();
}
else
{
error("Canvas creation failed. Shutting down.");
quit();
}
}
// Constants for referencing video resolution preferences
$WORD::RES_X = 0;
$WORD::RES_Y = 1;
$WORD::FULLSCREEN = 2;
$WORD::BITDEPTH = 3;
$WORD::REFRESH = 4;
$WORD::AA = 5;
function configureCanvas()
{
// Setup a good default if we don't have one already.
if ($pref::Video::Resolution $= "")
$pref::Video::Resolution = "800 600";
if ($pref::Video::FullScreen $= "")
$pref::Video::FullScreen = false;
if ($pref::Video::BitDepth $= "")
$pref::Video::BitDepth = "32";
if ($pref::Video::RefreshRate $= "")
$pref::Video::RefreshRate = "60";
if ($pref::Video::AA $= "")
$pref::Video::AA = "4";
%resX = $pref::Video::Resolution.x;
%resY = $pref::Video::Resolution.y;
%fs = $pref::Video::FullScreen;
%bpp = $pref::Video::BitDepth;
%rate = $pref::Video::RefreshRate;
%aa = $pref::Video::AA;
if($cliFullscreen !$= "") {
%fs = $cliFullscreen;
$cliFullscreen = "";
}
echo("--------------");
echo("Attempting to set resolution to \"" @ %resX SPC %resY SPC %fs SPC %bpp SPC %rate SPC %aa @ "\"");
%deskRes = getDesktopResolution();
%deskResX = getWord(%deskRes, $WORD::RES_X);
%deskResY = getWord(%deskRes, $WORD::RES_Y);
%deskResBPP = getWord(%deskRes, 2);
// We shouldn't be getting this any more but just in case...
if (%bpp $= "Default")
%bpp = %deskResBPP;
// Make sure we are running at a valid resolution
if (%fs $= "0" || %fs $= "false")
{
// Windowed mode has to use the same bit depth as the desktop
%bpp = %deskResBPP;
// Windowed mode also has to run at a smaller resolution than the desktop
if ((%resX >= %deskResX) || (%resY >= %deskResY))
{
warn("Warning: The requested windowed resolution is equal to or larger than the current desktop resolution. Attempting to find a better resolution");
%resCount = Canvas.getModeCount();
for (%i = (%resCount - 1); %i >= 0; %i--)
{
%testRes = Canvas.getMode(%i);
%testResX = getWord(%testRes, $WORD::RES_X);
%testResY = getWord(%testRes, $WORD::RES_Y);
%testBPP = getWord(%testRes, $WORD::BITDEPTH);
if (%testBPP != %bpp)
continue;
if ((%testResX < %deskResX) && (%testResY < %deskResY))
{
// This will work as our new resolution
%resX = %testResX;
%resY = %testResY;
warn("Warning: Switching to \"" @ %resX SPC %resY SPC %bpp @ "\"");
break;
}
}
}
}
$pref::Video::Resolution = %resX SPC %resY;
$pref::Video::FullScreen = %fs;
$pref::Video::BitDepth = %bpp;
$pref::Video::RefreshRate = %rate;
$pref::Video::AA = %aa;
if (%fs == 1 || %fs $= "true")
%fsLabel = "Yes";
else
%fsLabel = "No";
echo("Accepted Mode: " NL
"--Resolution : " @ %resX SPC %resY NL
"--Full Screen : " @ %fsLabel NL
"--Bits Per Pixel : " @ %bpp NL
"--Refresh Rate : " @ %rate NL
"--AA TypeXLevel : " @ %aa NL
"--------------");
// Actually set the new video mode
Canvas.setVideoMode(%resX, %resY, %fs, %bpp, %rate, %aa);
commandToServer('setClientAspectRatio', %resX, %resY);
// AA piggybacks on the AA setting in $pref::Video::mode.
// We need to parse the setting between AA modes, and then it's level
// It's formatted as AATypexAALevel
// So, FXAAx4 or MLAAx2
if ( isObject( FXAA_PostEffect ) )
FXAA_PostEffect.isEnabled = ( %aa > 0 ) ? true : false;
}

View file

@ -0,0 +1,51 @@
new GuiControl(ConsoleDlg) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
helpTag = "0";
new GuiConsoleEditCtrl(ConsoleEntry) {
profile = "ConsoleTextEditProfile";
horizSizing = "width";
vertSizing = "top";
position = "0 462";
extent = "640 18";
minExtent = "8 8";
visible = "1";
altCommand = "ConsoleEntry::eval();";
helpTag = "0";
maxLength = "255";
historySize = "40";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "1";
useSiblingScroller = "1";
};
new GuiScrollCtrl() {
internalName = "Scroll";
profile = "ConsoleScrollProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "640 462";
minExtent = "8 8";
visible = "1";
helpTag = "0";
willFirstRespond = "1";
hScrollBar = "alwaysOn";
vScrollBar = "alwaysOn";
lockHorizScroll = "false";
lockVertScroll = "false";
constantThumbHeight = "0";
childMargin = "0 0";
new GuiConsole( ConsoleMessageLogView ) {
profile = "GuiConsoleProfile";
position = "0 0";
};
};
};

View file

@ -0,0 +1,108 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
exec("./profiles.cs");
exec("./console.gui");
GlobalActionMap.bind("keyboard", "tilde", "toggleConsole");
function ConsoleEntry::eval()
{
%text = trim(ConsoleEntry.getValue());
if(%text $= "")
return;
// If it's missing a trailing () and it's not a variable,
// append the parentheses.
if(strpos(%text, "(") == -1 && !isDefined(%text)) {
if(strpos(%text, "=") == -1 && strpos(%text, " ") == -1) {
if(strpos(%text, "{") == -1 && strpos(%text, "}") == -1) {
%text = %text @ "()";
}
}
}
// Append a semicolon if need be.
%pos = strlen(%text) - 1;
if(strpos(%text, ";", %pos) == -1 && strpos(%text, "}") == -1) {
%text = %text @ ";";
}
// Turn off warnings for assigning from void
// and evaluate the snippet.
if(!isDefined("$Con::warnVoidAssignment"))
%oldWarnVoidAssignment = true;
else
%oldWarnVoidAssignment = $Con::warnVoidAssignment;
$Con::warnVoidAssignment = false;
echo("==>" @ %text);
if( !startsWith(%text, "function ")
&& !startsWith(%text, "datablock ")
&& !startsWith(%text, "foreach(")
&& !startsWith(%text, "foreach$(")
&& !startsWith(%text, "if(")
&& !startsWith(%text, "while(")
&& !startsWith(%text, "for(")
&& !startsWith(%text, "switch(")
&& !startsWith(%text, "switch$("))
eval("%result = " @ %text);
else
eval(%text);
$Con::warnVoidAssignment = %oldWarnVoidAssignment;
ConsoleEntry.setValue("");
// Echo result.
if(%result !$= "")
echo(%result);
}
function ToggleConsole(%make)
{
if (%make) {
if (ConsoleDlg.isAwake()) {
// Deactivate the console.
Canvas.popDialog(ConsoleDlg);
} else {
Canvas.pushDialog(ConsoleDlg, 99);
}
}
}
function ConsoleDlg::hideWindow(%this)
{
%this-->Scroll.setVisible(false);
}
function ConsoleDlg::showWindow(%this)
{
%this-->Scroll.setVisible(true);
}
function ConsoleDlg::setAlpha( %this, %alpha)
{
if (%alpha $= "")
ConsoleScrollProfile.fillColor = $ConsoleDefaultFillColor;
else
ConsoleScrollProfile.fillColor = getWords($ConsoleDefaultFillColor, 0, 2) SPC %alpha * 255.0;
}

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
if(!isObject(GuiConsoleProfile))
new GuiControlProfile(GuiConsoleProfile)
{
fontType = ($platform $= "macos") ? "Monaco" : "Lucida Console";
fontSize = ($platform $= "macos") ? 13 : 12;
fontColor = "255 255 255";
fontColorHL = "0 255 255";
fontColorNA = "255 0 0";
fontColors[6] = "100 100 100";
fontColors[7] = "100 100 0";
fontColors[8] = "0 0 100";
fontColors[9] = "0 100 0";
category = "Core";
};
if(!isObject(GuiConsoleTextProfile))
new GuiControlProfile(GuiConsoleTextProfile)
{
fontColor = "0 0 0";
autoSizeWidth = true;
autoSizeHeight = true;
textOffset = "2 2";
opaque = true;
fillColor = "255 255 255";
border = true;
borderThickness = 1;
borderColor = "0 0 0";
category = "Core";
};
if(!isObject(ConsoleScrollProfile))
new GuiControlProfile(ConsoleScrollProfile : GuiScrollProfile)
{
opaque = true;
fillColor = "0 0 0 175";
border = 1;
//borderThickness = 0;
borderColor = "0 0 0";
category = "Core";
};
if(!isObject(ConsoleTextEditProfile))
new GuiControlProfile(ConsoleTextEditProfile : GuiTextEditProfile)
{
fillColor = "242 241 240 255";
fillColorHL = "255 255 255";
category = "Core";
};

View file

@ -0,0 +1,102 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
// Cursor toggle functions.
//---------------------------------------------------------------------------------------------
$cursorControlled = true;
function showCursor()
{
if ($cursorControlled)
lockMouse(false);
Canvas.cursorOn();
}
function hideCursor()
{
if ($cursorControlled)
lockMouse(true);
Canvas.cursorOff();
}
//---------------------------------------------------------------------------------------------
// In the CanvasCursor package we add some additional functionality to the built-in GuiCanvas
// class, of which the global Canvas object is an instance. In this case, the behavior we want
// is for the cursor to automatically display, except when the only guis visible want no
// cursor - usually the in game interface.
//---------------------------------------------------------------------------------------------
package CanvasCursorPackage
{
//---------------------------------------------------------------------------------------------
// checkCursor
// The checkCursor method iterates through all the root controls on the canvas checking each
// ones noCursor property. If the noCursor property exists as anything other than false or an
// empty string on every control, the cursor will be hidden.
//---------------------------------------------------------------------------------------------
function GuiCanvas::checkCursor(%this)
{
%count = %this.getCount();
for(%i = 0; %i < %count; %i++)
{
%control = %this.getObject(%i);
if ((%control.noCursor $= "") || !%control.noCursor)
{
showCursor();
return;
}
}
// If we get here, every control requested a hidden cursor, so we oblige.
hideCursor();
}
//---------------------------------------------------------------------------------------------
// The following functions override the GuiCanvas defaults that involve changing the content
// of the Canvas. Basically, all we are doing is adding a call to checkCursor to each one.
//---------------------------------------------------------------------------------------------
function GuiCanvas::setContent(%this, %ctrl)
{
Parent::setContent(%this, %ctrl);
%this.checkCursor();
}
function GuiCanvas::pushDialog(%this, %ctrl, %layer, %center)
{
Parent::pushDialog(%this, %ctrl, %layer, %center);
%this.checkCursor();
}
function GuiCanvas::popDialog(%this, %ctrl)
{
Parent::popDialog(%this, %ctrl);
%this.checkCursor();
}
function GuiCanvas::popLayer(%this, %layer)
{
Parent::popLayer(%this, %layer);
%this.checkCursor();
}
};
activatePackage(CanvasCursorPackage);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,55 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
// CloudLayer
//------------------------------------------------------------------------------
singleton ShaderData( CloudLayerShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/cloudLayerV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/cloudLayerP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/cloudLayerV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/cloudLayerP.glsl";
samplerNames[0] = "$normalHeightMap";
pixVersion = 2.0;
};
//------------------------------------------------------------------------------
// BasicClouds
//------------------------------------------------------------------------------
singleton ShaderData( BasicCloudsShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/basicCloudsV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/basicCloudsP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/basicCloudsV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/basicCloudsP.glsl";
samplerNames[0] = "$diffuseMap";
pixVersion = 2.0;
};

View file

@ -0,0 +1,79 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Anim flag settings - must match material.h
// These cannot be enumed through script becuase it cannot
// handle the "|" operation for combining them together
// ie. Scroll | Wave does not work.
//-----------------------------------------------------------------------------
$scroll = 1;
$rotate = 2;
$wave = 4;
$scale = 8;
$sequence = 16;
// Common stateblock definitions
new GFXSamplerStateData(SamplerClampLinear)
{
textureColorOp = GFXTOPModulate;
addressModeU = GFXAddressClamp;
addressModeV = GFXAddressClamp;
addressModeW = GFXAddressClamp;
magFilter = GFXTextureFilterLinear;
minFilter = GFXTextureFilterLinear;
mipFilter = GFXTextureFilterLinear;
};
new GFXSamplerStateData(SamplerClampPoint)
{
textureColorOp = GFXTOPModulate;
addressModeU = GFXAddressClamp;
addressModeV = GFXAddressClamp;
addressModeW = GFXAddressClamp;
magFilter = GFXTextureFilterPoint;
minFilter = GFXTextureFilterPoint;
mipFilter = GFXTextureFilterPoint;
};
new GFXSamplerStateData(SamplerWrapLinear)
{
textureColorOp = GFXTOPModulate;
addressModeU = GFXTextureAddressWrap;
addressModeV = GFXTextureAddressWrap;
addressModeW = GFXTextureAddressWrap;
magFilter = GFXTextureFilterLinear;
minFilter = GFXTextureFilterLinear;
mipFilter = GFXTextureFilterLinear;
};
new GFXSamplerStateData(SamplerWrapPoint)
{
textureColorOp = GFXTOPModulate;
addressModeU = GFXTextureAddressWrap;
addressModeV = GFXTextureAddressWrap;
addressModeW = GFXTextureAddressWrap;
magFilter = GFXTextureFilterPoint;
minFilter = GFXTextureFilterPoint;
mipFilter = GFXTextureFilterPoint;
};

View file

@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
new GFXStateBlockData( ScatterSkySBData )
{
cullMode = "GFXCullNone";
zDefined = true;
zEnable = true;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
samplerStates[1] = SamplerClampLinear;
vertexColorEnable = true;
};
singleton ShaderData( ScatterSkyShaderData )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/scatterSkyV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/scatterSkyP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/scatterSkyV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/scatterSkyP.glsl";
samplerNames[0] = "$nightSky";
pixVersion = 2.0;
};

View file

@ -0,0 +1,152 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// This file contains shader data necessary for various engine utility functions
//-----------------------------------------------------------------------------
singleton ShaderData( ParticlesShaderData )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/particlesV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/particlesP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/particlesV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/particlesP.glsl";
samplerNames[0] = "$diffuseMap";
samplerNames[1] = "$prepassTex";
samplerNames[2] = "$paraboloidLightMap";
pixVersion = 2.0;
};
singleton ShaderData( OffscreenParticleCompositeShaderData )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/particleCompositeV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/particleCompositeP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/particleCompositeV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/particleCompositeP.glsl";
samplerNames[0] = "$colorSource";
samplerNames[1] = "$edgeSource";
pixVersion = 2.0;
};
//-----------------------------------------------------------------------------
// Planar Reflection
//-----------------------------------------------------------------------------
new ShaderData( ReflectBump )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/planarReflectBumpV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/planarReflectBumpP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectBumpV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectBumpP.glsl";
samplerNames[0] = "$diffuseMap";
samplerNames[1] = "$refractMap";
samplerNames[2] = "$bumpMap";
pixVersion = 2.0;
};
new ShaderData( Reflect )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/planarReflectV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/planarReflectP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectP.glsl";
samplerNames[0] = "$diffuseMap";
samplerNames[1] = "$refractMap";
pixVersion = 1.4;
};
//-----------------------------------------------------------------------------
// fxFoliageReplicator
//-----------------------------------------------------------------------------
new ShaderData( fxFoliageReplicatorShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/fxFoliageReplicatorV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/fxFoliageReplicatorP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/fxFoliageReplicatorV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/fxFoliageReplicatorP.glsl";
samplerNames[0] = "$diffuseMap";
samplerNames[1] = "$alphaMap";
pixVersion = 1.4;
};
singleton ShaderData( VolumetricFogPrePassShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreP.glsl";
pixVersion = 3.0;
};
singleton ShaderData( VolumetricFogShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogP.glsl";
samplerNames[0] = "$prepassTex";
samplerNames[1] = "$depthBuffer";
samplerNames[2] = "$frontBuffer";
samplerNames[3] = "$density";
pixVersion = 3.0;
};
singleton ShaderData( VolumetricFogReflectionShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogRefl.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogRefl.glsl";
pixVersion = 3.0;
};
singleton ShaderData( CubemapSaveShader )
{
DXVertexShaderFile = "shaders/common/cubemapSaveV.hlsl";
DXPixelShaderFile = "shaders/common/cubemapSaveP.hlsl";
OGLVertexShaderFile = "shaders/common/gl/cubemapSaveV.glsl";
OGLPixelShaderFile = "shaders/common/gl/cubemapSaveP.glsl";
samplerNames[0] = "$cubemapTex";
pixVersion = 3.0;
};

View file

@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
/// Used when generating the blended base texture.
singleton ShaderData( TerrainBlendShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/terrain/blendV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/terrain/blendP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/terrain/gl/blendV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/terrain/gl/blendP.glsl";
samplerNames[0] = "layerTex";
samplerNames[1] = "textureMap";
pixVersion = 2.0;
};

View file

@ -0,0 +1,208 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Water
//-----------------------------------------------------------------------------
singleton ShaderData( WaterShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/water/waterV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/water/waterP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/water/gl/waterV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/water/gl/waterP.glsl";
samplerNames[0] = "$bumpMap"; // noise
samplerNames[1] = "$prepassTex"; // #prepass
samplerNames[2] = "$reflectMap"; // $reflectbuff
samplerNames[3] = "$refractBuff"; // $backbuff
samplerNames[4] = "$skyMap"; // $cubemap
samplerNames[5] = "$foamMap"; // foam
samplerNames[6] = "$depthGradMap"; // depthMap ( color gradient )
pixVersion = 3.0;
};
new GFXSamplerStateData(WaterSampler)
{
textureColorOp = GFXTOPModulate;
addressModeU = GFXAddressWrap;
addressModeV = GFXAddressWrap;
addressModeW = GFXAddressWrap;
magFilter = GFXTextureFilterLinear;
minFilter = GFXTextureFilterAnisotropic;
mipFilter = GFXTextureFilterLinear;
maxAnisotropy = 4;
};
singleton GFXStateBlockData( WaterStateBlock )
{
samplersDefined = true;
samplerStates[0] = WaterSampler; // noise
samplerStates[1] = SamplerClampPoint; // #prepass
samplerStates[2] = SamplerClampLinear; // $reflectbuff
samplerStates[3] = SamplerClampPoint; // $backbuff
samplerStates[4] = SamplerWrapLinear; // $cubemap
samplerStates[5] = SamplerWrapLinear; // foam
samplerStates[6] = SamplerClampLinear; // depthMap ( color gradient )
cullDefined = true;
cullMode = "GFXCullCCW";
};
singleton GFXStateBlockData( UnderWaterStateBlock : WaterStateBlock )
{
cullMode = "GFXCullCW";
};
singleton CustomMaterial( WaterMat )
{
sampler["prepassTex"] = "#prepass";
sampler["reflectMap"] = "$reflectbuff";
sampler["refractBuff"] = "$backbuff";
// These samplers are set in code not here.
// This is to allow different WaterObject instances
// to use this same material but override these textures
// per instance.
//sampler["bumpMap"] = "";
//sampler["skyMap"] = "";
//sampler["foamMap"] = "";
//sampler["depthGradMap"] = "";
shader = WaterShader;
stateBlock = WaterStateBlock;
version = 3.0;
useAnisotropic[0] = true;
};
//-----------------------------------------------------------------------------
// Underwater
//-----------------------------------------------------------------------------
singleton ShaderData( UnderWaterShader : WaterShader )
{
defines = "UNDERWATER";
};
singleton CustomMaterial( UnderwaterMat )
{
// These samplers are set in code not here.
// This is to allow different WaterObject instances
// to use this same material but override these textures
// per instance.
//sampler["bumpMap"] = "core/art/water/noise02";
//sampler["foamMap"] = "core/art/water/foam";
sampler["prepassTex"] = "#prepass";
sampler["refractBuff"] = "$backbuff";
shader = UnderWaterShader;
stateBlock = UnderWaterStateBlock;
specular = "0.75 0.75 0.75 1.0";
specularPower = 48.0;
version = 3.0;
};
//-----------------------------------------------------------------------------
// Basic Water
//-----------------------------------------------------------------------------
singleton ShaderData( WaterBasicShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/water/waterBasicV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/water/waterBasicP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/water/gl/waterBasicV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/water/gl/waterBasicP.glsl";
samplerNames[0] = "$bumpMap";
samplerNames[2] = "$reflectMap";
samplerNames[3] = "$refractBuff";
samplerNames[4] = "$skyMap";
samplerNames[5] = "$depthGradMap";
pixVersion = 2.0;
};
singleton GFXStateBlockData( WaterBasicStateBlock )
{
samplersDefined = true;
samplerStates[0] = WaterSampler; // noise
samplerStates[2] = SamplerClampLinear; // $reflectbuff
samplerStates[3] = SamplerClampPoint; // $backbuff
samplerStates[4] = SamplerWrapLinear; // $cubemap
cullDefined = true;
cullMode = "GFXCullCCW";
};
singleton GFXStateBlockData( UnderWaterBasicStateBlock : WaterBasicStateBlock )
{
cullMode = "GFXCullCW";
};
singleton CustomMaterial( WaterBasicMat )
{
// These samplers are set in code not here.
// This is to allow different WaterObject instances
// to use this same material but override these textures
// per instance.
//sampler["bumpMap"] = "core/art/water/noise02";
//sampler["skyMap"] = "$cubemap";
//sampler["prepassTex"] = "#prepass";
sampler["reflectMap"] = "$reflectbuff";
sampler["refractBuff"] = "$backbuff";
cubemap = NewLevelSkyCubemap;
shader = WaterBasicShader;
stateBlock = WaterBasicStateBlock;
version = 2.0;
};
//-----------------------------------------------------------------------------
// Basic UnderWater
//-----------------------------------------------------------------------------
singleton ShaderData( UnderWaterBasicShader : WaterBasicShader)
{
defines = "UNDERWATER";
};
singleton CustomMaterial( UnderwaterBasicMat )
{
// These samplers are set in code not here.
// This is to allow different WaterObject instances
// to use this same material but override these textures
// per instance.
//sampler["bumpMap"] = "core/art/water/noise02";
//samplers["skyMap"] = "$cubemap";
//sampler["prepassTex"] = "#prepass";
sampler["refractBuff"] = "$backbuff";
shader = UnderWaterBasicShader;
stateBlock = UnderWaterBasicStateBlock;
version = 2.0;
};

View file

@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// ATI Vendor Profile Script
//
// This script is responsible for setting global
// capability strings based on the nVidia vendor.
if(GFXCardProfiler::getVersion() < 64.44)
{
$GFX::OutdatedDrivers = true;
$GFX::OutdatedDriversLink = "<a:www.ati.com>You can get newer drivers here.</a>.";
}
else
{
$GFX::OutdatedDrivers = false;
}

View file

@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// nVidia Vendor Profile Script
//
// This script is responsible for setting global
// capability strings based on the nVidia vendor.
if(GFXCardProfiler::getVersion() < 1.2)
{
$GFX::OutdatedDrivers = true;
$GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
}
else
{
$GFX::OutdatedDrivers = false;
}

View file

@ -0,0 +1,39 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// nVidia Vendor Profile Script
//
// This script is responsible for setting global
// capability strings based on the nVidia vendor.
if(GFXCardProfiler::getVersion() < 53.82)
{
$GFX::OutdatedDrivers = true;
$GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
}
else
{
$GFX::OutdatedDrivers = false;
}
// Silly card has trouble with this!
GFXCardProfiler::setCapability("autoMipmapLevel", false);

View file

@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// nVidia Vendor Profile Script
//
// This script is responsible for setting global
// capability strings based on the nVidia vendor.
if(GFXCardProfiler::getVersion() < 56.72)
{
$GFX::OutdatedDrivers = true;
$GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
}
else
{
$GFX::OutdatedDrivers = false;
}

View file

@ -0,0 +1,26 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// Direct3D 9 Renderer Profile Script
//
// This script is responsible for setting global
// capability strings based on the D3D9 renderer type.

View file

@ -0,0 +1,102 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// DInput keyboard, mouse, and joystick prefs
// ----------------------------------------------------------------------------
$pref::Input::MouseEnabled = 1;
$pref::Input::LinkMouseSensitivity = 1;
$pref::Input::KeyboardEnabled = 1;
$pref::Input::KeyboardTurnSpeed = 0.1;
$pref::Input::JoystickEnabled = 0;
// ----------------------------------------------------------------------------
// Video Preferences
// ----------------------------------------------------------------------------
// Set directory paths for various data or default images.
$pref::Video::ProfilePath = "core/gfxprofile";
$pref::Video::missingTexturePath = "core/images/missingTexture.png";
$pref::Video::unavailableTexturePath = "core/images/unavailable.png";
$pref::Video::warningTexturePath = "core/images/warnMat.dds";
$pref::Video::disableVerticalSync = 1;
$pref::Video::mode = "800 600 false 32 60 4";
$pref::Video::defaultFenceCount = 0;
// This disables the hardware FSAA/MSAA so that we depend completely on the FXAA
// post effect which works on all cards and in deferred mode. Note that the new
// Intel Hybrid graphics on laptops will fail to initialize when hardware AA is
// enabled... so you've been warned.
$pref::Video::disableHardwareAA = true;
$pref::Video::disableNormalmapping = false;
$pref::Video::disablePixSpecular = false;
$pref::Video::disableCubemapping = false;
$pref::Video::disableParallaxMapping = false;
// The number of mipmap levels to drop on loaded textures to reduce video memory
// usage. It will skip any textures that have been defined as not allowing down
// scaling.
$pref::Video::textureReductionLevel = 0;
$pref::Video::defaultAnisotropy = 1;
//$pref::Video::Gamma = 1.0;
/// AutoDetect graphics quality levels the next startup.
$pref::Video::autoDetect = 1;
// ----------------------------------------------------------------------------
// Shader stuff
// ----------------------------------------------------------------------------
// This is the path used by ShaderGen to cache procedural shaders. If left
// blank ShaderGen will only cache shaders to memory and not to disk.
$shaderGen::cachePath = "data/shaderCache";
// Uncomment to disable ShaderGen, useful when debugging
//$ShaderGen::GenNewShaders = false;
// Uncomment to dump disassembly for any shader that is compiled to disk. These
// will appear as shadername_dis.txt in the same path as the shader file.
//$gfx::disassembleAllShaders = true;
// ----------------------------------------------------------------------------
// Lighting and shadowing
// ----------------------------------------------------------------------------
// Uncomment to enable AdvancedLighting on the Mac (T3D 2009 Beta 3)
//$pref::machax::enableAdvancedLighting = true;
$sceneLighting::cacheSize = 20000;
$sceneLighting::purgeMethod = "lastCreated";
$sceneLighting::cacheLighting = 1;
$pref::Shadows::textureScalar = 1.0;
$pref::Shadows::disable = false;
// Sets the shadow filtering mode.
// None - Disables filtering.
// SoftShadow - Does a simple soft shadow
// SoftShadowHighQuality
$pref::Shadows::filterMode = "SoftShadow";

View file

@ -0,0 +1,534 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Check if a script file exists, compiled or not.
function isScriptFile(%path)
{
if( isFile(%path @ ".dso") || isFile(%path) )
return true;
return false;
}
function loadMaterials()
{
// Load any materials files for which we only have DSOs.
for( %file = findFirstFile( "*/materials.cs.dso" );
%file !$= "";
%file = findNextFile( "*/materials.cs.dso" ))
{
// Only execute, if we don't have the source file.
%csFileName = getSubStr( %file, 0, strlen( %file ) - 4 );
if( !isFile( %csFileName ) )
exec( %csFileName );
}
// Load all source material files.
for( %file = findFirstFile( "*/materials.cs" );
%file !$= "";
%file = findNextFile( "*/materials.cs" ))
{
exec( %file );
}
// Load all materials created by the material editor if
// the folder exists
if( IsDirectory( "materialEditor" ) )
{
for( %file = findFirstFile( "materialEditor/*.cs.dso" );
%file !$= "";
%file = findNextFile( "materialEditor/*.cs.dso" ))
{
// Only execute, if we don't have the source file.
%csFileName = getSubStr( %file, 0, strlen( %file ) - 4 );
if( !isFile( %csFileName ) )
exec( %csFileName );
}
for( %file = findFirstFile( "materialEditor/*.cs" );
%file !$= "";
%file = findNextFile( "materialEditor/*.cs" ))
{
exec( %file );
}
}
}
function reloadMaterials()
{
reloadTextures();
loadMaterials();
reInitMaterials();
}
function loadDatablockFiles( %datablockFiles, %recurse )
{
if ( %recurse )
{
recursiveLoadDatablockFiles( %datablockFiles, 9999 );
return;
}
%count = %datablockFiles.count();
for ( %i=0; %i < %count; %i++ )
{
%file = %datablockFiles.getKey( %i );
if ( !isFile(%file @ ".dso") && !isFile(%file) )
continue;
exec( %file );
}
// Destroy the incoming list.
//%datablockFiles.delete();
}
function recursiveLoadDatablockFiles( %datablockFiles, %previousErrors )
{
%reloadDatablockFiles = new ArrayObject();
// Keep track of the number of datablocks that
// failed during this pass.
%failedDatablocks = 0;
// Try re-executing the list of datablock files.
%count = %datablockFiles.count();
for ( %i=0; %i < %count; %i++ )
{
%file = %datablockFiles.getKey( %i );
if ( !isFile(%file @ ".dso") && !isFile(%file) )
continue;
// Start counting copy constructor creation errors.
$Con::objectCopyFailures = 0;
exec( %file );
// If errors occured then store this file for re-exec later.
if ( $Con::objectCopyFailures > 0 )
{
%reloadDatablockFiles.add( %file );
%failedDatablocks = %failedDatablocks + $Con::objectCopyFailures;
}
}
// Clear the object copy failure counter so that
// we get console error messages again.
$Con::objectCopyFailures = -1;
// Delete the old incoming list... we're done with it.
//%datablockFiles.delete();
// If we still have datablocks to retry.
%newCount = %reloadDatablockFiles.count();
if ( %newCount > 0 )
{
// If the datablock failures have not been reduced
// from the last pass then we must have a real syntax
// error and not just a bad dependancy.
if ( %previousErrors > %failedDatablocks )
recursiveLoadDatablockFiles( %reloadDatablockFiles, %failedDatablocks );
else
{
// Since we must have real syntax errors do one
// last normal exec to output error messages.
loadDatablockFiles( %reloadDatablockFiles, false );
}
return;
}
// Cleanup the empty reload list.
%reloadDatablockFiles.delete();
}
function getUserPath()
{
%temp = getUserHomeDirectory();
echo(%temp);
if(!isDirectory(%temp))
{
%temp = getUserDataDirectory();
echo(%temp);
if(!isDirectory(%temp))
{
%userPath = "data";
}
else
{
//put it in appdata/roaming
%userPath = %temp @ "/" @ $appName;
}
}
else
{
//put it in user/documents
%userPath = %temp @ "/" @ $appName;
}
return %userPath;
}
function getPrefpath()
{
$prefPath = getUserPath() @ "/preferences";
return $prefPath;
}
function updateTSShapeLoadProgress(%progress, %msg)
{
// Check if the loading GUI is visible and use that instead of the
// separate import progress GUI if possible
if ( isObject(LoadingGui) && LoadingGui.isAwake() )
{
// Save/Restore load progress at the start/end of the import process
if ( %progress == 0 )
{
ColladaImportProgress.savedProgress = LoadingProgress.getValue();
ColladaImportProgress.savedText = LoadingProgressTxt.getValue();
ColladaImportProgress.msgPrefix = "Importing " @ %msg;
%msg = "Reading file into memory...";
}
else if ( %progress == 1.0 )
{
LoadingProgress.setValue( ColladaImportProgress.savedProgress );
LoadingProgressTxt.setValue( ColladaImportProgress.savedText );
}
%msg = ColladaImportProgress.msgPrefix @ ": " @ %msg;
%progressCtrl = LoadingProgress;
%textCtrl = LoadingProgressTxt;
}
else
{
//it's probably the editors using it
if(isFunction("updateToolTSShapeLoadProgress"))
{
updateToolTSShapeLoadProgress(%progress, %msg);
}
}
// Update progress indicators
if (%progress == 0)
{
%progressCtrl.setValue(0.001);
%textCtrl.setText(%msg);
}
else if (%progress != 1.0)
{
%progressCtrl.setValue(%progress);
%textCtrl.setText(%msg);
}
Canvas.repaint(33);
}
/// A helper function which will return the ghosted client object
/// from a server object when connected to a local server.
function serverToClientObject( %serverObject )
{
assert( isObject( LocalClientConnection ), "serverToClientObject() - No local client connection found!" );
assert( isObject( ServerConnection ), "serverToClientObject() - No server connection found!" );
%ghostId = LocalClientConnection.getGhostId( %serverObject );
if ( %ghostId == -1 )
return 0;
return ServerConnection.resolveGhostID( %ghostId );
}
//----------------------------------------------------------------------------
// Debug commands
//----------------------------------------------------------------------------
function netSimulateLag( %msDelay, %packetLossPercent )
{
if ( %packetLossPercent $= "" )
%packetLossPercent = 0;
commandToServer( 'NetSimulateLag', %msDelay, %packetLossPercent );
}
//Various client functions
function validateDatablockName(%name)
{
// remove whitespaces at beginning and end
%name = trim( %name );
// remove numbers at the beginning
%numbers = "0123456789";
while( strlen(%name) > 0 )
{
// the first character
%firstChar = getSubStr( %name, 0, 1 );
// if the character is a number remove it
if( strpos( %numbers, %firstChar ) != -1 )
{
%name = getSubStr( %name, 1, strlen(%name) -1 );
%name = ltrim( %name );
}
else
break;
}
// replace whitespaces with underscores
%name = strreplace( %name, " ", "_" );
// remove any other invalid characters
%invalidCharacters = "-+*/%$&§=()[].?\"#,;!~<>|°^{}";
%name = stripChars( %name, %invalidCharacters );
if( %name $= "" )
%name = "Unnamed";
return %name;
}
//--------------------------------------------------------------------------
// Finds location of %word in %text, starting at %start. Works just like strPos
//--------------------------------------------------------------------------
function wordPos(%text, %word, %start)
{
if (%start $= "") %start = 0;
if (strpos(%text, %word, 0) == -1) return -1;
%count = getWordCount(%text);
if (%start >= %count) return -1;
for (%i = %start; %i < %count; %i++)
{
if (getWord( %text, %i) $= %word) return %i;
}
return -1;
}
//--------------------------------------------------------------------------
// Finds location of %field in %text, starting at %start. Works just like strPos
//--------------------------------------------------------------------------
function fieldPos(%text, %field, %start)
{
if (%start $= "") %start = 0;
if (strpos(%text, %field, 0) == -1) return -1;
%count = getFieldCount(%text);
if (%start >= %count) return -1;
for (%i = %start; %i < %count; %i++)
{
if (getField( %text, %i) $= %field) return %i;
}
return -1;
}
//--------------------------------------------------------------------------
// returns the text in a file with "\n" at the end of each line
//--------------------------------------------------------------------------
function loadFileText( %file)
{
%fo = new FileObject();
%fo.openForRead(%file);
%text = "";
while(!%fo.isEOF())
{
%text = %text @ %fo.readLine();
if (!%fo.isEOF()) %text = %text @ "\n";
}
%fo.delete();
return %text;
}
function setValueSafe(%dest, %val)
{
%cmd = %dest.command;
%alt = %dest.altCommand;
%dest.command = "";
%dest.altCommand = "";
%dest.setValue(%val);
%dest.command = %cmd;
%dest.altCommand = %alt;
}
function shareValueSafe(%source, %dest)
{
setValueSafe(%dest, %source.getValue());
}
function shareValueSafeDelay(%source, %dest, %delayMs)
{
schedule(%delayMs, 0, shareValueSafe, %source, %dest);
}
//------------------------------------------------------------------------------
// An Aggregate Control is a plain GuiControl that contains other controls,
// which all share a single job or represent a single value.
//------------------------------------------------------------------------------
// AggregateControl.setValue( ) propagates the value to any control that has an
// internal name.
function AggregateControl::setValue(%this, %val, %child)
{
for(%i = 0; %i < %this.getCount(); %i++)
{
%obj = %this.getObject(%i);
if( %obj == %child )
continue;
if(%obj.internalName !$= "")
setValueSafe(%obj, %val);
}
}
// AggregateControl.getValue() uses the value of the first control that has an
// internal name, if it has not cached a value via .setValue
function AggregateControl::getValue(%this)
{
for(%i = 0; %i < %this.getCount(); %i++)
{
%obj = %this.getObject(%i);
if(%obj.internalName !$= "")
{
//error("obj = " @ %obj.getId() @ ", " @ %obj.getName() @ ", " @ %obj.internalName );
//error(" value = " @ %obj.getValue());
return %obj.getValue();
}
}
}
// AggregateControl.updateFromChild( ) is called by child controls to propagate
// a new value, and to trigger the onAction() callback.
function AggregateControl::updateFromChild(%this, %child)
{
%val = %child.getValue();
if(%val == mCeil(%val)){
%val = mCeil(%val);
}else{
if ( %val <= -100){
%val = mCeil(%val);
}else if ( %val <= -10){
%val = mFloatLength(%val, 1);
}else if ( %val < 0){
%val = mFloatLength(%val, 2);
}else if ( %val >= 1000){
%val = mCeil(%val);
}else if ( %val >= 100){
%val = mFloatLength(%val, 1);
}else if ( %val >= 10){
%val = mFloatLength(%val, 2);
}else if ( %val > 0){
%val = mFloatLength(%val, 3);
}
}
%this.setValue(%val, %child);
%this.onAction();
}
// default onAction stub, here only to prevent console spam warnings.
function AggregateControl::onAction(%this)
{
}
// call a method on all children that have an internalName and that implement the method.
function AggregateControl::callMethod(%this, %method, %args)
{
for(%i = 0; %i < %this.getCount(); %i++)
{
%obj = %this.getObject(%i);
if(%obj.internalName !$= "" && %obj.isMethod(%method))
eval(%obj @ "." @ %method @ "( " @ %args @ " );");
}
}
// A function used in order to easily parse the MissionGroup for classes . I'm pretty
// sure at this point the function can be easily modified to search the any group as well.
function parseMissionGroup( %className, %childGroup )
{
if( getWordCount( %childGroup ) == 0)
%currentGroup = "MissionGroup";
else
%currentGroup = %childGroup;
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
{
if( (%currentGroup).getObject(%i).getClassName() $= %className )
return true;
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
{
if( parseMissionGroup( %className, (%currentGroup).getObject(%i).getId() ) )
return true;
}
}
}
// A variation of the above used to grab ids from the mission group based on classnames
function parseMissionGroupForIds( %className, %childGroup )
{
if( getWordCount( %childGroup ) == 0)
%currentGroup = "MissionGroup";
else
%currentGroup = %childGroup;
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
{
if( (%currentGroup).getObject(%i).getClassName() $= %className )
%classIds = %classIds @ (%currentGroup).getObject(%i).getId() @ " ";
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
%classIds = %classIds @ parseMissionGroupForIds( %className, (%currentGroup).getObject(%i).getId());
}
return trim( %classIds );
}
//------------------------------------------------------------------------------
// Altered Version of TGB's QuickEditDropDownTextEditCtrl
//------------------------------------------------------------------------------
function QuickEditDropDownTextEditCtrl::onRenameItem( %this )
{
}
function QuickEditDropDownTextEditCtrl::updateFromChild( %this, %ctrl )
{
if( %ctrl.internalName $= "PopUpMenu" )
{
%this->TextEdit.setText( %ctrl.getText() );
}
else if ( %ctrl.internalName $= "TextEdit" )
{
%popup = %this->PopupMenu;
%popup.changeTextById( %popup.getSelected(), %ctrl.getText() );
%this.onRenameItem();
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton Material( Empty )
{
};
singleton Material(WarningMaterial) {
detailMap[0] = "missingTexture";
diffuseColor[0] = "25 16 0";
emissive[0] = false;
translucent = false;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
function initLightingSystems(%manager)
{
echo( "\nInitializing Lighting Systems" );
// First exec the scripts for the different light managers
// in the lighting folder.
%pattern = "./lighting/*/init.cs";
%file = findFirstFile( %pattern );
if ( %file $= "" )
{
// Try for DSOs next.
%pattern = "./lighting/*/init.cs.dso";
%file = findFirstFile( %pattern );
}
while( %file !$= "" )
{
exec( %file );
%file = findNextFile( %pattern );
}
// Try the perfered one first.
%success = setLightManager(%manager);
// Did we completely fail to initialize a light manager?
if (!%success)
{
// If we completely failed to initialize a light
// manager then the 3d scene cannot be rendered.
quitWithErrorMessage( "Failed to set a light manager!" );
}
}
//---------------------------------------------------------------------------------------------
function onLightManagerActivate( %lmName )
{
// Call activation callbacks.
%activateNewFn = "onActivate" @ getWord( %lmName, 0 ) @ "LM";
if( isFunction( %activateNewFn ) )
eval( %activateNewFn @ "();" );
}
//---------------------------------------------------------------------------------------------
function onLightManagerDeactivate( %lmName )
{
// Call deactivation callback.
%deactivateOldFn = "onDeactivate" @ getWord( %lmName, 0 ) @ "LM";
if( isFunction( %deactivateOldFn ) )
eval( %deactivateOldFn @ "();" );
}

View file

@ -0,0 +1,70 @@
singleton ShaderData( ClearGBufferShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredClearGBufferV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredClearGBufferP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredClearGBufferP.glsl";
pixVersion = 2.0;
};
singleton ShaderData( DeferredColorShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredColorShaderP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredColorShaderP.glsl";
pixVersion = 2.0;
};
// Primary Deferred Shader
new GFXStateBlockData( AL_DeferredShadingState : PFX_DefaultStateBlock )
{
cullMode = GFXCullNone;
blendDefined = true;
blendEnable = true;
blendSrc = GFXBlendSrcAlpha;
blendDest = GFXBlendInvSrcAlpha;
samplersDefined = true;
samplerStates[0] = SamplerWrapLinear;
samplerStates[1] = SamplerWrapLinear;
samplerStates[2] = SamplerWrapLinear;
samplerStates[3] = SamplerWrapLinear;
};
new ShaderData( AL_DeferredShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredShadingP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredShadingP.glsl";
samplerNames[0] = "colorBufferTex";
samplerNames[1] = "lightPrePassTex";
samplerNames[2] = "matInfoTex";
samplerNames[3] = "prepassTex";
pixVersion = 2.0;
};
singleton PostEffect( AL_DeferredShading )
{
renderTime = "PFXAfterBin";
renderBin = "SkyBin";
shader = AL_DeferredShader;
stateBlock = AL_DeferredShadingState;
texture[0] = "#color";
texture[1] = "#lightinfo";
texture[2] = "#matinfo";
texture[3] = "#prepass";
target = "$backBuffer";
renderPriority = 10000;
allowReflectPass = true;
};

View file

@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// Default Prefs
/*
$pref::LightManager::sgAtlasMaxDynamicLights = "16";
$pref::LightManager::sgDynamicShadowDetailSize = "0";
$pref::LightManager::sgDynamicShadowQuality = "0";
$pref::LightManager::sgLightingProfileAllowShadows = "1";
$pref::LightManager::sgLightingProfileQuality = "0";
$pref::LightManager::sgMaxBestLights = "10";
$pref::LightManager::sgMultipleDynamicShadows = "1";
$pref::LightManager::sgShowCacheStats = "0";
$pref::LightManager::sgUseBloom = "";
$pref::LightManager::sgUseDRLHighDynamicRange = "0";
$pref::LightManager::sgUseDynamicRangeLighting = "0";
$pref::LightManager::sgUseDynamicShadows = "1";
$pref::LightManager::sgUseToneMapping = "";
*/
exec( "./shaders.cs" );
exec( "./deferredShading.cs" );
function onActivateAdvancedLM()
{
// Don't allow the offscreen target on OSX.
if ( $platform $= "macos" )
return;
// On the Xbox360 we know what will be enabled so don't do any trickery to
// disable MSAA
if ( $platform $= "xenon" )
return;
// Enable the offscreen target so that AL will work
// with MSAA back buffers and for HDR rendering.
AL_FormatToken.enable();
// Activate Deferred Shading
AL_DeferredShading.enable();
}
function onDeactivateAdvancedLM()
{
// Disable the offscreen render target.
AL_FormatToken.disable();
// Deactivate Deferred Shading
AL_DeferredShading.disable();
}
function setAdvancedLighting()
{
setLightManager( "Advanced Lighting" );
}

View file

@ -0,0 +1,276 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// Vector Light State
new GFXStateBlockData( AL_VectorLightState )
{
blendDefined = true;
blendEnable = true;
blendSrc = GFXBlendOne;
blendDest = GFXBlendOne;
blendOp = GFXBlendOpAdd;
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampPoint; // G-buffer
mSamplerNames[0] = "prePassBuffer";
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
mSamplerNames[1] = "shadowMap";
samplerStates[2] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
mSamplerNames[2] = "dynamicShadowMap";
samplerStates[3] = SamplerClampLinear; // SSAO Mask
mSamplerNames[3] = "ssaoMask";
samplerStates[4] = SamplerWrapPoint; // Random Direction Map
cullDefined = true;
cullMode = GFXCullNone;
stencilDefined = true;
stencilEnable = true;
stencilFailOp = GFXStencilOpKeep;
stencilZFailOp = GFXStencilOpKeep;
stencilPassOp = GFXStencilOpKeep;
stencilFunc = GFXCmpLess;
stencilRef = 0;
};
// Vector Light Material
new ShaderData( AL_VectorLightShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/farFrustumQuadV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/vectorLightP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/farFrustumQuadV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/vectorLightP.glsl";
samplerNames[0] = "$prePassBuffer";
samplerNames[1] = "$shadowMap";
samplerNames[2] = "$dynamicShadowMap";
samplerNames[3] = "$ssaoMask";
samplerNames[4] = "$gTapRotationTex";
samplerNames[5] = "$lightBuffer";
samplerNames[6] = "$colorBuffer";
samplerNames[7] = "$matInfoBuffer";
pixVersion = 3.0;
};
new CustomMaterial( AL_VectorLightMaterial )
{
shader = AL_VectorLightShader;
stateBlock = AL_VectorLightState;
sampler["prePassBuffer"] = "#prepass";
sampler["shadowMap"] = "$dynamiclight";
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
sampler["ssaoMask"] = "#ssaoMask";
sampler["lightBuffer"] = "#lightinfo";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
target = "lightinfo";
pixVersion = 3.0;
};
//------------------------------------------------------------------------------
// Convex-geometry light states
new GFXStateBlockData( AL_ConvexLightState )
{
blendDefined = true;
blendEnable = true;
blendSrc = GFXBlendOne;
blendDest = GFXBlendOne;
blendOp = GFXBlendOpAdd;
zDefined = true;
zEnable = true;
zWriteEnable = false;
zFunc = GFXCmpGreaterEqual;
samplersDefined = true;
samplerStates[0] = SamplerClampPoint; // G-buffer
mSamplerNames[0] = "prePassBuffer";
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
mSamplerNames[1] = "shadowMap";
samplerStates[2] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
mSamplerNames[2] = "dynamicShadowMap";
samplerStates[3] = SamplerClampLinear; // Cookie Map
samplerStates[4] = SamplerWrapPoint; // Random Direction Map
cullDefined = true;
cullMode = GFXCullCW;
stencilDefined = true;
stencilEnable = true;
stencilFailOp = GFXStencilOpKeep;
stencilZFailOp = GFXStencilOpKeep;
stencilPassOp = GFXStencilOpKeep;
stencilFunc = GFXCmpLess;
stencilRef = 0;
};
// Point Light Material
new ShaderData( AL_PointLightShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/convexGeometryV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/pointLightP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
samplerNames[0] = "$prePassBuffer";
samplerNames[1] = "$shadowMap";
samplerNames[2] = "$dynamicShadowMap";
samplerNames[3] = "$cookieMap";
samplerNames[4] = "$gTapRotationTex";
samplerNames[5] = "$lightBuffer";
samplerNames[6] = "$colorBuffer";
samplerNames[7] = "$matInfoBuffer";
pixVersion = 3.0;
};
new CustomMaterial( AL_PointLightMaterial )
{
shader = AL_PointLightShader;
stateBlock = AL_ConvexLightState;
sampler["prePassBuffer"] = "#prepass";
sampler["shadowMap"] = "$dynamiclight";
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
sampler["cookieMap"] = "$dynamiclightmask";
sampler["lightBuffer"] = "#lightinfo";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
target = "lightinfo";
pixVersion = 3.0;
};
// Spot Light Material
new ShaderData( AL_SpotLightShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/convexGeometryV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/spotLightP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/spotLightP.glsl";
samplerNames[0] = "$prePassBuffer";
samplerNames[1] = "$shadowMap";
samplerNames[2] = "$dynamicShadowMap";
samplerNames[3] = "$cookieMap";
samplerNames[4] = "$gTapRotationTex";
samplerNames[5] = "$lightBuffer";
samplerNames[6] = "$colorBuffer";
samplerNames[7] = "$matInfoBuffer";
pixVersion = 3.0;
};
new CustomMaterial( AL_SpotLightMaterial )
{
shader = AL_SpotLightShader;
stateBlock = AL_ConvexLightState;
sampler["prePassBuffer"] = "#prepass";
sampler["shadowMap"] = "$dynamiclight";
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
sampler["cookieMap"] = "$dynamiclightmask";
sampler["lightBuffer"] = "#lightinfo";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
target = "lightinfo";
pixVersion = 3.0;
};
/// This material is used for generating prepass
/// materials for objects that do not have materials.
new Material( AL_DefaultPrePassMaterial )
{
// We need something in the first pass else it
// won't create a proper material instance.
//
// We use color here because some objects may not
// have texture coords in their vertex format...
// for example like terrain.
//
diffuseColor[0] = "1 1 1 1";
};
/// This material is used for generating shadow
/// materials for objects that do not have materials.
new Material( AL_DefaultShadowMaterial )
{
// We need something in the first pass else it
// won't create a proper material instance.
//
// We use color here because some objects may not
// have texture coords in their vertex format...
// for example like terrain.
//
diffuseColor[0] = "1 1 1 1";
// This is here mostly for terrain which uses
// this material to create its shadow material.
//
// At sunset/sunrise the sun is looking thru
// backsides of the terrain which often are not
// closed. By changing the material to be double
// sided we avoid holes in the shadowed geometry.
//
doubleSided = true;
};
// Particle System Point Light Material
new ShaderData( AL_ParticlePointLightShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/particlePointLightV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/particlePointLightP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
samplerNames[0] = "$prePassBuffer";
pixVersion = 3.0;
};
new CustomMaterial( AL_ParticlePointLightMaterial )
{
shader = AL_ParticlePointLightShader;
stateBlock = AL_ConvexLightState;
sampler["prePassBuffer"] = "#prepass";
target = "lightinfo";
pixVersion = 3.0;
};

View file

@ -0,0 +1,92 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
exec( "./shadowFilter.cs" );
singleton GFXStateBlockData( BL_ProjectedShadowSBData )
{
blendDefined = true;
blendEnable = true;
blendSrc = GFXBlendDestColor;
blendDest = GFXBlendZero;
zDefined = true;
zEnable = true;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
vertexColorEnable = true;
};
singleton ShaderData( BL_ProjectedShadowShaderData )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/projectedShadowV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/projectedShadowP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/projectedShadowV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/projectedShadowP.glsl";
samplerNames[0] = "inputTex";
pixVersion = 2.0;
};
singleton CustomMaterial( BL_ProjectedShadowMaterial )
{
sampler["inputTex"] = "$miscbuff";
shader = BL_ProjectedShadowShaderData;
stateBlock = BL_ProjectedShadowSBData;
version = 2.0;
forwardLit = true;
};
function onActivateBasicLM()
{
// If HDR is enabled... enable the special format token.
if ( $platform !$= "macos" && HDRPostFx.isEnabled )
AL_FormatToken.enable();
// Create render pass for projected shadow.
new RenderPassManager( BL_ProjectedShadowRPM );
// Create the mesh bin and add it to the manager.
%meshBin = new RenderMeshMgr();
BL_ProjectedShadowRPM.addManager( %meshBin );
// Add both to the root group so that it doesn't
// end up in the MissionCleanup instant group.
RootGroup.add( BL_ProjectedShadowRPM );
RootGroup.add( %meshBin );
}
function onDeactivateBasicLM()
{
// Delete the pass manager which also deletes the bin.
BL_ProjectedShadowRPM.delete();
}
function setBasicLighting()
{
setLightManager( "Basic Lighting" );
}

View file

@ -0,0 +1,76 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton ShaderData( BL_ShadowFilterShaderV )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/basic/shadowFilterV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/basic/shadowFilterP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/basic/gl/shadowFilterV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/basic/gl/shadowFilterP.glsl";
samplerNames[0] = "$diffuseMap";
defines = "BLUR_DIR=float2(1.0,0.0)";
pixVersion = 2.0;
};
singleton ShaderData( BL_ShadowFilterShaderH : BL_ShadowFilterShaderV )
{
defines = "BLUR_DIR=float2(0.0,1.0)";
};
singleton GFXStateBlockData( BL_ShadowFilterSB : PFX_DefaultStateBlock )
{
colorWriteDefined=true;
colorWriteRed=false;
colorWriteGreen=false;
colorWriteBlue=false;
blendDefined = true;
blendEnable = true;
};
// NOTE: This is ONLY used in Basic Lighting, and
// only directly by the ProjectedShadow. It is not
// meant to be manually enabled like other PostEffects.
singleton PostEffect( BL_ShadowFilterPostFx )
{
// Blur vertically
shader = BL_ShadowFilterShaderV;
stateBlock = PFX_DefaultStateBlock;
targetClear = "PFXTargetClear_OnDraw";
targetClearColor = "0 0 0 0";
texture[0] = "$inTex";
target = "$outTex";
// Blur horizontal
new PostEffect()
{
shader = BL_ShadowFilterShaderH;
stateBlock = PFX_DefaultStateBlock;
texture[0] = "$inTex";
target = "$outTex";
};
};

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
new ShaderData(BlurDepthShader)
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/boxFilterV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/boxFilterP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/gl/boxFilterV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/gl/boxFilterP.glsl";
pixVersion = 2.0;
};

View file

@ -0,0 +1,90 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Initialize core sub system functionality such as audio, the Canvas, PostFX,
// rendermanager, light managers, etc.
//
// Note that not all of these need to be initialized before the client, although
// the audio should and the canvas definitely needs to be. I've put things here
// to distinguish between the purpose and functionality of the various client
// scripts. Game specific script isn't needed until we reach the shell menus
// and start a game or connect to a server. We get the various subsystems ready
// to go, and then use initClient() to handle the rest of the startup sequence.
//
// If this is too convoluted we can reduce this complexity after futher testing
// to find exactly which subsystems should be readied before kicking things off.
// ----------------------------------------------------------------------------
//We need to hook the missing/warn material stuff early, so do it here
$Core::MissingTexturePath = "core/images/missingTexture";
$Core::UnAvailableTexturePath = "core/images/unavailable";
$Core::WarningTexturePath = "core/images/warnMat";
$Core::CommonShaderPath = "core/shaders";
exec("./helperFunctions.cs");
// We need some of the default GUI profiles in order to get the canvas and
// other aspects of the GUI system ready.
exec("./profiles.cs");
//This is a bit of a shortcut, but we'll load the client's default settings to ensure all the prefs get initialized correctly
%prefPath = getPrefpath();
if ( isFile( %prefPath @ "/clientPrefs.cs" ) )
exec( %prefPath @ "/clientPrefs.cs" );
else
exec("data/defaults.cs");
%der = $pref::Video::displayDevice;
// Initialization of the various subsystems requires some of the preferences
// to be loaded... so do that first.
exec("./globals.cs");
exec("./canvas.cs");
exec("./cursor.cs");
exec("./renderManager.cs");
exec("./lighting.cs");
exec("./audio.cs");
exec("./sfx/audioAmbience.cs");
exec("./sfx/audioData.cs");
exec("./sfx/audioDescriptions.cs");
exec("./sfx/audioEnvironments.cs");
exec("./sfx/audioStates.cs");
exec("./parseArgs.cs");
// Materials and Shaders for rendering various object types
exec("./gfxData/commonMaterialData.cs");
exec("./gfxData/shaders.cs");
exec("./gfxData/terrainBlock.cs");
exec("./gfxData/water.cs");
exec("./gfxData/scatterSky.cs");
exec("./gfxData/clouds.cs");
// Initialize all core post effects.
exec("./postFx.cs");
// Seed the random number generator.
setRandomSeed();

View file

@ -0,0 +1,392 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Support functions used to manage the directory list
function pushFront(%list, %token, %delim)
{
if (%list !$= "")
return %token @ %delim @ %list;
return %token;
}
function pushBack(%list, %token, %delim)
{
if (%list !$= "")
return %list @ %delim @ %token;
return %token;
}
function popFront(%list, %delim)
{
return nextToken(%list, unused, %delim);
}
function parseArgs()
{
for ($i = 1; $i < $Game::argc ; $i++)
{
$arg = $Game::argv[$i];
$nextArg = $Game::argv[$i+1];
$hasNextArg = $Game::argc - $i > 1;
$logModeSpecified = false;
// Check for dedicated run
/*if( stricmp($arg,"-dedicated") == 0 )
{
$userDirs = $defaultGame;
$dirCount = 1;
$isDedicated = true;
}*/
switch$ ($arg)
{
//--------------------
case "-dedicated":
$userDirs = $defaultGame;
$dirCount = 1;
$isDedicated = true;
$Server::Dedicated = true;
enableWinConsole(true);
$argUsed[%i]++;
//--------------------
case "-mission":
$argUsed[%i]++;
if ($hasNextArg)
{
$missionArg = $nextArg;
$argUsed[%i+1]++;
%i++;
}
else
error("Error: Missing Command Line argument. Usage: -mission <filename>");
//--------------------
case "-connect":
$argUsed[%i]++;
if ($hasNextArg)
{
$JoinGameAddress = $nextArg;
$argUsed[%i+1]++;
%i++;
}
else
error("Error: Missing Command Line argument. Usage: -connect <ip_address>");
//--------------------
case "-log":
$argUsed[$i]++;
if ($hasNextArg)
{
// Turn on console logging
if ($nextArg != 0)
{
// Dump existing console to logfile first.
$nextArg += 4;
}
setLogMode($nextArg);
$logModeSpecified = true;
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -log <Mode: 0,1,2>");
//--------------------
case "-dir":
$argUsed[$i]++;
if ($hasNextArg)
{
// Append the mod to the end of the current list
$userDirs = strreplace($userDirs, $nextArg, "");
$userDirs = pushFront($userDirs, $nextArg, ";");
$argUsed[$i+1]++;
$i++;
$dirCount++;
}
else
error("Error: Missing Command Line argument. Usage: -dir <dir_name>");
//--------------------
// changed the default behavior of this command line arg. It now
// defaults to ONLY loading the game, not tools
// default auto-run already loads in tools --SRZ 11/29/07
case "-game":
$argUsed[$i]++;
if ($hasNextArg)
{
// Set the selected dir --NOTE: we no longer allow tools with this argument
/*
if( $isDedicated )
{
$userDirs = $nextArg;
$dirCount = 1;
}
else
{
$userDirs = "tools;" @ $nextArg;
$dirCount = 2;
}
*/
$userDirs = $nextArg;
$dirCount = 1;
$argUsed[$i+1]++;
$i++;
error($userDirs);
}
else
error("Error: Missing Command Line argument. Usage: -game <game_name>");
//--------------------
case "-console":
enableWinConsole(true);
$argUsed[$i]++;
//--------------------
case "-jSave":
$argUsed[$i]++;
if ($hasNextArg)
{
echo("Saving event log to journal: " @ $nextArg);
saveJournal($nextArg);
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -jSave <journal_name>");
//--------------------
case "-jPlay":
$argUsed[$i]++;
if ($hasNextArg)
{
playJournal($nextArg);
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -jPlay <journal_name>");
//--------------------
case "-jPlayToVideo":
$argUsed[$i]++;
if ($hasNextArg)
{
$VideoCapture::journalName = $nextArg;
$VideoCapture::captureFromJournal = true;
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -jPlayToVideo <journal_name>");
//--------------------
case "-vidCapFile":
$argUsed[$i]++;
if ($hasNextArg)
{
$VideoCapture::fileName = $nextArg;
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -vidCapFile <ouput_video_name>");
//--------------------
case "-vidCapFPS":
$argUsed[$i]++;
if ($hasNextArg)
{
$VideoCapture::fps = $nextArg;
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -vidCapFPS <ouput_video_framerate>");
//--------------------
case "-vidCapEncoder":
$argUsed[$i]++;
if ($hasNextArg)
{
$VideoCapture::encoder = $nextArg;
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -vidCapEncoder <ouput_video_encoder>");
//--------------------
case "-vidCapWidth":
$argUsed[$i]++;
if ($hasNextArg)
{
$videoCapture::width = $nextArg;
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -vidCapWidth <ouput_video_width>");
//--------------------
case "-vidCapHeight":
$argUsed[$i]++;
if ($hasNextArg)
{
$videoCapture::height = $nextArg;
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -vidCapHeight <ouput_video_height>");
//--------------------
case "-level":
$argUsed[$i]++;
if ($hasNextArg)
{
%hasExt = strpos($nextArg, ".mis");
if(%hasExt == -1)
{
$levelToLoad = $nextArg @ " ";
for(%i = $i + 2; %i < $Game::argc; %i++)
{
$arg = $Game::argv[%i];
%hasExt = strpos($arg, ".mis");
if(%hasExt == -1)
{
$levelToLoad = $levelToLoad @ $arg @ " ";
} else
{
$levelToLoad = $levelToLoad @ $arg;
break;
}
}
}
else
{
$levelToLoad = $nextArg;
}
$argUsed[$i+1]++;
$i++;
}
else
error("Error: Missing Command Line argument. Usage: -level <level file name (no path), with or without extension>");
//-------------------
case "-worldeditor":
$startWorldEditor = true;
$argUsed[$i]++;
//-------------------
case "-guieditor":
$startGUIEditor = true;
$argUsed[$i]++;
//-------------------
case "-help":
$displayHelp = true;
$argUsed[$i]++;
//-------------------
case "-compileAll":
$compileAll = true;
$argUsed[$i]++;
//-------------------
case "-compileTools":
$compileTools = true;
$argUsed[$i]++;
//-------------------
case "-genScript":
$genScript = true;
$argUsed[$i]++;
case "-fullscreen":
$cliFullscreen = true;
$argUsed[%i]++;
case "-windowed":
$cliFullscreen = false;
$argUsed[%i]++;
case "-openGL":
$pref::Video::displayDevice = "OpenGL";
$argUsed[%i]++;
case "-directX":
$pref::Video::displayDevice = "D3D";
$argUsed[%i]++;
case "-autoVideo":
$pref::Video::displayDevice = "";
$argUsed[%i]++;
case "-prefs":
$argUsed[%i]++;
if ($hasNextArg) {
exec($nextArg, true, true);
$argUsed[%i+1]++;
%i++;
}
else
error("Error: Missing Command Line argument. Usage: -prefs <path/script.cs>");
//-------------------
default:
$argUsed[$i]++;
if($userDirs $= "")
$userDirs = $arg;
}
}
//-----------------------------------------------
// Play journal to video file?
if ($VideoCapture::captureFromJournal && $VideoCapture::journalName !$= "")
{
if ($VideoCapture::fileName $= "")
$VideoCapture::fileName = $VideoCapture::journalName;
if ($VideoCapture::encoder $= "")
$VideoCapture::encoder = "THEORA";
if ($VideoCapture::fps $= "")
$VideoCapture::fps = 30;
if ($videoCapture::width $= "")
$videoCapture::width = 0;
if ($videoCapture::height $= "")
$videoCapture::height = 0;
playJournalToVideo( $VideoCapture::journalName, $VideoCapture::fileName,
$VideoCapture::encoder, $VideoCapture::fps,
$videoCapture::width SPC $videoCapture::height );
}
}

View file

@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton ShaderData( GammaShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gammaP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/gammaP.glsl";
samplerNames[0] = "$backBuffer";
samplerNames[1] = "$colorCorrectionTex";
pixVersion = 2.0;
};
singleton GFXStateBlockData( GammaStateBlock : PFX_DefaultStateBlock )
{
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
samplerStates[1] = SamplerClampLinear;
};
singleton PostEffect( GammaPostFX )
{
isEnabled = true;
allowReflectPass = true;
renderTime = "PFXBeforeBin";
renderBin = "EditorBin";
renderPriority = 9999;
shader = GammaShader;
stateBlock = GammaStateBlock;
texture[0] = "$backBuffer";
texture[1] = $HDRPostFX::colorCorrectionRamp;
targetFormat = getBestHDRFormat();
};
function GammaPostFX::preProcess( %this )
{
if ( %this.texture[1] !$= $HDRPostFX::colorCorrectionRamp )
%this.setTexture( 1, $HDRPostFX::colorCorrectionRamp );
}
function GammaPostFX::setShaderConsts( %this )
{
%clampedGamma = mClamp( $pref::Video::Gamma, 2.0, 2.5);
%this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma );
%this.setShaderConst( "$Brightness", $pref::Video::Brightness );
%this.setShaderConst( "$Contrast", $pref::Video::Contrast );
}

View file

@ -0,0 +1,186 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// An implementation of "Practical Morphological Anti-Aliasing" from
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
// Fernando Navarro, and Diego Gutierrez.
//
// http://www.iryoku.com/mlaa/
// NOTE: This is currently disabled in favor of FXAA. See
// core\scripts\client\canvas.cs if you want to re-enable it.
singleton GFXStateBlockData( MLAA_EdgeDetectStateBlock : PFX_DefaultStateBlock )
{
// Mark the edge pixels in stencil.
stencilDefined = true;
stencilEnable = true;
stencilPassOp = GFXStencilOpReplace;
stencilFunc = GFXCmpAlways;
stencilRef = 1;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
};
singleton ShaderData( MLAA_EdgeDetectionShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/edgeDetectionP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/edgeDetectionP.glsl";
samplerNames[0] = "$colorMapG";
samplerNames[1] = "$prepassMap";
pixVersion = 3.0;
};
singleton GFXStateBlockData( MLAA_BlendWeightCalculationStateBlock : PFX_DefaultStateBlock )
{
// Here we want to process only marked pixels.
stencilDefined = true;
stencilEnable = true;
stencilPassOp = GFXStencilOpKeep;
stencilFunc = GFXCmpEqual;
stencilRef = 1;
samplersDefined = true;
samplerStates[0] = SamplerClampPoint;
samplerStates[1] = SamplerClampLinear;
samplerStates[2] = SamplerClampPoint;
};
singleton ShaderData( MLAA_BlendWeightCalculationShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/passthruV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/blendWeightCalculationP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/passthruV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/blendWeightCalculationP.glsl";
samplerNames[0] = "$edgesMap";
samplerNames[1] = "$edgesMapL";
samplerNames[2] = "$areaMap";
pixVersion = 3.0;
};
singleton GFXStateBlockData( MLAA_NeighborhoodBlendingStateBlock : PFX_DefaultStateBlock )
{
// Here we want to process only marked pixels too.
stencilDefined = true;
stencilEnable = true;
stencilPassOp = GFXStencilOpKeep;
stencilFunc = GFXCmpEqual;
stencilRef = 1;
samplersDefined = true;
samplerStates[0] = SamplerClampPoint;
samplerStates[1] = SamplerClampLinear;
samplerStates[2] = SamplerClampPoint;
};
singleton ShaderData( MLAA_NeighborhoodBlendingShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/neighborhoodBlendingP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/neighborhoodBlendingP.glsl";
samplerNames[0] = "$blendMap";
samplerNames[1] = "$colorMapL";
samplerNames[2] = "$colorMap";
pixVersion = 3.0;
};
singleton PostEffect( MLAAFx )
{
isEnabled = false;
allowReflectPass = false;
renderTime = "PFXAfterDiffuse";
texture[0] = "$backBuffer"; //colorMapG
texture[1] = "#prepass"; // Used for depth detection
target = "$outTex";
targetClear = PFXTargetClear_OnDraw;
targetClearColor = "0 0 0 0";
stateBlock = MLAA_EdgeDetectStateBlock;
shader = MLAA_EdgeDetectionShader;
// The luma calculation weights which can be user adjustable
// per-scene if nessasary. The default value of...
//
// 0.2126 0.7152 0.0722
//
// ... is the HDTV ITU-R Recommendation BT. 709.
lumaCoefficients = "0.2126 0.7152 0.0722";
// The tweakable color threshold used to select
// the range of edge pixels to blend.
threshold = 0.1;
// The depth delta threshold used to select
// the range of edge pixels to blend.
depthThreshold = 0.01;
new PostEffect()
{
internalName = "blendingWeightsCalculation";
target = "$outTex";
targetClear = PFXTargetClear_OnDraw;
shader = MLAA_BlendWeightCalculationShader;
stateBlock = MLAA_BlendWeightCalculationStateBlock;
texture[0] = "$inTex"; // Edges mask
texture[1] = "$inTex"; // Edges mask
texture[2] = "core/images/AreaMap33.dds";
};
new PostEffect()
{
internalName = "neighborhoodBlending";
shader = MLAA_NeighborhoodBlendingShader;
stateBlock = MLAA_NeighborhoodBlendingStateBlock;
texture[0] = "$inTex"; // Blend weights
texture[1] = "$backBuffer";
texture[2] = "$backBuffer";
};
};
function MLAAFx::setShaderConsts(%this)
{
%this.setShaderConst("$lumaCoefficients", %this.lumaCoefficients);
%this.setShaderConst("$threshold", %this.threshold);
%this.setShaderConst("$depthThreshold", %this.depthThreshold);
}

View file

@ -0,0 +1,53 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton ShaderData( PFX_MotionBlurShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; //we use the bare-bones postFxV.hlsl
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/motionBlurP.hlsl"; //new pixel shader
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/motionBlurP.glsl";
samplerNames[0] = "$backBuffer";
samplerNames[1] = "$prepassTex";
pixVersion = 3.0;
};
singleton PostEffect(MotionBlurFX)
{
isEnabled = false;
renderTime = "PFXAfterDiffuse";
shader = PFX_MotionBlurShader;
stateBlock = PFX_DefaultStateBlock;
texture[0] = "$backbuffer";
texture[1] = "#prepass";
target = "$backBuffer";
};
function MotionBlurFX::setShaderConsts(%this)
{
%this.setShaderConst( "$velocityMultiplier", 3000 );
}

View file

@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton GFXStateBlockData( PFX_CausticsStateBlock : PFX_DefaultStateBlock )
{
blendDefined = true;
blendEnable = true;
blendSrc = GFXBlendOne;
blendDest = GFXBlendOne;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
samplerStates[1] = SamplerWrapLinear;
samplerStates[2] = SamplerWrapLinear;
};
singleton ShaderData( PFX_CausticsShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/causticsP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/gl/causticsP.glsl";
samplerNames[0] = "$prepassTex";
samplerNames[1] = "$causticsTex0";
samplerNames[2] = "$causticsTex1";
pixVersion = 3.0;
};
singleton PostEffect( CausticsPFX )
{
isEnabled = false;
renderTime = "PFXAfterDiffuse";
renderBin = "ObjTranslucentBin";
//renderPriority = 0.1;
shader = PFX_CausticsShader;
stateBlock = PFX_CausticsStateBlock;
texture[0] = "#prepass";
texture[1] = "core/images/caustics_1";
texture[2] = "core/images/caustics_2";
target = "$backBuffer";
};

View file

@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
///
$CAPostFx::enabled = false;
/// The lens distortion coefficient.
$CAPostFx::distCoeffecient = -0.05;
/// The cubic distortion value.
$CAPostFx::cubeDistortionFactor = -0.1;
/// The amount and direction of the maxium shift for
/// the red, green, and blue channels.
$CAPostFx::colorDistortionFactor = "0.005 -0.005 0.01";
singleton GFXStateBlockData( PFX_DefaultChromaticLensStateBlock )
{
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampPoint;
};
singleton ShaderData( PFX_ChromaticLensShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/chromaticLens.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/chromaticLens.glsl";
samplerNames[0] = "$backBuffer";
pixVersion = 3.0;
};
singleton PostEffect( ChromaticLensPostFX )
{
renderTime = "PFXAfterDiffuse";
renderPriority = 0.2;
isEnabled = false;
allowReflectPass = false;
shader = PFX_ChromaticLensShader;
stateBlock = PFX_DefaultChromaticLensStateBlock;
texture[0] = "$backBuffer";
target = "$backBuffer";
};
function ChromaticLensPostFX::setShaderConsts( %this )
{
%this.setShaderConst( "$distCoeff", $CAPostFx::distCoeffecient );
%this.setShaderConst( "$cubeDistort", $CAPostFx::cubeDistortionFactor );
%this.setShaderConst( "$colorDistort", $CAPostFx::colorDistortionFactor );
}

View file

@ -0,0 +1,72 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
$PostFXManager::Settings::EnableVignette = "1";
$PostFXManager::Settings::EnableDOF = "1";
$PostFXManager::Settings::EnabledSSAO = "1";
$PostFXManager::Settings::EnableHDR = "1";
$PostFXManager::Settings::EnableLightRays = "1";
$PostFXManager::Settings::EnablePostFX = "1";
$PostFXManager::Settings::Vignette::VMax = "0.6";
$PostFXManager::Settings::DOF::BlurCurveFar = "";
$PostFXManager::Settings::DOF::BlurCurveNear = "";
$PostFXManager::Settings::DOF::BlurMax = "";
$PostFXManager::Settings::DOF::BlurMin = "";
$PostFXManager::Settings::DOF::EnableAutoFocus = "";
$PostFXManager::Settings::DOF::EnableDOF = "";
$PostFXManager::Settings::DOF::FocusRangeMax = "";
$PostFXManager::Settings::DOF::FocusRangeMin = "";
$PostFXManager::Settings::HDR::adaptRate = "2";
$PostFXManager::Settings::HDR::blueShiftColor = "1.05 0.97 1.27";
$PostFXManager::Settings::HDR::brightPassThreshold = "1";
$PostFXManager::Settings::HDR::enableBloom = "1";
$PostFXManager::Settings::HDR::enableBlueShift = "0";
$PostFXManager::Settings::HDR::enableToneMapping = "0.5";
$PostFXManager::Settings::HDR::gaussMean = "0";
$PostFXManager::Settings::HDR::gaussMultiplier = "0.3";
$PostFXManager::Settings::HDR::gaussStdDev = "0.8";
$PostFXManager::Settings::HDR::keyValue = "0.18";
$PostFXManager::Settings::HDR::minLuminace = "0.001";
$PostFXManager::Settings::HDR::whiteCutoff = "1";
$PostFXManager::Settings::LightRays::brightScalar = "0.75";
$PostFXManager::Settings::LightRays::decay = "1.0";
$PostFXManager::Settings::LightRays::density = "0.94";
$PostFXManager::Settings::LightRays::numSamples = "40";
$PostFXManager::Settings::LightRays::weight = "5.65";
$PostFXManager::Settings::SSAO::blurDepthTol = "0.001";
$PostFXManager::Settings::SSAO::blurNormalTol = "0.95";
$PostFXManager::Settings::SSAO::lDepthMax = "2";
$PostFXManager::Settings::SSAO::lDepthMin = "0.2";
$PostFXManager::Settings::SSAO::lDepthPow = "0.2";
$PostFXManager::Settings::SSAO::lNormalPow = "2";
$PostFXManager::Settings::SSAO::lNormalTol = "-0.5";
$PostFXManager::Settings::SSAO::lRadius = "1";
$PostFXManager::Settings::SSAO::lStrength = "10";
$PostFXManager::Settings::SSAO::overallStrength = "2";
$PostFXManager::Settings::SSAO::quality = "0";
$PostFXManager::Settings::SSAO::sDepthMax = "1";
$PostFXManager::Settings::SSAO::sDepthMin = "0.1";
$PostFXManager::Settings::SSAO::sDepthPow = "1";
$PostFXManager::Settings::SSAO::sNormalPow = "1";
$PostFXManager::Settings::SSAO::sNormalTol = "0";
$PostFXManager::Settings::SSAO::sRadius = "0.1";
$PostFXManager::Settings::SSAO::sStrength = "6";
$PostFXManager::Settings::ColorCorrectionRamp = "core/images/null_color_ramp.png";

View file

@ -0,0 +1,599 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
/*
================================================================================
The DOFPostEffect API
================================================================================
DOFPostEffect::setFocalDist( %dist )
@summary
This method is for manually controlling the focus distance. It will have no
effect if auto focus is currently enabled. Makes use of the parameters set by
setFocusParams.
@param dist
float distance in meters
--------------------------------------------------------------------------------
DOFPostEffect::setAutoFocus( %enabled )
@summary
This method sets auto focus enabled or disabled. Makes use of the parameters set
by setFocusParams. When auto focus is enabled it determines the focal depth
by performing a raycast at the screen-center.
@param enabled
bool
--------------------------------------------------------------------------------
DOFPostEffect::setFocusParams( %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
Set the parameters that control how the near and far equations are calculated
from the focal distance. If you are not using auto focus you will need to call
setFocusParams PRIOR to calling setFocalDist.
@param nearBlurMax
float between 0.0 and 1.0
The max allowed value of near blur.
@param farBlurMax
float between 0.0 and 1.0
The max allowed value of far blur.
@param minRange/maxRange
float in meters
The distance range around the focal distance that remains in focus is a lerp
between the min/maxRange using the normalized focal distance as the parameter.
The point is to allow the focal range to expand as you focus farther away since this is
visually appealing.
Note: since min/maxRange are lerped by the "normalized" focal distance it is
dependant on the visible distance set in your level.
@param nearSlope
float less than zero
The slope of the near equation. A small number causes bluriness to increase gradually
at distances closer than the focal distance. A large number causes bluriness to
increase quickly.
@param farSlope
float greater than zero
The slope of the far equation. A small number causes bluriness to increase gradually
at distances farther than the focal distance. A large number causes bluriness to
increase quickly.
Note: To rephrase, the min/maxRange parameters control how much area around the
focal distance is completely in focus where the near/farSlope parameters control
how quickly or slowly bluriness increases at distances outside of that range.
================================================================================
Examples
================================================================================
Example1: Turn on DOF while zoomed in with a weapon.
NOTE: These are not real callbacks! Hook these up to your code where appropriate!
function onSniperZoom()
{
// Parameterize how you want DOF to look.
DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
// Turn on auto focus
DOFPostEffect.setAutoFocus( true );
// Turn on the PostEffect
DOFPostEffect.enable();
}
function onSniperUnzoom()
{
// Turn off the PostEffect
DOFPostEffect.disable();
}
Example2: Manually control DOF with the mouse wheel.
// Somewhere on startup...
// Parameterize how you want DOF to look.
DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
// Turn off auto focus
DOFPostEffect.setAutoFocus( false );
// Turn on the PostEffect
DOFPostEffect.enable();
NOTE: These are not real callbacks! Hook these up to your code where appropriate!
function onMouseWheelUp()
{
// Since setFocalDist is really just a wrapper to assign to the focalDist
// dynamic field we can shortcut and increment it directly.
DOFPostEffect.focalDist += 8;
}
function onMouseWheelDown()
{
DOFPostEffect.focalDist -= 8;
}
*/
/// This method is for manually controlling the focal distance. It will have no
/// effect if auto focus is currently enabled. Makes use of the parameters set by
/// setFocusParams.
function DOFPostEffect::setFocalDist( %this, %dist )
{
%this.focalDist = %dist;
}
/// This method sets auto focus enabled or disabled. Makes use of the parameters set
/// by setFocusParams. When auto focus is enabled it determine the focal depth
/// by performing a raycast at the screen-center.
function DOFPostEffect::setAutoFocus( %this, %enabled )
{
%this.autoFocusEnabled = %enabled;
}
/// Set the parameters that control how the near and far equations are calculated
/// from the focal distance. If you are not using auto focus you will need to call
/// setFocusParams PRIOR to calling setFocalDist.
function DOFPostEffect::setFocusParams( %this, %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
{
%this.nearBlurMax = %nearBlurMax;
%this.farBlurMax = %farBlurMax;
%this.minRange = %minRange;
%this.maxRange = %maxRange;
%this.nearSlope = %nearSlope;
%this.farSlope = %farSlope;
}
/*
More information...
This DOF technique is based on this paper:
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch28.html
================================================================================
1. Overview of how we represent "Depth of Field"
================================================================================
DOF is expressed as an amount of bluriness per pixel according to its depth.
We represented this by a piecewise linear curve depicted below.
Note: we also refer to "bluriness" as CoC ( circle of confusion ) which is the term
used in the basis paper and in photography.
X-axis (depth)
x = 0.0----------------------------------------------x = 1.0
Y-axis (bluriness)
y = 1.0
|
| ____(x1,y1) (x4,y4)____
| (ns,nb)\ <--Line1 line2---> /(fe,fb)
| \ /
| \(x2,y2) (x3,y3)/
| (ne,0)------(fs,0)
y = 0.0
I have labeled the "corners" of this graph with (Xn,Yn) to illustrate that
this is in fact a collection of line segments where the x/y of each point
corresponds to the key below.
key:
ns - (n)ear blur (s)tart distance
nb - (n)ear (b)lur amount (max value)
ne - (n)ear blur (e)nd distance
fs - (f)ar blur (s)tart distance
fe - (f)ar blur (e)nd distance
fb - (f)ar (b)lur amount (max value)
Of greatest importance in this graph is Line1 and Line2. Where...
L1 { (x1,y1), (x2,y2) }
L2 { (x3,y3), (x4,y4) }
Line one represents the amount of "near" blur given a pixels depth and line two
represents the amount of "far" blur at that depth.
Both these equations are evaluated for each pixel and then the larger of the two
is kept. Also the output blur (for each equation) is clamped between 0 and its
maximum allowable value.
Therefore, to specify a DOF "qualify" you need to specify the near-blur-line,
far-blur-line, and maximum near and far blur value.
================================================================================
2. Abstracting a "focal depth"
================================================================================
Although the shader(s) work in terms of a near and far equation it is more
useful to express DOF as an adjustable focal depth and derive the other parameters
"under the hood".
Given a maximum near/far blur amount and a near/far slope we can calculate the
near/far equations for any focal depth. We extend this to also support a range
of depth around the focal depth that is also in focus and for that range to
shrink or grow as the focal depth moves closer or farther.
Keep in mind this is only one implementation and depending on the effect you
desire you may which to express the relationship between focal depth and
the shader paramaters different.
*/
//-----------------------------------------------------------------------------
// GFXStateBlockData / ShaderData
//-----------------------------------------------------------------------------
singleton GFXStateBlockData( PFX_DefaultDOFStateBlock )
{
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampPoint;
samplerStates[1] = SamplerClampPoint;
};
singleton GFXStateBlockData( PFX_DOFCalcCoCStateBlock )
{
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
samplerStates[1] = SamplerClampLinear;
};
singleton GFXStateBlockData( PFX_DOFDownSampleStateBlock )
{
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
samplerStates[1] = SamplerClampPoint;
};
singleton GFXStateBlockData( PFX_DOFBlurStateBlock )
{
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
};
singleton GFXStateBlockData( PFX_DOFFinalStateBlock )
{
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
samplerStates[1] = SamplerClampLinear;
samplerStates[2] = SamplerClampLinear;
samplerStates[3] = SamplerClampPoint;
blendDefined = true;
blendEnable = true;
blendDest = GFXBlendInvSrcAlpha;
blendSrc = GFXBlendOne;
};
singleton ShaderData( PFX_DOFDownSampleShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_V.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_P.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_V.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_P.glsl";
samplerNames[0] = "$colorSampler";
samplerNames[1] = "$depthSampler";
pixVersion = 3.0;
};
singleton ShaderData( PFX_DOFBlurYShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_V.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_P.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_V.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_P.glsl";
samplerNames[0] = "$diffuseMap";
pixVersion = 2.0;
defines = "BLUR_DIR=float2(0.0,1.0)";
};
singleton ShaderData( PFX_DOFBlurXShader : PFX_DOFBlurYShader )
{
defines = "BLUR_DIR=float2(1.0,0.0)";
};
singleton ShaderData( PFX_DOFCalcCoCShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_V.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_P.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_V.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_P.glsl";
samplerNames[0] = "$shrunkSampler";
samplerNames[1] = "$blurredSampler";
pixVersion = 3.0;
};
singleton ShaderData( PFX_DOFSmallBlurShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_V.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_P.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_V.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_P.glsl";
samplerNames[0] = "$colorSampler";
pixVersion = 3.0;
};
singleton ShaderData( PFX_DOFFinalShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_V.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_P.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_V.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_P.glsl";
samplerNames[0] = "$colorSampler";
samplerNames[1] = "$smallBlurSampler";
samplerNames[2] = "$largeBlurSampler";
samplerNames[3] = "$depthSampler";
pixVersion = 3.0;
};
//-----------------------------------------------------------------------------
// PostEffects
//-----------------------------------------------------------------------------
function DOFPostEffect::onAdd( %this )
{
// The weighted distribution of CoC value to the three blur textures
// in the order small, medium, large. Most likely you will not need to
// change this value.
%this.setLerpDist( 0.2, 0.3, 0.5 );
// Fill out some default values but DOF really should not be turned on
// without actually specifying your own parameters!
%this.autoFocusEnabled = false;
%this.focalDist = 0.0;
%this.nearBlurMax = 0.5;
%this.farBlurMax = 0.5;
%this.minRange = 50;
%this.maxRange = 500;
%this.nearSlope = -5.0;
%this.farSlope = 5.0;
}
function DOFPostEffect::setLerpDist( %this, %d0, %d1, %d2 )
{
%this.lerpScale = -1.0 / %d0 SPC -1.0 / %d1 SPC -1.0 / %d2 SPC 1.0 / %d2;
%this.lerpBias = 1.0 SPC ( 1.0 - %d2 ) / %d1 SPC 1.0 / %d2 SPC ( %d2 - 1.0 ) / %d2;
}
singleton PostEffect( DOFPostEffect )
{
renderTime = "PFXAfterBin";
renderBin = "GlowBin";
renderPriority = 0.1;
shader = PFX_DOFDownSampleShader;
stateBlock = PFX_DOFDownSampleStateBlock;
texture[0] = "$backBuffer";
texture[1] = "#prepass";
target = "#shrunk";
targetScale = "0.25 0.25";
isEnabled = false;
};
singleton PostEffect( DOFBlurY )
{
shader = PFX_DOFBlurYShader;
stateBlock = PFX_DOFBlurStateBlock;
texture[0] = "#shrunk";
target = "$outTex";
};
DOFPostEffect.add( DOFBlurY );
singleton PostEffect( DOFBlurX )
{
shader = PFX_DOFBlurXShader;
stateBlock = PFX_DOFBlurStateBlock;
texture[0] = "$inTex";
target = "#largeBlur";
};
DOFPostEffect.add( DOFBlurX );
singleton PostEffect( DOFCalcCoC )
{
shader = PFX_DOFCalcCoCShader;
stateBlock = PFX_DOFCalcCoCStateBlock;
texture[0] = "#shrunk";
texture[1] = "#largeBlur";
target = "$outTex";
};
DOFPostEffect.add( DOFCalcCoc );
singleton PostEffect( DOFSmallBlur )
{
shader = PFX_DOFSmallBlurShader;
stateBlock = PFX_DefaultDOFStateBlock;
texture[0] = "$inTex";
target = "$outTex";
};
DOFPostEffect.add( DOFSmallBlur );
singleton PostEffect( DOFFinalPFX )
{
shader = PFX_DOFFinalShader;
stateBlock = PFX_DOFFinalStateBlock;
texture[0] = "$backBuffer";
texture[1] = "$inTex";
texture[2] = "#largeBlur";
texture[3] = "#prepass";
target = "$backBuffer";
};
DOFPostEffect.add( DOFFinalPFX );
//-----------------------------------------------------------------------------
// Scripts
//-----------------------------------------------------------------------------
function DOFPostEffect::setShaderConsts( %this )
{
if ( %this.autoFocusEnabled )
%this.autoFocus();
%fd = %this.focalDist / $Param::FarDist;
%range = mLerp( %this.minRange, %this.maxRange, %fd ) / $Param::FarDist * 0.5;
// We work in "depth" space rather than real-world units for the
// rest of this method...
// Given the focal distance and the range around it we want in focus
// we can determine the near-end-distance and far-start-distance
%ned = getMax( %fd - %range, 0.0 );
%fsd = getMin( %fd + %range, 1.0 );
// near slope
%nsl = %this.nearSlope;
// Given slope of near blur equation and the near end dist and amount (x2,y2)
// solve for the y-intercept
// y = mx + b
// so...
// y - mx = b
%b = 0.0 - %nsl * %ned;
%eqNear = %nsl SPC %b SPC 0.0;
// Do the same for the far blur equation...
%fsl = %this.farSlope;
%b = 0.0 - %fsl * %fsd;
%eqFar = %fsl SPC %b SPC 1.0;
%this.setShaderConst( "$dofEqWorld", %eqNear );
DOFFinalPFX.setShaderConst( "$dofEqFar", %eqFar );
%this.setShaderConst( "$maxWorldCoC", %this.nearBlurMax );
DOFFinalPFX.setShaderConst( "$maxFarCoC", %this.farBlurMax );
DOFFinalPFX.setShaderConst( "$dofLerpScale", %this.lerpScale );
DOFFinalPFX.setShaderConst( "$dofLerpBias", %this.lerpBias );
}
function DOFPostEffect::autoFocus( %this )
{
if ( !isObject( ServerConnection ) ||
!isObject( ServerConnection.getCameraObject() ) )
{
return;
}
%mask = $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType;
%control = ServerConnection.getCameraObject();
%fvec = %control.getEyeVector();
%start = %control.getEyePoint();
%end = VectorAdd( %start, VectorScale( %fvec, $Param::FarDist ) );
// Use the client container for this ray cast.
%result = containerRayCast( %start, %end, %mask, %control, true );
%hitPos = getWords( %result, 1, 3 );
if ( %hitPos $= "" )
%focDist = $Param::FarDist;
else
%focDist = VectorDist( %hitPos, %start );
// For debuging
//$DOF::debug_dist = %focDist;
//$DOF::debug_depth = %focDist / $Param::FarDist;
//echo( "F: " @ %focDist SPC "D: " @ %delta );
%this.focalDist = %focDist;
}
// For debugging
/*
function reloadDOF()
{
exec( "./dof.cs" );
DOFPostEffect.reload();
DOFPostEffect.disable();
DOFPostEffect.enable();
}
function dofMetricsCallback()
{
return " | DOF |" @
" Dist: " @ $DOF::debug_dist @
" Depth: " @ $DOF::debug_depth;
}
*/

View file

@ -0,0 +1,113 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton GFXStateBlockData( PFX_DefaultEdgeAAStateBlock )
{
zDefined = true;
zEnable = false;
zWriteEnable = false;
samplersDefined = true;
samplerStates[0] = SamplerClampPoint;
//samplerStates[1] = SamplerWrapPoint;
};
singleton ShaderData( PFX_EdgeAADetectShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeDetectP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeDetectP.glsl";
samplerNames[0] = "$prepassBuffer";
pixVersion = 3.0;
};
singleton ShaderData( PFX_EdgeAAShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAP.glsl";
samplerNames[0] = "$edgeBuffer";
samplerNames[1] = "$backBuffer";
pixVersion = 3.0;
};
singleton ShaderData( PFX_EdgeAADebugShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/dbgEdgeDisplayP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl";
samplerNames[0] = "$edgeBuffer";
pixVersion = 3.0;
};
singleton PostEffect( EdgeDetectPostEffect )
{
renderTime = "PFXBeforeBin";
renderBin = "ObjTranslucentBin";
//renderPriority = 0.1;
targetScale = "0.5 0.5";
shader = PFX_EdgeAADetectShader;
stateBlock = PFX_DefaultEdgeAAStateBlock;
texture[0] = "#prepass";
target = "#edge";
isEnabled = true;
};
singleton PostEffect( EdgeAAPostEffect )
{
renderTime = "PFXAfterDiffuse";
//renderBin = "ObjTranslucentBin";
//renderPriority = 0.1;
shader = PFX_EdgeAAShader;
stateBlock = PFX_DefaultEdgeAAStateBlock;
texture[0] = "#edge";
texture[1] = "$backBuffer";
target = "$backBuffer";
};
singleton PostEffect( Debug_EdgeAAPostEffect )
{
renderTime = "PFXAfterDiffuse";
//renderBin = "ObjTranslucentBin";
//renderPriority = 0.1;
shader = PFX_EdgeAADebugShader;
stateBlock = PFX_DefaultEdgeAAStateBlock;
texture[0] = "#edge";
target = "$backBuffer";
};

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton ShaderData( PFX_FlashShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/flashP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/flashP.glsl";
samplerNames[0] = "$backBuffer";
defines = "WHITE_COLOR=float4(1.0,1.0,1.0,0.0);MUL_COLOR=float4(1.0,0.25,0.25,0.0)";
pixVersion = 2.0;
};
singleton PostEffect( FlashFx )
{
isEnabled = false;
allowReflectPass = false;
renderTime = "PFXAfterDiffuse";
shader = PFX_FlashShader;
texture[0] = "$backBuffer";
renderPriority = 10;
stateBlock = PFX_DefaultStateBlock;
};
function FlashFx::setShaderConsts( %this )
{
if ( isObject( ServerConnection ) )
{
%this.setShaderConst( "$damageFlash", ServerConnection.getDamageFlash() );
%this.setShaderConst( "$whiteOut", ServerConnection.getWhiteOut() );
}
else
{
%this.setShaderConst( "$damageFlash", 0 );
%this.setShaderConst( "$whiteOut", 0 );
}
}

Some files were not shown because too many files have changed in this diff Show more