summaryrefslogtreecommitdiff
path: root/indra/newview/llviewershadermgr.cpp
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2013-07-10 09:47:46 -0700
committerGraham Linden <graham@lindenlab.com>2013-07-10 09:47:46 -0700
commit326e20b0e5cd8e30d4b52c662a29aa2fc816b40d (patch)
treef9c766719839a8948ac4ff3463a420525169ee1b /indra/newview/llviewershadermgr.cpp
parent167fc262734dfb72e33e57a0b309d0ce6a17ce47 (diff)
NORSPEC-291 WIP materials underwater w and wo alpha, water fog color broken, no refl, no water dis
Diffstat (limited to 'indra/newview/llviewershadermgr.cpp')
-rwxr-xr-xindra/newview/llviewershadermgr.cpp97
1 files changed, 96 insertions, 1 deletions
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 6d9a0dd261..88593346c0 100755
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -168,6 +168,7 @@ LLGLSLShader gPostNightVisionProgram;
// Deferred rendering shaders
LLGLSLShader gDeferredImpostorProgram;
LLGLSLShader gDeferredWaterProgram;
+LLGLSLShader gDeferredUnderWaterProgram;
LLGLSLShader gDeferredDiffuseProgram;
LLGLSLShader gDeferredDiffuseAlphaMaskProgram;
LLGLSLShader gDeferredNonIndexedDiffuseProgram;
@@ -189,6 +190,7 @@ LLGLSLShader gDeferredMultiSpotLightProgram;
LLGLSLShader gDeferredSunProgram;
LLGLSLShader gDeferredBlurLightProgram;
LLGLSLShader gDeferredSoftenProgram;
+LLGLSLShader gDeferredSoftenWaterProgram;
LLGLSLShader gDeferredShadowProgram;
LLGLSLShader gDeferredShadowCubeProgram;
LLGLSLShader gDeferredShadowAlphaMaskProgram;
@@ -215,6 +217,7 @@ LLGLSLShader gNormalMapGenProgram;
// Deferred materials shaders
LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2];
+LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2];
LLViewerShaderMgr::LLViewerShaderMgr() :
mVertexShaderLevel(SHADER_COUNT, 0),
@@ -280,14 +283,23 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
mShaderList.push_back(&gUnderWaterProgram);
mShaderList.push_back(&gDeferredSunProgram);
mShaderList.push_back(&gDeferredSoftenProgram);
+ mShaderList.push_back(&gDeferredSoftenWaterProgram);
mShaderList.push_back(&gDeferredMaterialProgram[1]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[1]);
mShaderList.push_back(&gDeferredMaterialProgram[5]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[5]);
mShaderList.push_back(&gDeferredMaterialProgram[9]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[9]);
mShaderList.push_back(&gDeferredMaterialProgram[13]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[13]);
mShaderList.push_back(&gDeferredMaterialProgram[1+LLMaterial::SHADER_COUNT]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredMaterialProgram[5+LLMaterial::SHADER_COUNT]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT]);
+ mShaderList.push_back(&gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredAlphaProgram);
mShaderList.push_back(&gDeferredSkinnedAlphaProgram);
mShaderList.push_back(&gDeferredFullbrightProgram);
@@ -1123,6 +1135,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSunProgram.unload();
gDeferredBlurLightProgram.unload();
gDeferredSoftenProgram.unload();
+ gDeferredSoftenWaterProgram.unload();
gDeferredShadowProgram.unload();
gDeferredShadowCubeProgram.unload();
gDeferredShadowAlphaMaskProgram.unload();
@@ -1141,6 +1154,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredPostGammaCorrectProgram.unload();
gFXAAProgram.unload();
gDeferredWaterProgram.unload();
+ gDeferredUnderWaterProgram.unload();
gDeferredWLSkyProgram.unload();
gDeferredWLCloudProgram.unload();
gDeferredStarProgram.unload();
@@ -1152,6 +1166,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
for (U32 i = 0; i < LLMaterial::SHADER_COUNT*2; ++i)
{
gDeferredMaterialProgram[i].unload();
+ gDeferredMaterialWaterProgram[i].unload();
}
return TRUE;
}
@@ -1279,6 +1294,15 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[1].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[5].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[9].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[13].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
+ gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
+
for (U32 i = 0; i < LLMaterial::SHADER_COUNT*2; ++i)
{
if (success)
@@ -1305,6 +1329,35 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
success = gDeferredMaterialProgram[i].createShader(NULL, NULL);
}
+
+ if (success)
+ {
+ gDeferredMaterialProgram[i].mName = llformat("Deferred Material Shader %d", i);
+
+ U32 alpha_mode = i & 0x3;
+
+ gDeferredMaterialWaterProgram[i].mShaderFiles.clear();
+ gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
+ gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gDeferredMaterialWaterProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+ gDeferredMaterialWaterProgram[i].addPermutation("HAS_NORMAL_MAP", i & 0x8? "1" : "0");
+ gDeferredMaterialWaterProgram[i].addPermutation("HAS_SPECULAR_MAP", i & 0x4 ? "1" : "0");
+ gDeferredMaterialWaterProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode));
+ gDeferredMaterialWaterProgram[i].addPermutation("HAS_SUN_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0");
+ bool has_skin = i & 0x10;
+ gDeferredMaterialWaterProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0");
+
+ gDeferredMaterialWaterProgram[i].addPermutation("WATER_FOG","1");
+ gDeferredMaterialWaterProgram[i].mFeatures.hasWaterFog = true;
+ gDeferredMaterialWaterProgram[i].mShaderGroup = SHADER_WATER;
+
+ if (has_skin)
+ {
+ gDeferredMaterialWaterProgram[i].mFeatures.hasObjectSkinning = true;
+ }
+
+ success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL);
+ }
}
gDeferredMaterialProgram[1].mFeatures.hasLighting = true;
@@ -1316,7 +1369,14 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-
+ gDeferredMaterialWaterProgram[1].mFeatures.hasLighting = true;
+ gDeferredMaterialWaterProgram[5].mFeatures.hasLighting = true;
+ gDeferredMaterialWaterProgram[9].mFeatures.hasLighting = true;
+ gDeferredMaterialWaterProgram[13].mFeatures.hasLighting = true;
+ gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
+ gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
+ gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
+ gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
if (success)
{
@@ -1584,6 +1644,21 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
+ // load water shader
+ /*gDeferredUnderWaterProgram.mName = "Deferred Under Water Shader";
+ gDeferredUnderWaterProgram.mFeatures.calculatesAtmospherics = true;
+ gDeferredUnderWaterProgram.mFeatures.hasGamma = true;
+ gDeferredUnderWaterProgram.mShaderFiles.clear();
+ gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB));
+ gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/underWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gDeferredUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER];
+ gDeferredUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
+
+ success = gDeferredUnderWaterProgram.createShader(NULL, &mWaterUniforms);*/
+ }
+
+ if (success)
+ {
gDeferredSoftenProgram.mName = "Deferred Soften Shader";
gDeferredSoftenProgram.mShaderFiles.clear();
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1601,6 +1676,26 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
+ gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader";
+ gDeferredSoftenWaterProgram.mFeatures.hasWaterFog = true;
+ gDeferredSoftenWaterProgram.mShaderFiles.clear();
+ gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
+ gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB));
+
+ gDeferredSoftenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+ gDeferredSoftenWaterProgram.addPermutation("WATER_FOG", "1");
+ gDeferredSoftenWaterProgram.mShaderGroup = SHADER_WATER;
+
+ if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
+ { //if using SSAO, take screen space light map into account as if shadows are enabled
+ gDeferredSoftenWaterProgram.mShaderLevel = llmax(gDeferredSoftenWaterProgram.mShaderLevel, 2);
+ }
+
+ success = gDeferredSoftenWaterProgram.createShader(NULL, NULL);
+ }
+
+ if (success)
+ {
gDeferredShadowProgram.mName = "Deferred Shadow Shader";
gDeferredShadowProgram.mShaderFiles.clear();
gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowV.glsl", GL_VERTEX_SHADER_ARB));