diffuse/albedo texture linearization

http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html
This commit is contained in:
Azaezel 2015-11-11 13:52:46 -06:00
parent 51b6469922
commit ce2964d2d0
31 changed files with 396 additions and 107 deletions

View file

@ -105,7 +105,7 @@ void AdvancedLightManager::activate( SceneManager *sceneManager )
// we prefer the floating point format if it works. // we prefer the floating point format if it works.
Vector<GFXFormat> formats; Vector<GFXFormat> formats;
formats.push_back( GFXFormatR16G16B16A16F ); formats.push_back( GFXFormatR16G16B16A16F );
formats.push_back( GFXFormatR16G16B16A16 ); //formats.push_back( GFXFormatR16G16B16A16 );
GFXFormat blendTargetFormat = GFX->selectSupportedFormat( &GFXDefaultRenderTargetProfile, GFXFormat blendTargetFormat = GFX->selectSupportedFormat( &GFXDefaultRenderTargetProfile,
formats, formats,
true, true,

View file

@ -46,6 +46,7 @@ ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true );
ImplementFeatureType( MFT_SpecularMap, MFG_Texture, 8.0f, true ); ImplementFeatureType( MFT_SpecularMap, MFG_Texture, 8.0f, true );
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 9.0f, true ); ImplementFeatureType( MFT_NormalMap, MFG_Texture, 9.0f, true );
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 10.0f, true ); ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 10.0f, true );
ImplementFeatureType( MFT_Imposter, U32(-1), -1, true );
ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true ); ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true );

View file

@ -94,6 +94,7 @@ DeclareFeatureType( MFT_OverlayMap );
DeclareFeatureType( MFT_DetailMap ); DeclareFeatureType( MFT_DetailMap );
DeclareFeatureType( MFT_DiffuseColor ); DeclareFeatureType( MFT_DiffuseColor );
DeclareFeatureType( MFT_DetailNormalMap ); DeclareFeatureType( MFT_DetailNormalMap );
DeclareFeatureType( MFT_Imposter );
DeclareFeatureType( MFT_AccuMap ); DeclareFeatureType( MFT_AccuMap );
DeclareFeatureType( MFT_AccuScale ); DeclareFeatureType( MFT_AccuScale );

View file

@ -144,6 +144,8 @@ void AccuTexFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
// get the accu pixel color // get the accu pixel color
meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) ); meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) );
if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", accuColor, accuColor));
// scale up normals // scale up normals
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) ); meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );

View file

@ -828,6 +828,12 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
// Base Texture // Base Texture
//**************************************************************************** //****************************************************************************
DiffuseMapFeatGLSL::DiffuseMapFeatGLSL()
: mTorqueDep("shaders/common/gl/torque.glsl")
{
addDependency(&mTorqueDep);
}
void DiffuseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList, void DiffuseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ) const MaterialFeatureData &fd )
{ {
@ -855,20 +861,23 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
diffuseMap->sampler = true; diffuseMap->sampler = true;
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
// create sample color var
Var *diffColor = new Var;
diffColor->setType("vec4");
diffColor->setName("diffuseColor");
LangElement *colorDecl = new DecOp( diffColor );
MultiLine * meta = new MultiLine;
output = meta;
if ( fd.features[MFT_CubeMap] ) if ( fd.features[MFT_CubeMap] )
{ {
MultiLine * meta = new MultiLine;
// create sample color
Var *diffColor = new Var;
diffColor->setType( "vec4" );
diffColor->setName( "diffuseColor" );
LangElement *colorDecl = new DecOp( diffColor );
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n", meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n",
colorDecl, colorDecl,
diffuseMap, diffuseMap,
inTex ) ); inTex ) );
if (!fd.features[MFT_Imposter])
meta->addStatement( new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor) );
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) ); meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) );
output = meta; output = meta;
@ -877,8 +886,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
{ {
// Handle atlased textures // Handle atlased textures
// http://www.infinity-universe.com/Infinity/index.php?option=com_content&task=view&id=65&Itemid=47 // http://www.infinity-universe.com/Infinity/index.php?option=com_content&task=view&id=65&Itemid=47
MultiLine * meta = new MultiLine;
output = meta;
Var *atlasedTex = new Var; Var *atlasedTex = new Var;
atlasedTex->setName("atlasedTexCoord"); atlasedTex->setName("atlasedTexCoord");
@ -934,11 +941,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
// For the rest of the feature... // For the rest of the feature...
inTex = atlasedTex; inTex = atlasedTex;
// create sample color var
Var *diffColor = new Var;
diffColor->setType("vec4");
diffColor->setName("diffuseColor");
// To dump out UV coords... // To dump out UV coords...
//#define DEBUG_ATLASED_UV_COORDS //#define DEBUG_ATLASED_UV_COORDS
#ifdef DEBUG_ATLASED_UV_COORDS #ifdef DEBUG_ATLASED_UV_COORDS
@ -954,21 +956,26 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
{ {
meta->addStatement(new GenOp( " @ = tex2Dlod(@, float4(@, 0.0, mipLod));\r\n", meta->addStatement(new GenOp( " @ = tex2Dlod(@, float4(@, 0.0, mipLod));\r\n",
new DecOp(diffColor), diffuseMap, inTex)); new DecOp(diffColor), diffuseMap, inTex));
if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
} }
else else
{ {
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n", meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
new DecOp(diffColor), diffuseMap, inTex)); new DecOp(diffColor), diffuseMap, inTex));
if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
} }
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul))); meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul)));
} }
else else
{ {
LangElement *statement = new GenOp( "tex2D(@, @)", diffuseMap, inTex ); meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
output = new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ); if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul)));
} }
} }
ShaderFeature::Resources DiffuseMapFeatGLSL::getResources( const MaterialFeatureData &fd ) ShaderFeature::Resources DiffuseMapFeatGLSL::getResources( const MaterialFeatureData &fd )

View file

@ -236,7 +236,12 @@ public:
/// Base texture /// Base texture
class DiffuseMapFeatGLSL : public ShaderFeatureGLSL class DiffuseMapFeatGLSL : public ShaderFeatureGLSL
{ {
protected:
ShaderIncludeDependency mTorqueDep;
public: public:
DiffuseMapFeatGLSL();
virtual void processVert( Vector<ShaderComponent*> &componentList, virtual void processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ); const MaterialFeatureData &fd );

View file

@ -68,6 +68,7 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatGLSL ); FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatGLSL );
FEATUREMGR->registerFeature( MFT_Fog, new FogFeatGLSL ); FEATUREMGR->registerFeature( MFT_Fog, new FogFeatGLSL );
FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureGLSL( "Imposter" ) );
FEATUREMGR->registerFeature( MFT_NormalsOut, new NormalsOutFeatGLSL ); FEATUREMGR->registerFeature( MFT_NormalsOut, new NormalsOutFeatGLSL );

View file

@ -141,6 +141,8 @@ void AccuTexFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
// get the accu pixel color // get the accu pixel color
meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) ); meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) );
if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", accuColor, accuColor));
// scale up normals // scale up normals
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) ); meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );

View file

@ -826,6 +826,12 @@ Var* ShaderFeatureHLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
// Base Texture // Base Texture
//**************************************************************************** //****************************************************************************
DiffuseMapFeatHLSL::DiffuseMapFeatHLSL()
: mTorqueDep("shaders/common/torque.hlsl")
{
addDependency(&mTorqueDep);
}
void DiffuseMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList, void DiffuseMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ) const MaterialFeatureData &fd )
{ {
@ -853,30 +859,30 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
diffuseMap->sampler = true; diffuseMap->sampler = true;
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
// create sample color
Var *diffColor = new Var;
diffColor->setType("float4");
diffColor->setName("diffuseColor");
LangElement *colorDecl = new DecOp(diffColor);
MultiLine * meta = new MultiLine;
output = meta;
if ( fd.features[MFT_CubeMap] ) if ( fd.features[MFT_CubeMap] )
{ {
MultiLine * meta = new MultiLine;
// create sample color
Var *diffColor = new Var;
diffColor->setType( "float4" );
diffColor->setName( "diffuseColor" );
LangElement *colorDecl = new DecOp( diffColor );
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n", meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n",
colorDecl, colorDecl,
diffuseMap, diffuseMap,
inTex ) ); inTex ) );
if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) ); meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) );
output = meta;
} }
else if(fd.features[MFT_DiffuseMapAtlas]) else if(fd.features[MFT_DiffuseMapAtlas])
{ {
// Handle atlased textures // Handle atlased textures
// http://www.infinity-universe.com/Infinity/index.php?option=com_content&task=view&id=65&Itemid=47 // http://www.infinity-universe.com/Infinity/index.php?option=com_content&task=view&id=65&Itemid=47
MultiLine * meta = new MultiLine;
output = meta;
Var *atlasedTex = new Var; Var *atlasedTex = new Var;
atlasedTex->setName("atlasedTexCoord"); atlasedTex->setName("atlasedTexCoord");
@ -932,11 +938,6 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
// For the rest of the feature... // For the rest of the feature...
inTex = atlasedTex; inTex = atlasedTex;
// create sample color var
Var *diffColor = new Var;
diffColor->setType("float4");
diffColor->setName("diffuseColor");
// To dump out UV coords... // To dump out UV coords...
//#define DEBUG_ATLASED_UV_COORDS //#define DEBUG_ATLASED_UV_COORDS
#ifdef DEBUG_ATLASED_UV_COORDS #ifdef DEBUG_ATLASED_UV_COORDS
@ -958,15 +959,18 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n", meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
new DecOp(diffColor), diffuseMap, inTex)); new DecOp(diffColor), diffuseMap, inTex));
} }
if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul))); meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul)));
} }
else else
{ {
LangElement *statement = new GenOp( "tex2D(@, @)", diffuseMap, inTex ); meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
output = new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ); if (!fd.features[MFT_Imposter])
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul)));
} }
} }
ShaderFeature::Resources DiffuseMapFeatHLSL::getResources( const MaterialFeatureData &fd ) ShaderFeature::Resources DiffuseMapFeatHLSL::getResources( const MaterialFeatureData &fd )

View file

@ -236,7 +236,12 @@ public:
/// Base texture /// Base texture
class DiffuseMapFeatHLSL : public ShaderFeatureHLSL class DiffuseMapFeatHLSL : public ShaderFeatureHLSL
{ {
protected:
ShaderIncludeDependency mTorqueDep;
public: public:
DiffuseMapFeatHLSL();
virtual void processVert( Vector<ShaderComponent*> &componentList, virtual void processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ); const MaterialFeatureData &fd );

View file

@ -70,6 +70,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) ); FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) );
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) ); FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) );
FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget1 ) ); FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget1 ) );
FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureHLSL( "Imposter" ) );
FEATUREMGR->registerFeature( MFT_DiffuseMapAtlas, new NamedFeatureHLSL( "Diffuse Map Atlas" ) ); FEATUREMGR->registerFeature( MFT_DiffuseMapAtlas, new NamedFeatureHLSL( "Diffuse Map Atlas" ) );
FEATUREMGR->registerFeature( MFT_NormalMapAtlas, new NamedFeatureHLSL( "Normal Map Atlas" ) ); FEATUREMGR->registerFeature( MFT_NormalMapAtlas, new NamedFeatureHLSL( "Normal Map Atlas" ) );

View file

@ -64,6 +64,12 @@ MODULE_BEGIN( TerrainFeatGLSL )
MODULE_END; MODULE_END;
TerrainFeatGLSL::TerrainFeatGLSL()
: mTorqueDep( "shaders/common/gl/torque.glsl" )
{
addDependency( &mTorqueDep );
}
Var* TerrainFeatGLSL::_getUniformVar( const char *name, const char *type, ConstantSortPosition csp ) Var* TerrainFeatGLSL::_getUniformVar( const char *name, const char *type, ConstantSortPosition csp )
{ {
Var *theVar = (Var*)LangElement::find( name ); Var *theVar = (Var*)LangElement::find( name );
@ -262,6 +268,7 @@ void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
baseColor->setType( "vec4" ); baseColor->setType( "vec4" );
baseColor->setName( "baseColor" ); baseColor->setName( "baseColor" );
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) ); meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) ); meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) );
output = meta; output = meta;

View file

@ -36,7 +36,10 @@
class TerrainFeatGLSL : public ShaderFeatureGLSL class TerrainFeatGLSL : public ShaderFeatureGLSL
{ {
protected: protected:
ShaderIncludeDependency mTorqueDep;
public:
TerrainFeatGLSL();
Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList ); Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList );
Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList ); Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList );

View file

@ -64,6 +64,12 @@ MODULE_BEGIN( TerrainFeatHLSL )
MODULE_END; MODULE_END;
TerrainFeatHLSL::TerrainFeatHLSL()
: mTorqueDep( "shaders/common/torque.hlsl" )
{
addDependency( &mTorqueDep );
}
Var* TerrainFeatHLSL::_getUniformVar( const char *name, const char *type, ConstantSortPosition csp ) Var* TerrainFeatHLSL::_getUniformVar( const char *name, const char *type, ConstantSortPosition csp )
{ {
Var *theVar = (Var*)LangElement::find( name ); Var *theVar = (Var*)LangElement::find( name );
@ -262,6 +268,7 @@ void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
baseColor->setType( "float4" ); baseColor->setType( "float4" );
baseColor->setName( "baseColor" ); baseColor->setName( "baseColor" );
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) ); meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) ); meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) );
output = meta; output = meta;

View file

@ -37,6 +37,10 @@ class TerrainFeatHLSL : public ShaderFeatureHLSL
{ {
protected: protected:
ShaderIncludeDependency mTorqueDep;
public:
TerrainFeatHLSL();
Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList ); Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList );
Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList ); Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList );

View file

@ -136,6 +136,7 @@ void ImposterCaptureMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
fd.features.addFeature( MFT_NormalsOut ); fd.features.addFeature( MFT_NormalsOut );
fd.features.addFeature( MFT_ForwardShading ); fd.features.addFeature( MFT_ForwardShading );
fd.features.addFeature( MFT_Imposter );
} }
ImposterCaptureMaterialHook* ImposterCaptureMaterialHook::_getOrCreateHook( BaseMatInstance *inMat ) ImposterCaptureMaterialHook* ImposterCaptureMaterialHook::_getOrCreateHook( BaseMatInstance *inMat )

View file

@ -33,7 +33,7 @@
anchorLeft = "1"; anchorLeft = "1";
anchorRight = "0"; anchorRight = "0";
position = "323 232"; position = "323 232";
extent = "377 303"; extent = "377 355";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "center"; horizSizing = "center";
vertSizing = "center"; vertSizing = "center";
@ -51,7 +51,7 @@
groupNum = "-1"; groupNum = "-1";
buttonType = "PushButton"; buttonType = "PushButton";
useMouseEvents = "0"; useMouseEvents = "0";
position = "306 271"; position = "304 319";
extent = "60 23"; extent = "60 23";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "right"; horizSizing = "right";
@ -179,47 +179,49 @@
canSave = "1"; canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiSliderCtrl(OptMouseSensitivity) {
new GuiSliderCtrl(OptMouseSensitivity) { range = "0.02 2";
range = "0.02 2"; ticks = "10";
ticks = "10"; snap = "0";
value = "0.75"; value = "1";
isContainer = "0"; position = "105 182";
Profile = "GuiSliderProfile"; extent = "244 18";
HorizSizing = "right"; minExtent = "8 2";
VertSizing = "bottom"; horizSizing = "right";
position = "105 182"; vertSizing = "bottom";
Extent = "244 18"; profile = "GuiSliderProfile";
MinExtent = "8 2"; visible = "1";
canSave = "1"; active = "1";
Visible = "1"; command = "OptMouseSetSensitivity(OptMouseSensitivity.value);";
Command = "OptMouseSetSensitivity(OptMouseSensitivity.value);"; tooltipProfile = "GuiToolTipProfile";
tooltipprofile = "GuiToolTipProfile"; hovertime = "1000";
hovertime = "1000"; isContainer = "0";
canSaveDynamicFields = "0"; canSave = "1";
}; canSaveDynamicFields = "0";
new GuiTextCtrl() { };
text = "Mouse Sensitivity:"; new GuiTextCtrl() {
maxLength = "255"; text = "Mouse Sensitivity:";
Margin = "0 0 0 0"; maxLength = "255";
Padding = "0 0 0 0"; margin = "0 0 0 0";
AnchorTop = "1"; padding = "0 0 0 0";
AnchorBottom = "0"; anchorTop = "1";
AnchorLeft = "1"; anchorBottom = "0";
AnchorRight = "0"; anchorLeft = "1";
isContainer = "0"; anchorRight = "0";
Profile = "GuiTextProfile"; position = "15 182";
HorizSizing = "right"; extent = "85 18";
VertSizing = "bottom"; minExtent = "8 8";
position = "15 182"; horizSizing = "right";
Extent = "85 18"; vertSizing = "bottom";
MinExtent = "8 8"; profile = "GuiTextProfile";
canSave = "1"; visible = "1";
Visible = "1"; active = "1";
tooltipprofile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
canSaveDynamicFields = "0"; isContainer = "0";
}; canSave = "1";
canSaveDynamicFields = "0";
};
}; };
new GuiBitmapBorderCtrl() { new GuiBitmapBorderCtrl() {
position = "9 55"; position = "9 55";
@ -601,7 +603,7 @@
}; };
new GuiBitmapBorderCtrl() { new GuiBitmapBorderCtrl() {
position = "9 55"; position = "9 55";
extent = "358 210"; extent = "358 252";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "right"; horizSizing = "right";
vertSizing = "bottom"; vertSizing = "bottom";
@ -1252,6 +1254,66 @@
canSave = "1"; canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiControl() {
position = "0 227";
extent = "352 15";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "GammaSliderContainer";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSliderCtrl() {
range = "0.5 1.5";
ticks = "0";
snap = "0";
value = "1";
position = "76 -1";
extent = "268 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiSliderProfile";
visible = "1";
active = "1";
variable = "$pref::Video::Contrast";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "Contrast:";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "18 -4";
extent = "105 18";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiControl() { new GuiControl() {
position = "0 190"; position = "0 190";
extent = "352 15"; extent = "352 15";
@ -1269,10 +1331,10 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
new GuiSliderCtrl() { new GuiSliderCtrl() {
range = "0.001 2.2"; range = "2.0 2.5";
ticks = "0"; ticks = "0";
snap = "0"; snap = "0";
value = "1"; value = "2.2";
position = "76 -1"; position = "76 -1";
extent = "268 15"; extent = "268 15";
minExtent = "8 2"; minExtent = "8 2";
@ -1312,6 +1374,66 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
}; };
new GuiControl() {
position = "0 208";
extent = "352 15";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "GammaSliderContainer";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSliderCtrl() {
range = "-0.5 0.5";
ticks = "0";
snap = "0";
value = "0";
position = "76 -1";
extent = "268 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiSliderProfile";
visible = "1";
active = "1";
variable = "$pref::Video::Brightness";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "Brightness:";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "6 -3";
extent = "105 18";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
};
}; };
new GuiControl() { new GuiControl() {
position = "9 55"; position = "9 55";
@ -1396,7 +1518,7 @@
groupNum = "-1"; groupNum = "-1";
buttonType = "PushButton"; buttonType = "PushButton";
useMouseEvents = "0"; useMouseEvents = "0";
position = "241 271"; position = "239 319";
extent = "60 23"; extent = "60 23";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "right"; horizSizing = "right";

View file

@ -73,7 +73,9 @@ $pref::Video::disableCubemapping = false;
/// ///
$pref::Video::disableParallaxMapping = false; $pref::Video::disableParallaxMapping = false;
$pref::Video::Gamma = 1.0; $pref::Video::Gamma = 2.2;
$pref::Video::Contrast = 1.0;
$pref::Video::Brightness = 0;
// Console-friendly defaults // Console-friendly defaults
if($platform $= "xenon") if($platform $= "xenon")

View file

@ -44,7 +44,7 @@ singleton GFXStateBlockData( GammaStateBlock : PFX_DefaultStateBlock )
singleton PostEffect( GammaPostFX ) singleton PostEffect( GammaPostFX )
{ {
isEnabled = true; isEnabled = true;
allowReflectPass = false; allowReflectPass = true;
renderTime = "PFXBeforeBin"; renderTime = "PFXBeforeBin";
renderBin = "EditorBin"; renderBin = "EditorBin";
@ -65,6 +65,8 @@ function GammaPostFX::preProcess( %this )
function GammaPostFX::setShaderConsts( %this ) function GammaPostFX::setShaderConsts( %this )
{ {
%clampedGamma = mClamp( $pref::Video::Gamma, 0.001, 2.2); %clampedGamma = mClamp( $pref::Video::Gamma, 2.0, 2.5);
%this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma ); %this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma );
%this.setShaderConst( "$Brightness", $pref::Video::Brightness );
%this.setShaderConst( "$Contrast", $pref::Video::Contrast );
} }

View file

@ -253,8 +253,10 @@ function HDRPostFX::setShaderConsts( %this )
%combinePass.setShaderConst( "$g_fEnableBlueShift", $HDRPostFX::enableBlueShift ); %combinePass.setShaderConst( "$g_fEnableBlueShift", $HDRPostFX::enableBlueShift );
%combinePass.setShaderConst( "$g_fBlueShiftColor", $HDRPostFX::blueShiftColor ); %combinePass.setShaderConst( "$g_fBlueShiftColor", $HDRPostFX::blueShiftColor );
%clampedGamma = mClamp( $pref::Video::Gamma, 0.001, 2.2); %clampedGamma = mClamp( $pref::Video::Gamma, 2.0, 2.5);
%combinePass.setShaderConst( "$g_fOneOverGamma", 1 / %clampedGamma ); %combinePass.setShaderConst( "$g_fOneOverGamma", 1 / %clampedGamma );
%combinePass.setShaderConst( "$Brightness", $pref::Video::Brightness );
%combinePass.setShaderConst( "$Contrast", $pref::Video::Contrast );
%whiteCutoff = ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff ) * %whiteCutoff = ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff ) *
( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff ); ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff );
@ -329,7 +331,7 @@ function HDRPostFX::onDisabled( %this )
singleton PostEffect( HDRPostFX ) singleton PostEffect( HDRPostFX )
{ {
isEnabled = false; isEnabled = false;
allowReflectPass = false; allowReflectPass = true;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff
// and before we resolve the scene to the backbuffer. // and before we resolve the scene to the backbuffer.
@ -355,6 +357,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
shader = HDR_DownScale4x4Shader; shader = HDR_DownScale4x4Shader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -365,6 +368,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
internalName = "bloomH"; internalName = "bloomH";
shader = HDR_BloomGaussBlurHShader; shader = HDR_BloomGaussBlurHShader;
@ -376,6 +380,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
internalName = "bloomV"; internalName = "bloomV";
shader = HDR_BloomGaussBlurVShader; shader = HDR_BloomGaussBlurVShader;
@ -390,6 +395,7 @@ singleton PostEffect( HDRPostFX )
// Now calculate the adapted luminance. // Now calculate the adapted luminance.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
internalName = "adaptLum"; internalName = "adaptLum";
shader = HDR_SampleLumShader; shader = HDR_SampleLumShader;
@ -401,6 +407,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -411,6 +418,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -421,6 +429,7 @@ singleton PostEffect( HDRPostFX )
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
shader = HDR_DownSampleLumShader; shader = HDR_DownSampleLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
texture[0] = "$inTex"; texture[0] = "$inTex";
@ -434,6 +443,7 @@ singleton PostEffect( HDRPostFX )
// one... PostEffect takes care to manage that. // one... PostEffect takes care to manage that.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
internalName = "finalLum"; internalName = "finalLum";
shader = HDR_CalcAdaptedLumShader; shader = HDR_CalcAdaptedLumShader;
stateBlock = HDR_DownSampleStateBlock; stateBlock = HDR_DownSampleStateBlock;
@ -450,6 +460,7 @@ singleton PostEffect( HDRPostFX )
// version of the scene. // version of the scene.
new PostEffect() new PostEffect()
{ {
allowReflectPass = true;
internalName = "combinePass"; internalName = "combinePass";
shader = HDR_CombineShader; shader = HDR_CombineShader;

View file

@ -33,7 +33,7 @@ function initRenderManager()
{ {
enabled = "false"; enabled = "false";
format = "GFXFormatR8G8B8A8"; format = "GFXFormatR16G16B16A16F";
depthFormat = "GFXFormatD24S8"; depthFormat = "GFXFormatD24S8";
aaLevel = 0; // -1 = match backbuffer aaLevel = 0; // -1 = match backbuffer
@ -49,20 +49,21 @@ function initRenderManager()
// We really need to fix the sky to render after all the // We really need to fix the sky to render after all the
// meshes... but that causes issues in reflections. // meshes... but that causes issues in reflections.
DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Sky"; renderOrder = 0.1; processAddOrder = 0.1; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(SkyBin) { bintype = "Sky"; renderOrder = 0.1; processAddOrder = 0.1; } );
//DiffuseRenderPassManager.addManager( new RenderVistaMgr() { bintype = "Vista"; renderOrder = 0.15; processAddOrder = 0.15; } ); //DiffuseRenderPassManager.addManager( new RenderVistaMgr() { bintype = "Vista"; renderOrder = 0.15; processAddOrder = 0.15; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(BeginBin) { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );
// Normal mesh rendering. // Normal mesh rendering.
DiffuseRenderPassManager.addManager( new RenderTerrainMgr() { renderOrder = 0.4; processAddOrder = 0.4; } ); DiffuseRenderPassManager.addManager( new RenderTerrainMgr(TerrainBin) { renderOrder = 0.4; processAddOrder = 0.4; } );
DiffuseRenderPassManager.addManager( new RenderMeshMgr() { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; } ); DiffuseRenderPassManager.addManager( new RenderMeshMgr(MeshBin) { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; } );
DiffuseRenderPassManager.addManager( new RenderImposterMgr() { renderOrder = 0.56; processAddOrder = 0.56; } ); DiffuseRenderPassManager.addManager( new RenderImposterMgr(ImposterBin) { renderOrder = 0.56; processAddOrder = 0.56; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjectBin) { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Shadow"; renderOrder = 0.7; processAddOrder = 0.7; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(ShadowBin) { bintype = "Shadow"; renderOrder = 0.7; processAddOrder = 0.7; } );
DiffuseRenderPassManager.addManager( new RenderMeshMgr() { bintype = "Decal"; renderOrder = 0.8; processAddOrder = 0.8; } ); DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalRoadBin) { bintype = "DecalRoad"; renderOrder = 0.8; processAddOrder = 0.8; } );
DiffuseRenderPassManager.addManager( new RenderOcclusionMgr() { bintype = "Occluder"; renderOrder = 0.9; processAddOrder = 0.9; } ); DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalBin) { bintype = "Decal"; renderOrder = 0.81; processAddOrder = 0.81; } );
DiffuseRenderPassManager.addManager( new RenderOcclusionMgr(OccluderBin){ bintype = "Occluder"; renderOrder = 0.9; processAddOrder = 0.9; } );
// We now render translucent objects that should handle // We now render translucent objects that should handle
// their own fogging and lighting. // their own fogging and lighting.
@ -70,10 +71,10 @@ function initRenderManager()
// Note that the fog effect is triggered before this bin. // Note that the fog effect is triggered before this bin.
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjTranslucentBin) { bintype = "ObjectTranslucent"; renderOrder = 1.0; processAddOrder = 1.0; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjTranslucentBin) { bintype = "ObjectTranslucent"; renderOrder = 1.0; processAddOrder = 1.0; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Water"; renderOrder = 1.2; processAddOrder = 1.2; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(WaterBin) { bintype = "Water"; renderOrder = 1.2; processAddOrder = 1.2; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Foliage"; renderOrder = 1.3; processAddOrder = 1.3; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(FoliageBin) { bintype = "Foliage"; renderOrder = 1.3; processAddOrder = 1.3; } );
DiffuseRenderPassManager.addManager( new RenderParticleMgr() { renderOrder = 1.35; processAddOrder = 1.35; } ); DiffuseRenderPassManager.addManager( new RenderParticleMgr(ParticleBin) { renderOrder = 1.35; processAddOrder = 1.35; } );
DiffuseRenderPassManager.addManager( new RenderTranslucentMgr() { renderOrder = 1.4; processAddOrder = 1.4; } ); DiffuseRenderPassManager.addManager( new RenderTranslucentMgr(TranslucentBin){ renderOrder = 1.4; processAddOrder = 1.4; } );
// Note that the GlowPostFx is triggered after this bin. // Note that the GlowPostFx is triggered after this bin.
DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } ); DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } );
@ -83,7 +84,7 @@ function initRenderManager()
DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } );
// Resolve format change token last. // Resolve format change token last.
DiffuseRenderPassManager.addManager( new RenderPassStateBin() { renderOrder = 1.7; stateToken = AL_FormatToken; } ); DiffuseRenderPassManager.addManager( new RenderPassStateBin(FinalBin) { renderOrder = 1.7; stateToken = AL_FormatToken; } );
} }
/// This post effect is used to copy data from the non-MSAA back-buffer to the /// This post effect is used to copy data from the non-MSAA back-buffer to the

View file

@ -284,4 +284,37 @@ void fizzle(vec2 vpos, float visibility)
/// @note This macro will only work in the void main() method of a pixel shader. /// @note This macro will only work in the void main() method of a pixel shader.
#define assert(condition, color) { if(!any(condition)) { OUT_col = color; return; } } #define assert(condition, color) { if(!any(condition)) { OUT_col = color; return; } }
// Deferred Shading: Material Info Flag Check
bool getFlag(float flags, int num)
{
float process = round(flags * 255);
float squareNum = pow(2, num);
return (mod(process, pow(2, squareNum)) >= squareNum);
}
// #define TORQUE_STOCK_GAMMA
#ifdef TORQUE_STOCK_GAMMA
// Sample in linear space. Decodes gamma.
vec4 toLinear(vec4 tex)
{
return tex;
}
// Encodes gamma.
vec4 toGamma(vec4 tex)
{
return tex;
}
#else
// Sample in linear space. Decodes gamma.
vec4 toLinear(vec4 tex)
{
return vec4(pow(abs(tex.rgb), vec3(2.2)), tex.a);
}
// Encodes gamma.
vec4 toGamma(vec4 tex)
{
return vec4(pow(abs(tex.rgb), vec3(1.0/2.2)), tex.a);
}
#endif //
#endif // _TORQUE_GLSL_ #endif // _TORQUE_GLSL_

View file

@ -28,7 +28,8 @@ uniform sampler2D backBuffer : register(S0);
uniform sampler1D colorCorrectionTex : register( s1 ); uniform sampler1D colorCorrectionTex : register( s1 );
uniform float OneOverGamma; uniform float OneOverGamma;
uniform float Brightness;
uniform float Contrast;
float4 main( PFXVertToPix IN ) : COLOR0 float4 main( PFXVertToPix IN ) : COLOR0
{ {
@ -42,5 +43,11 @@ float4 main( PFXVertToPix IN ) : COLOR0
// Apply gamma correction // Apply gamma correction
color.rgb = pow( abs(color.rgb), OneOverGamma ); color.rgb = pow( abs(color.rgb), OneOverGamma );
// Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
color.rgb += Brightness;
return color; return color;
} }

View file

@ -28,6 +28,8 @@ uniform sampler2D backBuffer;
uniform sampler1D colorCorrectionTex; uniform sampler1D colorCorrectionTex;
uniform float OneOverGamma; uniform float OneOverGamma;
uniform float Brightness;
uniform float Contrast;
in vec2 uv0; in vec2 uv0;
@ -45,5 +47,11 @@ void main()
// Apply gamma correction // Apply gamma correction
color.rgb = pow( abs(color.rgb), vec3(OneOverGamma) ); color.rgb = pow( abs(color.rgb), vec3(OneOverGamma) );
// Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
color.rgb += Brightness;
OUT_col = color; OUT_col = color;
} }

View file

@ -41,6 +41,8 @@ uniform float3 g_fBlueShiftColor;
uniform float g_fBloomScale; uniform float g_fBloomScale;
uniform float g_fOneOverGamma; uniform float g_fOneOverGamma;
uniform float Brightness;
uniform float Contrast;
float4 main( PFXVertToPix IN ) : COLOR0 float4 main( PFXVertToPix IN ) : COLOR0
@ -90,6 +92,12 @@ float4 main( PFXVertToPix IN ) : COLOR0
// Apply gamma correction // Apply gamma correction
sample.rgb = pow( abs(sample.rgb), g_fOneOverGamma ); sample.rgb = pow( abs(sample.rgb), g_fOneOverGamma );
// Apply contrast
sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
sample.rgb += Brightness;
return sample; return sample;
} }

View file

@ -42,6 +42,8 @@ uniform vec3 g_fBlueShiftColor;
uniform float g_fBloomScale; uniform float g_fBloomScale;
uniform float g_fOneOverGamma; uniform float g_fOneOverGamma;
uniform float Brightness;
uniform float Contrast;
out vec4 OUT_col; out vec4 OUT_col;
@ -93,6 +95,12 @@ void main()
// Apply gamma correction // Apply gamma correction
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) ); _sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) );
// Apply contrast
_sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
_sample.rgb += Brightness;
OUT_col = _sample; OUT_col = _sample;
} }

View file

@ -277,5 +277,37 @@ void fizzle(float2 vpos, float visibility)
clip( visibility - frac( determinant( m ) ) ); clip( visibility - frac( determinant( m ) ) );
} }
// Deferred Shading: Material Info Flag Check
bool getFlag(float flags, int num)
{
int process = round(flags * 255);
int squareNum = pow(2, num);
return (fmod(process, pow(2, squareNum)) >= squareNum);
}
// #define TORQUE_STOCK_GAMMA
#ifdef TORQUE_STOCK_GAMMA
// Sample in linear space. Decodes gamma.
float4 toLinear(float4 tex)
{
return tex;
}
// Encodes gamma.
float4 toLinear(float4 tex)
{
return tex;
}
#else
// Sample in linear space. Decodes gamma.
float4 toLinear(float4 tex)
{
return float4(pow(abs(tex.rgb), 2.2), tex.a);
}
// Encodes gamma.
float4 toGamma(float4 tex)
{
return float4(pow(abs(tex.rgb), 1.0/2.2), tex.a);
}
#endif //
#endif // _TORQUE_HLSL_ #endif // _TORQUE_HLSL_

View file

@ -120,6 +120,7 @@ void main()
{ {
// Modulate baseColor by the ambientColor. // Modulate baseColor by the ambientColor.
vec4 waterBaseColor = baseColor * vec4( ambientColor.rgb, 1 ); vec4 waterBaseColor = baseColor * vec4( ambientColor.rgb, 1 );
waterBaseColor = toLinear(waterBaseColor);
// Get the bumpNorm... // Get the bumpNorm...
vec3 bumpNorm = ( texture( bumpMap, IN_rippleTexCoord01.xy ).rgb * 2.0 - 1.0 ) * rippleMagnitude.x; vec3 bumpNorm = ( texture( bumpMap, IN_rippleTexCoord01.xy ).rgb * 2.0 - 1.0 ) * rippleMagnitude.x;

View file

@ -324,6 +324,7 @@ void main()
// Calculate the water "base" color based on depth. // Calculate the water "base" color based on depth.
vec4 waterBaseColor = baseColor * texture( depthGradMap, saturate( delta / depthGradMax ) ); vec4 waterBaseColor = baseColor * texture( depthGradMap, saturate( delta / depthGradMax ) );
waterBaseColor = toLinear(waterBaseColor);
// Modulate baseColor by the ambientColor. // Modulate baseColor by the ambientColor.
waterBaseColor *= vec4( ambientColor.rgb, 1 ); waterBaseColor *= vec4( ambientColor.rgb, 1 );

View file

@ -117,6 +117,7 @@ float4 main( ConnectData IN ) : COLOR
{ {
// Modulate baseColor by the ambientColor. // Modulate baseColor by the ambientColor.
float4 waterBaseColor = baseColor * float4( ambientColor.rgb, 1 ); float4 waterBaseColor = baseColor * float4( ambientColor.rgb, 1 );
waterBaseColor = toLinear(waterBaseColor);
// Get the bumpNorm... // Get the bumpNorm...
float3 bumpNorm = ( tex2D( bumpMap, IN.rippleTexCoord01.xy ).rgb * 2.0 - 1.0 ) * rippleMagnitude.x; float3 bumpNorm = ( tex2D( bumpMap, IN.rippleTexCoord01.xy ).rgb * 2.0 - 1.0 ) * rippleMagnitude.x;

View file

@ -311,6 +311,7 @@ float4 main( ConnectData IN ) : COLOR
// Calculate the water "base" color based on depth. // Calculate the water "base" color based on depth.
float4 waterBaseColor = baseColor * tex1D( depthGradMap, saturate( delta / depthGradMax ) ); float4 waterBaseColor = baseColor * tex1D( depthGradMap, saturate( delta / depthGradMax ) );
waterBaseColor = toLinear(waterBaseColor);
// Modulate baseColor by the ambientColor. // Modulate baseColor by the ambientColor.
waterBaseColor *= float4( ambientColor.rgb, 1 ); waterBaseColor *= float4( ambientColor.rgb, 1 );