mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
diffuse/albedo texture linearization
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html
This commit is contained in:
parent
51b6469922
commit
ce2964d2d0
31 changed files with 396 additions and 107 deletions
|
|
@ -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_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue