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.cpp74
1 files changed, 53 insertions, 21 deletions
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 96354ea18f..073a1787d5 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -100,6 +100,7 @@ LLGLSLShader gBenchmarkProgram;
LLGLSLShader gReflectionProbeDisplayProgram;
LLGLSLShader gCopyProgram;
LLGLSLShader gCopyDepthProgram;
+LLGLSLShader gPBRTerrainBakeProgram;
//object shaders
LLGLSLShader gObjectPreviewProgram;
@@ -226,7 +227,7 @@ LLGLSLShader gDeferredSkinnedPBROpaqueProgram;
LLGLSLShader gHUDPBRAlphaProgram;
LLGLSLShader gDeferredPBRAlphaProgram;
LLGLSLShader gDeferredSkinnedPBRAlphaProgram;
-LLGLSLShader gDeferredPBRTerrainProgram;
+LLGLSLShader gDeferredPBRTerrainProgram[TERRAIN_PAINT_TYPE_COUNT];
LLGLSLShader gGLTFPBRMetallicRoughnessProgram;
@@ -432,7 +433,10 @@ void LLViewerShaderMgr::finalizeShaderList()
mShaderList.push_back(&gGLTFPBRMetallicRoughnessProgram);
mShaderList.push_back(&gDeferredAvatarProgram);
mShaderList.push_back(&gDeferredTerrainProgram);
- mShaderList.push_back(&gDeferredPBRTerrainProgram);
+ for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type)
+ {
+ mShaderList.push_back(&gDeferredPBRTerrainProgram[paint_type]);
+ }
mShaderList.push_back(&gDeferredDiffuseAlphaMaskProgram);
mShaderList.push_back(&gDeferredNonIndexedDiffuseAlphaMaskProgram);
mShaderList.push_back(&gDeferredTreeProgram);
@@ -1129,7 +1133,10 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedPBROpaqueProgram.unload();
gDeferredPBRAlphaProgram.unload();
gDeferredSkinnedPBRAlphaProgram.unload();
- gDeferredPBRTerrainProgram.unload();
+ for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type)
+ {
+ gDeferredPBRTerrainProgram[paint_type].unload();
+ }
return true;
}
@@ -1443,25 +1450,31 @@ bool LLViewerShaderMgr::loadShadersDeferred()
S32 detail = gSavedSettings.getS32("RenderTerrainPBRDetail");
detail = llclamp(detail, TERRAIN_PBR_DETAIL_MIN, TERRAIN_PBR_DETAIL_MAX);
const S32 mapping = clamp_terrain_mapping(gSavedSettings.getS32("RenderTerrainPBRPlanarSampleCount"));
- gDeferredPBRTerrainProgram.mName = llformat("Deferred PBR Terrain Shader %d %s",
- detail,
- (mapping == 1 ? "flat" : "triplanar"));
- gDeferredPBRTerrainProgram.mFeatures.hasSrgb = true;
- gDeferredPBRTerrainProgram.mFeatures.isAlphaLighting = true;
- gDeferredPBRTerrainProgram.mFeatures.calculatesAtmospherics = true;
- gDeferredPBRTerrainProgram.mFeatures.hasAtmospherics = true;
- gDeferredPBRTerrainProgram.mFeatures.hasGamma = true;
- gDeferredPBRTerrainProgram.mFeatures.hasTransport = true;
- gDeferredPBRTerrainProgram.mFeatures.isPBRTerrain = true;
+ for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type)
+ {
+ LLGLSLShader* shader = &gDeferredPBRTerrainProgram[paint_type];
+ shader->mName = llformat("Deferred PBR Terrain Shader %d %s %s",
+ detail,
+ (paint_type == TERRAIN_PAINT_TYPE_PBR_PAINTMAP ? "paintmap" : "heightmap-with-noise"),
+ (mapping == 1 ? "flat" : "triplanar"));
+ shader->mFeatures.hasSrgb = true;
+ shader->mFeatures.isAlphaLighting = true;
+ shader->mFeatures.calculatesAtmospherics = true;
+ shader->mFeatures.hasAtmospherics = true;
+ shader->mFeatures.hasGamma = true;
+ shader->mFeatures.hasTransport = true;
+ shader->mFeatures.isPBRTerrain = true;
- gDeferredPBRTerrainProgram.mShaderFiles.clear();
- gDeferredPBRTerrainProgram.mShaderFiles.push_back(make_pair("deferred/pbrterrainV.glsl", GL_VERTEX_SHADER));
- gDeferredPBRTerrainProgram.mShaderFiles.push_back(make_pair("deferred/pbrterrainF.glsl", GL_FRAGMENT_SHADER));
- gDeferredPBRTerrainProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
- gDeferredPBRTerrainProgram.addPermutation("TERRAIN_PBR_DETAIL", llformat("%d", detail));
- gDeferredPBRTerrainProgram.addPermutation("TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT", llformat("%d", mapping));
- success = gDeferredPBRTerrainProgram.createShader();
- llassert(success);
+ shader->mShaderFiles.clear();
+ shader->mShaderFiles.push_back(make_pair("deferred/pbrterrainV.glsl", GL_VERTEX_SHADER));
+ shader->mShaderFiles.push_back(make_pair("deferred/pbrterrainF.glsl", GL_FRAGMENT_SHADER));
+ shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ shader->addPermutation("TERRAIN_PBR_DETAIL", llformat("%d", detail));
+ shader->addPermutation("TERRAIN_PAINT_TYPE", llformat("%d", paint_type));
+ shader->addPermutation("TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT", llformat("%d", mapping));
+ success = success && shader->createShader();
+ llassert(success);
+ }
}
if (success)
@@ -2959,6 +2972,25 @@ bool LLViewerShaderMgr::loadShadersInterface()
if (success)
{
+ LLGLSLShader* shader = &gPBRTerrainBakeProgram;
+ U32 bit_depth = gSavedSettings.getU32("TerrainPaintBitDepth");
+ // LLTerrainPaintMap currently uses an RGB8 texture internally
+ bit_depth = llclamp(bit_depth, 1, 8);
+ shader->mName = llformat("Terrain Bake Shader RGB%o", bit_depth);
+ shader->mFeatures.isPBRTerrain = true;
+
+ shader->mShaderFiles.clear();
+ shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeV.glsl", GL_VERTEX_SHADER));
+ shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeF.glsl", GL_FRAGMENT_SHADER));
+ shader->mShaderLevel = mShaderLevel[SHADER_INTERFACE];
+ const U32 value_range = (1 << bit_depth) - 1;
+ shader->addPermutation("TERRAIN_PAINT_PRECISION", llformat("%d", value_range));
+ success = success && shader->createShader();
+ llassert(success);
+ }
+
+ if (success)
+ {
gAlphaMaskProgram.mName = "Alpha Mask Shader";
gAlphaMaskProgram.mShaderFiles.clear();
gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskV.glsl", GL_VERTEX_SHADER));