summaryrefslogtreecommitdiff
path: root/indra/newview/llviewershadermgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewershadermgr.cpp')
-rw-r--r--indra/newview/llviewershadermgr.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index e473901609..812b03a2e6 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -61,6 +61,14 @@ BOOL LLViewerShaderMgr::sInitialized = FALSE;
LLVector4 gShinyOrigin;
+//utility shaders
+LLGLSLShader gOcclusionProgram;
+LLGLSLShader gUIProgram;
+LLGLSLShader gCustomAlphaProgram;
+LLGLSLShader gGlowCombineProgram;
+LLGLSLShader gTwoTextureAddProgram;
+LLGLSLShader gSolidColorProgram;
+
//object shaders
LLGLSLShader gObjectSimpleProgram;
LLGLSLShader gObjectSimpleWaterProgram;
@@ -70,6 +78,7 @@ LLGLSLShader gObjectFullbrightShinyProgram;
LLGLSLShader gObjectFullbrightShinyWaterProgram;
LLGLSLShader gObjectShinyProgram;
LLGLSLShader gObjectShinyWaterProgram;
+LLGLSLShader gObjectBumpProgram;
LLGLSLShader gObjectSimpleNonIndexedProgram;
LLGLSLShader gObjectSimpleNonIndexedWaterProgram;
@@ -169,6 +178,13 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
mShaderList.push_back(&gWaterProgram);
mShaderList.push_back(&gAvatarEyeballProgram);
mShaderList.push_back(&gObjectSimpleProgram);
+ mShaderList.push_back(&gObjectBumpProgram);
+ mShaderList.push_back(&gUIProgram);
+ mShaderList.push_back(&gCustomAlphaProgram);
+ mShaderList.push_back(&gGlowCombineProgram);
+ mShaderList.push_back(&gTwoTextureAddProgram);
+ mShaderList.push_back(&gSolidColorProgram);
+ mShaderList.push_back(&gOcclusionProgram);
mShaderList.push_back(&gObjectFullbrightProgram);
mShaderList.push_back(&gObjectFullbrightShinyProgram);
mShaderList.push_back(&gObjectFullbrightShinyWaterProgram);
@@ -410,9 +426,13 @@ void LLViewerShaderMgr::setShaders()
}
mMaxAvatarShaderLevel = 0;
+ LLGLSLShader::sNoFixedFunction = false;
if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")
&& gSavedSettings.getBOOL("VertexShaderEnable"))
{
+ //using shaders, disable fixed function
+ LLGLSLShader::sNoFixedFunction = true;
+
S32 light_class = 2;
S32 env_class = 2;
S32 obj_class = 2;
@@ -554,6 +574,7 @@ void LLViewerShaderMgr::setShaders()
}
else
{
+ LLGLSLShader::sNoFixedFunction = false;
gPipeline.mVertexShadersEnabled = FALSE;
gPipeline.mVertexShadersLoaded = 0;
mVertexShaderLevel[SHADER_LIGHTING] = 0;
@@ -568,6 +589,7 @@ void LLViewerShaderMgr::setShaders()
}
else
{
+ LLGLSLShader::sNoFixedFunction = false;
gPipeline.mVertexShadersEnabled = FALSE;
gPipeline.mVertexShadersLoaded = 0;
mVertexShaderLevel[SHADER_LIGHTING] = 0;
@@ -591,7 +613,15 @@ void LLViewerShaderMgr::setShaders()
void LLViewerShaderMgr::unloadShaders()
{
+ gOcclusionProgram.unload();
+ gUIProgram.unload();
+ gCustomAlphaProgram.unload();
+ gGlowCombineProgram.unload();
+ gTwoTextureAddProgram.unload();
+ gSolidColorProgram.unload();
+
gObjectSimpleProgram.unload();
+ gObjectBumpProgram.unload();
gObjectSimpleWaterProgram.unload();
gObjectFullbrightProgram.unload();
gObjectFullbrightWaterProgram.unload();
@@ -1581,6 +1611,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectFullbrightShinyWaterProgram.unload();
gObjectShinyWaterProgram.unload();
gObjectSimpleProgram.unload();
+ gObjectBumpProgram.unload();
gObjectSimpleWaterProgram.unload();
gObjectFullbrightProgram.unload();
gObjectFullbrightWaterProgram.unload();
@@ -1753,6 +1784,22 @@ BOOL LLViewerShaderMgr::loadShadersObject()
if (success)
{
+ gObjectBumpProgram.mName = "Bump Shader";
+ /*gObjectBumpProgram.mFeatures.calculatesLighting = true;
+ gObjectBumpProgram.mFeatures.calculatesAtmospherics = true;
+ gObjectBumpProgram.mFeatures.hasGamma = true;
+ gObjectBumpProgram.mFeatures.hasAtmospherics = true;
+ gObjectBumpProgram.mFeatures.hasLighting = true;
+ gObjectBumpProgram.mFeatures.mIndexedTextureChannels = 0;*/
+ gObjectBumpProgram.mShaderFiles.clear();
+ gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpV.glsl", GL_VERTEX_SHADER_ARB));
+ gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gObjectBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+ success = gObjectBumpProgram.createShader(NULL, NULL);
+ }
+
+ if (success)
+ {
gObjectSimpleWaterProgram.mName = "Simple Water Shader";
gObjectSimpleWaterProgram.mFeatures.calculatesLighting = true;
gObjectSimpleWaterProgram.mFeatures.calculatesAtmospherics = true;
@@ -2135,6 +2182,85 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
success = gHighlightProgram.createShader(NULL, NULL);
}
+ if (success)
+ {
+ gUIProgram.mName = "UI Shader";
+ gUIProgram.mShaderFiles.clear();
+ gUIProgram.mShaderFiles.push_back(make_pair("interface/uiV.glsl", GL_VERTEX_SHADER_ARB));
+ gUIProgram.mShaderFiles.push_back(make_pair("interface/uiF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gUIProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+ success = gUIProgram.createShader(NULL, NULL);
+ }
+
+ if (success)
+ {
+ gCustomAlphaProgram.mName = "Custom Alpha Shader";
+ gCustomAlphaProgram.mShaderFiles.clear();
+ gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaV.glsl", GL_VERTEX_SHADER_ARB));
+ gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gCustomAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+ success = gCustomAlphaProgram.createShader(NULL, NULL);
+ }
+
+ if (success)
+ {
+ gGlowCombineProgram.mName = "Glow Combine Shader";
+ gGlowCombineProgram.mShaderFiles.clear();
+ gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineV.glsl", GL_VERTEX_SHADER_ARB));
+ gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gGlowCombineProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+ success = gGlowCombineProgram.createShader(NULL, NULL);
+ if (success)
+ {
+ gGlowCombineProgram.bind();
+ gGlowCombineProgram.uniform1i("glowMap", 0);
+ gGlowCombineProgram.uniform1i("screenMap", 1);
+ gGlowCombineProgram.unbind();
+ }
+ }
+
+ if (success)
+ {
+ gTwoTextureAddProgram.mName = "Two Texture Add Shader";
+ gTwoTextureAddProgram.mShaderFiles.clear();
+ gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddV.glsl", GL_VERTEX_SHADER_ARB));
+ gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gTwoTextureAddProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+ success = gTwoTextureAddProgram.createShader(NULL, NULL);
+ if (success)
+ {
+ gTwoTextureAddProgram.bind();
+ gTwoTextureAddProgram.uniform1i("tex0", 0);
+ gTwoTextureAddProgram.uniform1i("tex1", 1);
+ }
+ }
+
+ if (success)
+ {
+ gSolidColorProgram.mName = "Solid Color Shader";
+ gSolidColorProgram.mShaderFiles.clear();
+ gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorV.glsl", GL_VERTEX_SHADER_ARB));
+ gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gSolidColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+ success = gSolidColorProgram.createShader(NULL, NULL);
+ if (success)
+ {
+ gSolidColorProgram.bind();
+ gSolidColorProgram.uniform1i("tex0", 0);
+ gSolidColorProgram.unbind();
+ }
+ }
+
+ if (success)
+ {
+ gOcclusionProgram.mName = "Occlusion Shader";
+ gOcclusionProgram.mShaderFiles.clear();
+ gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionV.glsl", GL_VERTEX_SHADER_ARB));
+ gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gOcclusionProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+ success = gOcclusionProgram.createShader(NULL, NULL);
+ }
+
if( !success )
{
mVertexShaderLevel[SHADER_INTERFACE] = 0;