summaryrefslogtreecommitdiff
path: root/indra/newview/llviewershadermgr.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2013-03-27 21:59:14 -0500
committerDave Parks <davep@lindenlab.com>2013-03-27 21:59:14 -0500
commit6300f4f768de13823a754831797cb34022f87b60 (patch)
treeae847221ee1a68535e58562cb291441489ab0f82 /indra/newview/llviewershadermgr.cpp
parent7be396cc985c0274ff05b375a8bf27c0e630666a (diff)
NORSPEC-61 Hook up material parameters to shaders.
Diffstat (limited to 'indra/newview/llviewershadermgr.cpp')
-rw-r--r--indra/newview/llviewershadermgr.cpp144
1 files changed, 24 insertions, 120 deletions
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 17bfc24f43..4e38d2f7e9 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -208,15 +208,7 @@ LLGLSLShader gDeferredStarProgram;
LLGLSLShader gNormalMapGenProgram;
// Deferred materials shaders
-LLGLSLShader gDeferredMaterialShiny;
-LLGLSLShader gDeferredMaterialNormal;
-LLGLSLShader gDeferredMaterialShinyNormal;
-LLGLSLShader gDeferredMaterialShinyAlphaTest;
-LLGLSLShader gDeferredMaterialNormalAlphaTest;
-LLGLSLShader gDeferredMaterialShinyNormalAlphaTest;
-LLGLSLShader gDeferredMaterialShinyEmissive;
-LLGLSLShader gDeferredMaterialNormalEmissive;
-LLGLSLShader gDeferredMaterialShinyNormalEmissive;
+LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT];
LLViewerShaderMgr::LLViewerShaderMgr() :
mVertexShaderLevel(SHADER_COUNT, 0),
@@ -1116,12 +1108,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLCloudProgram.unload();
gDeferredStarProgram.unload();
gNormalMapGenProgram.unload();
- gDeferredMaterialShiny.unload();
- gDeferredMaterialNormal.unload();
- gDeferredMaterialShinyAlphaTest.unload();
- gDeferredMaterialNormalAlphaTest.unload();
- gDeferredMaterialShinyEmissive.unload();
- gDeferredMaterialNormalEmissive.unload();
+ for (U32 i = 0; i < LLMaterial::SHADER_COUNT; ++i)
+ {
+ gDeferredMaterialProgram[i].unload();
+ }
return TRUE;
}
@@ -1236,114 +1226,28 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
success = gDeferredBumpProgram.createShader(NULL, NULL);
}
- if (success)
- {
- gDeferredMaterialShiny.mName = "Deferred Shiny Material Shader";
- gDeferredMaterialShiny.mShaderFiles.clear();
- gDeferredMaterialShiny.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialShiny.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialShiny.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialShiny.addPermutation("SHINY_MATERIAL", "1");
- success = gDeferredMaterialShiny.createShader(NULL, NULL);
- }
-
- if (success)
- {
- gDeferredMaterialNormal.mName = "Deferred Normal Mapped Material Shader";
- gDeferredMaterialNormal.mShaderFiles.clear();
- gDeferredMaterialNormal.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialNormal.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialNormal.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialNormal.addPermutation("NORMAL_MATERIAL", "1");
- success = gDeferredMaterialNormal.createShader(NULL, NULL);
- }
-
- if (success)
- {
- gDeferredMaterialShinyNormal.mName = "Deferred Normal Mapped Shiny Material Shader";
- gDeferredMaterialShinyNormal.mShaderFiles.clear();
- gDeferredMaterialShinyNormal.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialShinyNormal.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialShinyNormal.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialShinyNormal.addPermutation("NORMAL_MATERIAL", "1");
- gDeferredMaterialShinyNormal.addPermutation("SHINY_MATERIAL", "1");
- success = gDeferredMaterialShinyNormal.createShader(NULL, NULL);
- }
-
- if (success)
- {
- gDeferredMaterialShinyAlphaTest.mName = "Deferred Alpha Tested Shiny Material Shader";
- gDeferredMaterialShinyAlphaTest.mShaderFiles.clear();
- gDeferredMaterialShinyAlphaTest.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialShinyAlphaTest.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialShinyAlphaTest.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialShinyAlphaTest.addPermutation("SHINY_MATERIAL", "1");
- gDeferredMaterialShinyAlphaTest.addPermutation("ALPHA_TEST", "1");
- success = gDeferredMaterialShinyAlphaTest.createShader(NULL, NULL);
- }
-
- if (success)
- {
- gDeferredMaterialNormalAlphaTest.mName = "Deferred Alpha Tested Normal Mapped Material Shader";
- gDeferredMaterialNormalAlphaTest.mShaderFiles.clear();
- gDeferredMaterialNormalAlphaTest.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialNormalAlphaTest.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialNormalAlphaTest.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialNormalAlphaTest.addPermutation("NORMAL_MATERIAL", "1");
- gDeferredMaterialNormalAlphaTest.addPermutation("ALPHA_TEST", "1");
- success = gDeferredMaterialNormalAlphaTest.createShader(NULL, NULL);
- }
-
- if (success)
- {
- gDeferredMaterialNormalAlphaTest.mName = "Deferred Alpha Tested Shiny Normal Mapped Material Shader";
- gDeferredMaterialShinyNormalAlphaTest.mShaderFiles.clear();
- gDeferredMaterialShinyNormalAlphaTest.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialShinyNormalAlphaTest.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialShinyNormalAlphaTest.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialShinyNormalAlphaTest.addPermutation("NORMAL_MATERIAL", "1");
- gDeferredMaterialShinyNormalAlphaTest.addPermutation("SHINY_MATERIAL", "1");
- gDeferredMaterialShinyNormalAlphaTest.addPermutation("ALPHA_TEST", "1");
- success = gDeferredMaterialShinyNormalAlphaTest.createShader(NULL, NULL);
- }
-
- if (success)
- {
- gDeferredMaterialShinyEmissive.mName = "Deferred Emissive Mask Shiny Material Shader";
- gDeferredMaterialShinyEmissive.mShaderFiles.clear();
- gDeferredMaterialShinyEmissive.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialShinyEmissive.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialShinyEmissive.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialShinyEmissive.addPermutation("SHINY_MATERIAL", "1");
- gDeferredMaterialShinyEmissive.addPermutation("EMISSIVE_MASK", "1");
- success = gDeferredMaterialShinyEmissive.createShader(NULL, NULL);
- }
-
- if (success)
- {
- gDeferredMaterialNormalEmissive.mName = "Deferred Emissive Mask Normal Mapped Material Shader";
- gDeferredMaterialNormalEmissive.mShaderFiles.clear();
- gDeferredMaterialNormalEmissive.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialNormalEmissive.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialNormalEmissive.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialNormalEmissive.addPermutation("NORMAL_MATERIAL", "1");
- gDeferredMaterialNormalEmissive.addPermutation("EMISSIVE_MASK", "1");
- success = gDeferredMaterialNormalEmissive.createShader(NULL, NULL);
- }
-
- if (success)
+
+ for (U32 i = 0; i < LLMaterial::SHADER_COUNT; ++i)
{
- gDeferredMaterialShinyNormalEmissive.mName = "Deferred Emissive Mask Normal Mapped Material Shader";
- gDeferredMaterialShinyNormalEmissive.mShaderFiles.clear();
- gDeferredMaterialShinyNormalEmissive.mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredMaterialShinyNormalEmissive.mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
- gDeferredMaterialShinyNormalEmissive.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- gDeferredMaterialShinyNormalEmissive.addPermutation("NORMAL_MATERIAL", "1");
- gDeferredMaterialShinyNormalEmissive.addPermutation("SHINY_MATERIAL", "1");
- gDeferredMaterialShinyNormalEmissive.addPermutation("EMISSIVE_MASK", "1");
- success = gDeferredMaterialShinyNormalEmissive.createShader(NULL, NULL);
+ if (success)
+ {
+ gDeferredMaterialProgram[i].mName = llformat("Deferred Material Shader %d", i);
+
+ U32 alpha_mode = i & 0x3;
+
+ gDeferredMaterialProgram[i].mShaderFiles.clear();
+ gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
+ gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gDeferredMaterialProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+ gDeferredMaterialProgram[i].addPermutation("HAS_NORMAL_MAP", i & 0x8? "1" : "0");
+ gDeferredMaterialProgram[i].addPermutation("HAS_SPECULAR_MAP", i & 0x4 ? "1" : "0");
+ gDeferredMaterialProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode));
+
+ success = gDeferredMaterialProgram[i].createShader(NULL, NULL);
+ }
}
+
if (success)
{
gDeferredTreeProgram.mName = "Deferred Tree Shader";