diff options
author | Dave Parks <davep@lindenlab.com> | 2012-02-21 14:02:09 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2012-02-21 14:02:09 -0600 |
commit | e1a71a97cd00d70fedeb6191b6ebb10361019ee1 (patch) | |
tree | e8890e6ab769c1b53ea439ac99c1ee3b7efa59ac | |
parent | 48f5b69c43d4d4a2b6e272f7ac8d706ccc0c0601 (diff) |
SH-2908 Potential fix for pink textures on some OpenGL 3.1 implementations.
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 9aeb1a99f8..e1cd8fa62d 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -614,6 +614,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //some implementations of GLSL 1.30 require integer precision be explicitly declared text[count++] = strdup("precision mediump int;\n"); + text[count++] = strdup("precision highp float;\n"); } else { //set version to 400 @@ -668,20 +669,22 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade VARYING_FLAT ivec4 vary_texture_index; + vec4 ret = vec4(1,0,1,1); + vec4 diffuseLookup(vec2 texcoord) { switch (vary_texture_index.r)) { - case 0: return texture2D(tex0, texcoord); - case 1: return texture2D(tex1, texcoord); - case 2: return texture2D(tex2, texcoord); + case 0: ret = texture2D(tex0, texcoord); break; + case 1: ret = texture2D(tex1, texcoord); break; + case 2: ret = texture2D(tex2, texcoord); break; . . . - case N: return texture2D(texN, texcoord); + case N: return texture2D(texN, texcoord); break; } - return vec4(0,0,0,0); + return ret; } */ @@ -708,18 +711,19 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } else if (major_version > 1 || minor_version >= 30) { //switches are supported in GLSL 1.30 and later + text[count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n"); text[count++] = strdup("\tswitch (vary_texture_index.r)\n"); text[count++] = strdup("\t{\n"); //switch body for (S32 i = 0; i < texture_index_channels; ++i) { - std::string case_str = llformat("\t\tcase %d: return texture2D(tex%d, texcoord);\n", i, i); + std::string case_str = llformat("\t\tcase %d: ret = texture2D(tex%d, texcoord); break;\n", i, i); text[count++] = strdup(case_str.c_str()); } text[count++] = strdup("\t}\n"); - text[count++] = strdup("\treturn vec4(1,0,1,1);\n"); + text[count++] = strdup("\treturn ret;\n"); text[count++] = strdup("}\n"); } else |