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

@ -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.
#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_