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

@ -277,5 +277,37 @@ void fizzle(float2 vpos, float visibility)
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_