Commit 641d780b authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Run post deferred geometry in linear color space

parent a5901f51
......@@ -276,8 +276,6 @@ vec3 post_atmo = color.rgb;
#if !defined(LOCAL_LIGHT_KILL)
color.rgb += light.rgb;
#endif
// back to sRGB as we're going directly to the final RT post-deferred gamma correction
color.rgb = linear_to_srgb(color.rgb);
//color.rgb = amblit;
//color.rgb = vec3(ambient);
......@@ -291,7 +289,9 @@ vec3 post_atmo = color.rgb;
//color.rgb = post_atmo;
#ifdef WATER_FOG
color.rgb = linear_to_srgb(color.rgb);
color = applyWaterFogView(pos.xyz, color);
color.rgb = srgb_to_linear(color.rgb);
#endif // WATER_FOG
#endif
......
......@@ -39,15 +39,15 @@ vec3 fullbrightScaleSoftClip(vec3 light);
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
vec3 srgb_to_linear(vec3 cs);
void main()
{
float shadow = 1.0;
vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color;
color.rgb = fullbrightAtmosTransport(color.rgb);
color.rgb = fullbrightScaleSoftClip(color.rgb);
frag_color = color;
frag_color = vec4(srgb_to_linear(color.rgb), color.a);
}
......@@ -85,6 +85,8 @@ void main()
color.a = final_alpha;
#endif
color.rgb = srgb_to_linear(color.rgb);
frag_color.rgb = color.rgb;
frag_color.a = color.a;
}
......
......@@ -99,7 +99,7 @@ void main()
color.a = 1.0;
//color.rgb = linear_to_srgb(color.rgb);
color.rgb = srgb_to_linear(color.rgb);
frag_color = color;
}
......
......@@ -422,13 +422,13 @@ void main()
glare = min(glare, 1.0);
float al = max(diffcol.a, glare)*vertex_color.a;
#ifdef WATER_FOG
//convert to srgb as this color is being written post gamma correction
color = linear_to_srgb(color);
#ifdef WATER_FOG
vec4 temp = applyWaterFogView(pos, vec4(color, al));
color = temp.rgb;
al = temp.a;
color = srgb_to_linear(color);
#endif
frag_color = vec4(color, al);
......
......@@ -2284,6 +2284,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredEmissiveProgram.mFeatures.calculatesAtmospherics = true;
gDeferredEmissiveProgram.mFeatures.hasGamma = true;
gDeferredEmissiveProgram.mFeatures.hasTransport = true;
gDeferredEmissiveProgram.mFeatures.hasSrgb = true;
gDeferredEmissiveProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredEmissiveProgram.mShaderFiles.clear();
gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveV.glsl", GL_VERTEX_SHADER));
......
......@@ -9319,6 +9319,43 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target)
screen_target->flush();
screen_target->bindTarget();
{ // render non-deferred geometry (alpha, fullbright, glow)
LLGLDisable blend(GL_BLEND);
LLGLDisable stencil(GL_STENCIL_TEST);
pushRenderTypeMask();
andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA,
LLPipeline::RENDER_TYPE_FULLBRIGHT,
LLPipeline::RENDER_TYPE_VOLUME,
LLPipeline::RENDER_TYPE_GLOW,
LLPipeline::RENDER_TYPE_BUMP,
LLPipeline::RENDER_TYPE_PASS_SIMPLE,
LLPipeline::RENDER_TYPE_PASS_ALPHA,
LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
LLPipeline::RENDER_TYPE_PASS_BUMP,
LLPipeline::RENDER_TYPE_PASS_POST_BUMP,
LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
LLPipeline::RENDER_TYPE_PASS_GLOW,
LLPipeline::RENDER_TYPE_PASS_GRASS,
LLPipeline::RENDER_TYPE_PASS_SHINY,
LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
LLPipeline::RENDER_TYPE_AVATAR,
LLPipeline::RENDER_TYPE_CONTROL_AV,
LLPipeline::RENDER_TYPE_ALPHA_MASK,
LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK,
END_RENDER_TYPES);
renderGeomPostDeferred(camera);
popRenderTypeMask();
}
screen_target->flush();
// gamma correct lighting
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
......@@ -9336,9 +9373,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target)
screen_target->bindTarget();
// Apply gamma correction to the frame here.
gDeferredPostGammaCorrectProgram.bind();
// mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
S32 channel = 0;
channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage());
S32 channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage());
if (channel > -1)
{
screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT);
......@@ -9371,39 +9407,6 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target)
screen_target->bindTarget();
{ // render non-deferred geometry (alpha, fullbright, glow)
LLGLDisable blend(GL_BLEND);
LLGLDisable stencil(GL_STENCIL_TEST);
pushRenderTypeMask();
andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA,
LLPipeline::RENDER_TYPE_FULLBRIGHT,
LLPipeline::RENDER_TYPE_VOLUME,
LLPipeline::RENDER_TYPE_GLOW,
LLPipeline::RENDER_TYPE_BUMP,
LLPipeline::RENDER_TYPE_PASS_SIMPLE,
LLPipeline::RENDER_TYPE_PASS_ALPHA,
LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
LLPipeline::RENDER_TYPE_PASS_BUMP,
LLPipeline::RENDER_TYPE_PASS_POST_BUMP,
LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
LLPipeline::RENDER_TYPE_PASS_GLOW,
LLPipeline::RENDER_TYPE_PASS_GRASS,
LLPipeline::RENDER_TYPE_PASS_SHINY,
LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
LLPipeline::RENDER_TYPE_AVATAR,
LLPipeline::RENDER_TYPE_CONTROL_AV,
LLPipeline::RENDER_TYPE_ALPHA_MASK,
LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK,
END_RENDER_TYPES);
renderGeomPostDeferred(camera);
popRenderTypeMask();
}
{
// render highlights, etc.
renderHighlights();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment