summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-01-23 16:17:12 -0600
committerDave Parks <davep@lindenlab.com>2023-01-23 16:17:12 -0600
commit6419e7f9f96ddee14c33a97eef4860efff2b2923 (patch)
treebc5cbc622f9cd538fffbacaf7c4d2d0af9862e5c
parentdcf05c57c8b934baf1597fbffc3f501a8e1538b0 (diff)
SL-19015 Fix for ugly SSAO
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl16
-rw-r--r--indra/newview/pipeline.cpp150
2 files changed, 56 insertions, 110 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 9bead273ff..93a85cad40 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -39,6 +39,7 @@ uniform sampler2D lightMap;
uniform float dist_factor;
uniform float blur_size;
uniform vec2 delta;
+uniform vec2 screen_res;
uniform vec3 kern[4];
uniform float kern_scale;
@@ -52,8 +53,8 @@ void main()
vec2 tc = vary_fragcoord.xy;
vec3 norm = getNorm(tc);
vec3 pos = getPosition(tc).xyz;
- vec4 ccol = texture2D(lightMap, tc).rgba;
-
+ vec4 ccol = texture(lightMap, tc).rgba;
+
vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy);
dlt /= max(-pos.z*dist_factor, 1.0);
@@ -64,7 +65,8 @@ void main()
float pointplanedist_tolerance_pow2 = pos.z*pos.z*0.00005;
// perturb sampling origin slightly in screen-space to hide edge-ghosting artifacts where smoothing radius is quite large
- float tc_mod = 0.5*(tc.x + tc.y); // mod(tc.x+tc.y,2)
+ tc *= screen_res;
+ float tc_mod = 0.5*(tc.x + tc.y);
tc_mod -= floor(tc_mod);
tc_mod *= 2.0;
tc += ( (tc_mod - 0.5) * kern[1].z * dlt * 0.5 );
@@ -83,13 +85,14 @@ void main()
for (int i = 1; i < 7; i++)
{
vec2 samptc = tc + k[i].z*dlt*2.0;
+ samptc /= screen_res;
vec3 samppos = getPosition(samptc).xyz;
float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
if (d*d <= pointplanedist_tolerance_pow2)
{
- col += texture2D(lightMap, samptc)*k[i].xyxx;
+ col += texture(lightMap, samptc)*k[i].xyxx;
defined_weight += k[i].xy;
}
}
@@ -97,19 +100,20 @@ void main()
for (int i = 1; i < 7; i++)
{
vec2 samptc = tc - k[i].z*dlt*2.0;
+ samptc /= screen_res;
vec3 samppos = getPosition(samptc).xyz;
float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
if (d*d <= pointplanedist_tolerance_pow2)
{
- col += texture2D(lightMap, samptc)*k[i].xyxx;
+ col += texture(lightMap, samptc)*k[i].xyxx;
defined_weight += k[i].xy;
}
}
col /= defined_weight.xyxx;
- //col.y *= max(col.y, 0.75);
+ //col.y *= col.y;
frag_color = col;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 379ab55354..1ba139cd50 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8135,8 +8135,6 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f)
void LLPipeline::renderDeferredLighting()
{
-
-
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
LL_PROFILE_GPU_ZONE("renderDeferredLighting");
if (!sCull)
@@ -8145,31 +8143,12 @@ void LLPipeline::renderDeferredLighting()
}
LLRenderTarget *screen_target = &mRT->screen;
- //LLRenderTarget *deferred_target = &mRT->deferredScreen;
- //LLRenderTarget *deferred_depth_target = &mRT->deferredDepth;
LLRenderTarget* deferred_light_target = &mRT->deferredLight;
{
- LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED);
+ LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred");
LLViewerCamera *camera = LLViewerCamera::getInstance();
-#if 0
- {
- LLGLDepthTest depth(GL_TRUE);
- deferred_depth_target->copyContents(*deferred_target,
- 0,
- 0,
- deferred_target->getWidth(),
- deferred_target->getHeight(),
- 0,
- 0,
- deferred_depth_target->getWidth(),
- deferred_depth_target->getHeight(),
- GL_DEPTH_BUFFER_BIT,
- GL_NEAREST);
- }
-#endif
-
LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0);
if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
@@ -8177,11 +8156,6 @@ void LLPipeline::renderDeferredLighting()
gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
}
- // ati doesn't seem to love actually using the stencil buffer on FBO's
- //LLGLDisable stencil(GL_STENCIL_TEST);
- // glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
- // glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
-
gGL.setColorMask(true, true);
// draw a cube around every light
@@ -8251,76 +8225,64 @@ void LLPipeline::renderDeferredLighting()
if (RenderDeferredSSAO)
{
- /*if (gCubeSnapshot)
- { // SSAO and shadows disabled in reflection maps
- deferred_light_target->bindTarget();
- glClearColor(1, 1, 1, 1);
- deferred_light_target->clear();
- glClearColor(0, 0, 0, 0);
- deferred_light_target->flush();
- }
- else*/
- {
- // soften direct lighting lightmap
- LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow");
- LL_PROFILE_GPU_ZONE("soften shadow");
- // blur lightmap
- screen_target->bindTarget();
- glClearColor(1, 1, 1, 1);
- screen_target->clear(GL_COLOR_BUFFER_BIT);
- glClearColor(0, 0, 0, 0);
+ // soften direct lighting lightmap
+ LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow");
+ LL_PROFILE_GPU_ZONE("soften shadow");
+ // blur lightmap
+ screen_target->bindTarget();
+ glClearColor(1, 1, 1, 1);
+ screen_target->clear(GL_COLOR_BUFFER_BIT);
+ glClearColor(0, 0, 0, 0);
- bindDeferredShader(gDeferredBlurLightProgram);
- mScreenTriangleVB->setBuffer();
- LLVector3 go = RenderShadowGaussian;
- const U32 kern_length = 4;
- F32 blur_size = RenderShadowBlurSize;
- F32 dist_factor = RenderShadowBlurDistFactor;
+ bindDeferredShader(gDeferredBlurLightProgram);
- // sample symmetrically with the middle sample falling exactly on 0.0
- F32 x = 0.f;
+ LLVector3 go = RenderShadowGaussian;
+ const U32 kern_length = 4;
+ F32 blur_size = RenderShadowBlurSize;
+ F32 dist_factor = RenderShadowBlurDistFactor;
- LLVector3 gauss[32]; // xweight, yweight, offset
+ // sample symmetrically with the middle sample falling exactly on 0.0
+ F32 x = 0.f;
- F32 screenPixelSize = 1.f / screen_target->getWidth();
+ LLVector3 gauss[32]; // xweight, yweight, offset
- for (U32 i = 0; i < kern_length; i++)
- {
- gauss[i].mV[0] = llgaussian(x, go.mV[0]);
- gauss[i].mV[1] = llgaussian(x, go.mV[1]);
- gauss[i].mV[2] = x;
- x += screenPixelSize;
- }
+ for (U32 i = 0; i < kern_length; i++)
+ {
+ gauss[i].mV[0] = llgaussian(x, go.mV[0]);
+ gauss[i].mV[1] = llgaussian(x, go.mV[1]);
+ gauss[i].mV[2] = x;
+ x += 1.f;
+ }
- gDeferredBlurLightProgram.uniform2f(sDelta, screenPixelSize, 0.f);
- gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor);
- gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV);
- gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length / 2.f - 0.5f));
+ gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f);
+ gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor);
+ gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV);
+ gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length / 2.f - 0.5f));
- {
- LLGLDisable blend(GL_BLEND);
- LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
- }
+ {
+ LLGLDisable blend(GL_BLEND);
+ LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+ mScreenTriangleVB->setBuffer();
+ mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ }
- screen_target->flush();
- unbindDeferredShader(gDeferredBlurLightProgram);
+ screen_target->flush();
+ unbindDeferredShader(gDeferredBlurLightProgram);
- bindDeferredShader(gDeferredBlurLightProgram, screen_target);
+ bindDeferredShader(gDeferredBlurLightProgram, screen_target);
- mScreenTriangleVB->setBuffer();
- deferred_light_target->bindTarget();
+ deferred_light_target->bindTarget();
- gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f);
+ gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f);
- {
- LLGLDisable blend(GL_BLEND);
- LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
- mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
- }
- deferred_light_target->flush();
- unbindDeferredShader(gDeferredBlurLightProgram);
+ {
+ LLGLDisable blend(GL_BLEND);
+ LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+ mScreenTriangleVB->setBuffer();
+ mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
}
+ deferred_light_target->flush();
+ unbindDeferredShader(gDeferredBlurLightProgram);
}
screen_target->bindTarget();
@@ -8346,33 +8308,13 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable test(GL_ALPHA_TEST);
// full screen blit
-
mScreenTriangleVB->setBuffer();
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
-
}
unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram);
}
-#if 0
- { // render non-deferred geometry (fullbright, alpha, etc)
- LLGLDisable blend(GL_BLEND);
- //LLGLDisable stencil(GL_STENCIL_TEST);
- gGL.setSceneBlendType(LLRender::BT_ALPHA);
-
- gPipeline.pushRenderTypeMask();
-
- gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::RENDER_TYPE_WL_SKY,
- LLPipeline::END_RENDER_TYPES);
-
- renderGeomPostDeferred(*LLViewerCamera::getInstance(), false);
- gPipeline.popRenderTypeMask();
- }
-#endif
-
bool render_local = RenderLocalLights; // && !gCubeSnapshot;
if (render_local)