Skip to content

Commit 45b2d69

Browse files
author
Rye Mutt
authored
Add dedicated sun probe shader and remove SSAO and shadow smoothing from probe generation passes (#2405)
* Add dedicated sun probe shader and remove SSAO and shadow smoothing from probe generation passes (#2398) * Fix usage of removed sunLightNoFragCoordV in shader manager
1 parent efe8783 commit 45b2d69

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

indra/newview/llviewershadermgr.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ LLGLSLShader gDeferredMultiLightProgram[16];
158158
LLGLSLShader gDeferredSpotLightProgram;
159159
LLGLSLShader gDeferredMultiSpotLightProgram;
160160
LLGLSLShader gDeferredSunProgram;
161+
LLGLSLShader gDeferredSunProbeProgram;
161162
LLGLSLShader gHazeProgram;
162163
LLGLSLShader gHazeWaterProgram;
163164
LLGLSLShader gDeferredBlurLightProgram;
@@ -400,6 +401,7 @@ void LLViewerShaderMgr::finalizeShaderList()
400401
mShaderList.push_back(&gObjectAlphaMaskNoColorProgram);
401402
mShaderList.push_back(&gUnderWaterProgram);
402403
mShaderList.push_back(&gDeferredSunProgram);
404+
mShaderList.push_back(&gDeferredSunProbeProgram);
403405
mShaderList.push_back(&gHazeProgram);
404406
mShaderList.push_back(&gHazeWaterProgram);
405407
mShaderList.push_back(&gDeferredSoftenProgram);
@@ -1600,21 +1602,14 @@ bool LLViewerShaderMgr::loadShadersDeferred()
16001602
if (success)
16011603
{
16021604
std::string fragment;
1603-
std::string vertex = "deferred/sunLightV.glsl";
1604-
16051605
bool use_ao = gSavedSettings.getBOOL("RenderDeferredSSAO");
1606-
16071606
if (use_ao)
16081607
{
16091608
fragment = "deferred/sunLightSSAOF.glsl";
16101609
}
16111610
else
16121611
{
16131612
fragment = "deferred/sunLightF.glsl";
1614-
if (mShaderLevel[SHADER_DEFERRED] == 1)
1615-
{ //no shadows, no SSAO, no frag coord
1616-
vertex = "deferred/sunLightNoFragCoordV.glsl";
1617-
}
16181613
}
16191614

16201615
gDeferredSunProgram.mName = "Deferred Sun Shader";
@@ -1623,14 +1618,29 @@ bool LLViewerShaderMgr::loadShadersDeferred()
16231618
gDeferredSunProgram.mFeatures.hasAmbientOcclusion = use_ao;
16241619

16251620
gDeferredSunProgram.mShaderFiles.clear();
1626-
gDeferredSunProgram.mShaderFiles.push_back(make_pair(vertex, GL_VERTEX_SHADER));
1621+
gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER));
16271622
gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER));
16281623
gDeferredSunProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
16291624

16301625
success = gDeferredSunProgram.createShader();
16311626
llassert(success);
16321627
}
16331628

1629+
if (success)
1630+
{
1631+
gDeferredSunProbeProgram.mName = "Deferred Sun Probe Shader";
1632+
gDeferredSunProbeProgram.mFeatures.isDeferred = true;
1633+
gDeferredSunProbeProgram.mFeatures.hasShadows = true;
1634+
1635+
gDeferredSunProbeProgram.mShaderFiles.clear();
1636+
gDeferredSunProbeProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER));
1637+
gDeferredSunProbeProgram.mShaderFiles.push_back(make_pair("deferred/sunLightF.glsl", GL_FRAGMENT_SHADER));
1638+
gDeferredSunProbeProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
1639+
1640+
success = gDeferredSunProbeProgram.createShader();
1641+
llassert(success);
1642+
}
1643+
16341644
if (success)
16351645
{
16361646
gDeferredBlurLightProgram.mName = "Deferred Blur Light Shader";

indra/newview/llviewershadermgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ extern LLGLSLShader gDeferredMultiLightProgram[LL_DEFERRED_MULTI_LIGHT_C
230230
extern LLGLSLShader gDeferredSpotLightProgram;
231231
extern LLGLSLShader gDeferredMultiSpotLightProgram;
232232
extern LLGLSLShader gDeferredSunProgram;
233+
extern LLGLSLShader gDeferredSunProbeProgram;
233234
extern LLGLSLShader gHazeProgram;
234235
extern LLGLSLShader gHazeWaterProgram;
235236
extern LLGLSLShader gDeferredBlurLightProgram;

indra/newview/pipeline.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7930,13 +7930,15 @@ void LLPipeline::renderDeferredLighting()
79307930
mat.mult_matrix_vec(tc_moon);
79317931
mTransformedMoonDir.set(tc_moon.v);
79327932

7933-
if (RenderDeferredSSAO || RenderShadowDetail > 0)
7933+
if ((RenderDeferredSSAO && !gCubeSnapshot) || RenderShadowDetail > 0)
79347934
{
79357935
LL_PROFILE_GPU_ZONE("sun program");
79367936
deferred_light_target->bindTarget();
79377937
{ // paint shadow/SSAO light map (direct lighting lightmap)
79387938
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - sun shadow");
7939-
bindDeferredShader(gDeferredSunProgram, deferred_light_target);
7939+
7940+
LLGLSLShader& sun_shader = gCubeSnapshot ? gDeferredSunProbeProgram : gDeferredSunProgram;
7941+
bindDeferredShader(sun_shader, deferred_light_target);
79407942
mScreenTriangleVB->setBuffer();
79417943
glClearColor(1, 1, 1, 1);
79427944
deferred_light_target->clear(GL_COLOR_BUFFER_BIT);
@@ -7961,8 +7963,8 @@ void LLPipeline::renderDeferredLighting()
79617963
}
79627964
}
79637965

7964-
gDeferredSunProgram.uniform3fv(sOffset, slice, offset);
7965-
gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES,
7966+
sun_shader.uniform3fv(sOffset, slice, offset);
7967+
sun_shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES,
79667968
(GLfloat)deferred_light_target->getWidth(),
79677969
(GLfloat)deferred_light_target->getHeight());
79687970

@@ -7972,12 +7974,12 @@ void LLPipeline::renderDeferredLighting()
79727974
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
79737975
}
79747976

7975-
unbindDeferredShader(gDeferredSunProgram);
7977+
unbindDeferredShader(sun_shader);
79767978
}
79777979
deferred_light_target->flush();
79787980
}
79797981

7980-
if (RenderDeferredSSAO)
7982+
if (RenderDeferredSSAO && !gCubeSnapshot)
79817983
{
79827984
// soften direct lighting lightmap
79837985
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow");

0 commit comments

Comments
 (0)