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:
Areloch 2017-06-23 11:36:20 -05:00
parent 8780f83262
commit 25686ed4be
294 changed files with 3894 additions and 2813 deletions

View file

@ -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)));
}
}