mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15: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
|
|
@ -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_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue