From 73703191e0fc91e022d01c91740c1deade8cbaf5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 26 Jul 2013 12:44:05 -0700 Subject: NORSPEC-327 modify 'select' ops in srgb shader code to mollify the doddering mac GLSL compiler --- .../app_settings/shaders/class1/deferred/srgb.glsl | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred') diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl index 177f6c25f8..d532835bf1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +// OLD_SELECT work-around missing mix(vec3,vec,bvec3) in older GLSL versions (*cough* MAC *cough*) + vec3 srgb_to_linear(vec3 cs) { @@ -32,7 +34,17 @@ vec3 srgb_to_linear(vec3 cs) vec3 low_range = cs / vec3(12.92); vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else return mix(high_range, low_range, lessThanEqual(cs,vec3(0.04045))); +#endif } vec3 linear_to_srgb(vec3 cl) @@ -45,5 +57,17 @@ vec3 linear_to_srgb(vec3 cl) cl = clamp(cl, vec3(0), vec3(1)); vec3 low_range = cl * 12.92; vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else return mix(high_range, low_range, lessThan(cl,vec3(0.0031308))); +#endif } + -- cgit v1.2.3