浏览代码

Merge pull request #1732 from Azaezel/linearGammaHelperFuncs

vec3 variants for toLinear and toGamma
Anis 9 年之前
父节点
当前提交
507c239a87

+ 19 - 0
Templates/Empty/game/shaders/common/gl/torque.glsl

@@ -304,6 +304,15 @@ vec4 toGamma(vec4 tex)
 {
    return tex;
 }
+vec3 toLinear(vec3 tex)
+{
+   return tex;
+}
+// Encodes gamma.
+vec3 toGamma(vec3 tex)
+{
+   return tex;
+}
 #else
 // Sample in linear space. Decodes gamma.
 vec4 toLinear(vec4 tex)
@@ -315,6 +324,16 @@ vec4 toGamma(vec4 tex)
 {
    return vec4(pow(abs(tex.rgb), vec3(1.0/2.2)), tex.a);
 }
+// Sample in linear space. Decodes gamma.
+vec3 toLinear(vec3 tex)
+{
+   return pow(abs(tex), vec3(2.2));
+}
+// Encodes gamma.
+vec3 toGamma(vec3 tex)
+{
+   return pow(abs(tex), vec3(1.0/2.2));
+}
 #endif //
 
 #endif // _TORQUE_GLSL_

+ 29 - 1
Templates/Empty/game/shaders/common/torque.hlsl

@@ -294,7 +294,25 @@ float4 toLinear(float4 tex)
    return tex;
 }
 // Encodes gamma.
-float4 toLinear(float4 tex)
+float4 toGamma(float4 tex)
+{
+   return tex;
+}
+float3 toLinear(float3 tex)
+{
+   return tex;
+}
+// Encodes gamma.
+float3 toGamma(float3 tex)
+{
+   return tex;
+}
+float3 toLinear(float3 tex)
+{
+   return tex;
+}
+// Encodes gamma.
+float3 toLinear(float3 tex)
 {
    return tex;
 }
@@ -309,6 +327,16 @@ float4 toGamma(float4 tex)
 {
    return float4(pow(abs(tex.rgb), 1.0/2.2), tex.a);
 }
+// Sample in linear space. Decodes gamma.
+float3 toLinear(float3 tex)
+{
+   return pow(abs(tex.rgb), 2.2);
+}
+// Encodes gamma.
+float3 toGamma(float3 tex)
+{
+   return pow(abs(tex.rgb), 1.0/2.2);
+}
 #endif //
 
 #endif // _TORQUE_HLSL_

+ 19 - 0
Templates/Full/game/shaders/common/gl/torque.glsl

@@ -304,6 +304,15 @@ vec4 toGamma(vec4 tex)
 {
    return tex;
 }
+vec3 toLinear(vec3 tex)
+{
+   return tex;
+}
+// Encodes gamma.
+vec3 toGamma(vec3 tex)
+{
+   return tex;
+}
 #else
 // Sample in linear space. Decodes gamma.
 vec4 toLinear(vec4 tex)
@@ -315,6 +324,16 @@ vec4 toGamma(vec4 tex)
 {
    return vec4(pow(abs(tex.rgb), vec3(1.0/2.2)), tex.a);
 }
+// Sample in linear space. Decodes gamma.
+vec3 toLinear(vec3 tex)
+{
+   return pow(abs(tex), vec3(2.2));
+}
+// Encodes gamma.
+vec3 toGamma(vec3 tex)
+{
+   return pow(abs(tex), vec3(1.0/2.2));
+}
 #endif //
 
 #endif // _TORQUE_GLSL_

+ 29 - 1
Templates/Full/game/shaders/common/torque.hlsl

@@ -294,7 +294,25 @@ float4 toLinear(float4 tex)
    return tex;
 }
 // Encodes gamma.
-float4 toLinear(float4 tex)
+float4 toGamma(float4 tex)
+{
+   return tex;
+}
+float3 toLinear(float3 tex)
+{
+   return tex;
+}
+// Encodes gamma.
+float3 toGamma(float3 tex)
+{
+   return tex;
+}
+float3 toLinear(float3 tex)
+{
+   return tex;
+}
+// Encodes gamma.
+float3 toLinear(float3 tex)
 {
    return tex;
 }
@@ -309,6 +327,16 @@ float4 toGamma(float4 tex)
 {
    return float4(pow(abs(tex.rgb), 1.0/2.2), tex.a);
 }
+// Sample in linear space. Decodes gamma.
+float3 toLinear(float3 tex)
+{
+   return pow(abs(tex.rgb), 2.2);
+}
+// Encodes gamma.
+float3 toGamma(float3 tex)
+{
+   return pow(abs(tex.rgb), 1.0/2.2);
+}
 #endif //
 
 #endif // _TORQUE_HLSL_