mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-23 21:35:34 +00:00
Implementation of sRGB image support. Overhauls the linearization setup to utilize the sRGB image types, as well as refactors the use of ColorF and ColorI to be properly internally consistent. ColorIs are used only for front-facing/editing/UI settings, and ColorFs, now renamed to LinearColorF to reduce confusion of purpose, are used for color info in the engine itself. This avoids confusing and expensive conversions back and forth between types and avoids botches with linearity. Majority work done by @rextimmy
This commit is contained in:
parent
8943c673fb
commit
0801a3cca8
294 changed files with 3894 additions and 2813 deletions
|
|
@ -342,7 +342,7 @@ void ParallaxFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
Var *bumpMapTexture = (Var*)LangElement::find("bumpMapTex");
|
||||
|
||||
// Call the library function to do the rest.
|
||||
if (fd.features.hasFeature(MFT_IsDXTnm, getProcessIndex()))
|
||||
if (fd.features.hasFeature(MFT_IsBC3nm, getProcessIndex()))
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, @, @.xy, @, @ );\r\n",
|
||||
texCoord, bumpMapTexture, normalMap, texCoord, negViewTS, parallaxInfo));
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ void PixelSpecularHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if (specularColor)
|
||||
final = new GenOp( "@ * @", final, specularColor );
|
||||
}
|
||||
else if ( fd.features[MFT_NormalMap] && !fd.features[MFT_IsDXTnm] )
|
||||
else if ( fd.features[MFT_NormalMap] && !fd.features[MFT_IsBC3nm] && !fd.features[MFT_IsBC5nm])
|
||||
{
|
||||
Var *bumpColor = (Var*)LangElement::find( "bumpNormal" );
|
||||
final = new GenOp( "@ * @.a", final, bumpColor );
|
||||
|
|
|
|||
|
|
@ -146,8 +146,9 @@ LangElement *ShaderFeatureHLSL::expandNormalMap( LangElement *sampleNormalOp,
|
|||
const MaterialFeatureData &fd )
|
||||
{
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
if ( fd.features.hasFeature( MFT_IsDXTnm, getProcessIndex() ) )
|
||||
const bool hasBc3 = fd.features.hasFeature(MFT_IsBC3nm, getProcessIndex() );
|
||||
const bool hasBc5 = fd.features.hasFeature(MFT_IsBC5nm, getProcessIndex() );
|
||||
if ( hasBc3 || hasBc5 )
|
||||
{
|
||||
if ( fd.features[MFT_ImposterVert] )
|
||||
{
|
||||
|
|
@ -155,12 +156,18 @@ LangElement *ShaderFeatureHLSL::expandNormalMap( LangElement *sampleNormalOp,
|
|||
// encodes them with the z axis in the alpha component.
|
||||
meta->addStatement( new GenOp( " @ = float4( normalize( @.xyw * 2.0 - 1.0 ), 0.0 ); // Obj DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
}
|
||||
else
|
||||
else if( hasBc3 )
|
||||
{
|
||||
// DXT Swizzle trick
|
||||
// BC3 Swizzle trick
|
||||
meta->addStatement( new GenOp( " @ = float4( @.ag * 2.0 - 1.0, 0.0, 0.0 ); // DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement( new GenOp( " @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // DXTnm\r\n", normalVar, normalVar, normalVar ) );
|
||||
}
|
||||
else if (hasBc5)
|
||||
{
|
||||
// BC5
|
||||
meta->addStatement(new GenOp(" @ = float4( @.gr * 2.0 - 1.0, 0.0, 0.0 ); // bc5nm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement(new GenOp(" @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // bc5nm\r\n", normalVar, normalVar, normalVar )) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -874,10 +881,6 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if ( fd.features[MFT_CubeMap] )
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = @.Sample(@, @);\r\n", colorDecl, diffuseMapTex, 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, NULL, targ)));
|
||||
}
|
||||
else if(fd.features[MFT_DiffuseMapAtlas])
|
||||
|
|
@ -951,9 +954,6 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
#endif
|
||||
meta->addStatement(new GenOp(" @ = @.SampleLevel(@,@,mipLod);\r\n",
|
||||
new DecOp(diffColor), diffuseMapTex, 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, NULL, targ) ) );
|
||||
}
|
||||
|
|
@ -961,8 +961,6 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
{
|
||||
meta->addStatement(new GenOp("@ = @.Sample(@, @);\r\n", colorDecl, diffuseMapTex, 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, NULL, targ)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
|||
|
||||
FEATUREMGR->registerFeature( MFT_VertTransform, new VertPositionHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_RTLighting, new RTLightingFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_IsDXTnm, new NamedFeatureHLSL( "DXTnm" ) );
|
||||
FEATUREMGR->registerFeature( MFT_IsBC3nm, new NamedFeatureHLSL( "BC3nm" ) );
|
||||
FEATUREMGR->registerFeature( MFT_IsBC5nm, new NamedFeatureHLSL( "BC5nm" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TexAnim, new TexAnimHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DiffuseMap, new DiffuseMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_OverlayMap, new OverlayTexFeatHLSL );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue