PostProcessing: Use Dubois algorithm for anaglyph shader.
This commit is contained in:
parent
ec4dfae333
commit
e3969f763e
|
@ -36,6 +36,28 @@ static char s_vertex_shader[] =
|
|||
" uv0 = rawpos * src_rect.zw + src_rect.xy;\n"
|
||||
"}\n";
|
||||
|
||||
// Anaglyph Red-Cyan shader based on Dubois algorithm
|
||||
// Constants taken from the paper:
|
||||
// "Conversion of a Stereo Pair to Anaglyph with
|
||||
// the Least-Squares Projection Method"
|
||||
// Eric Dubois, March 2009
|
||||
static char s_anaglyph_shader[] =
|
||||
"void main() {\n"
|
||||
" vec3 l = SampleLayer(0).rgb;\n"
|
||||
" vec3 r = SampleLayer(1).rgb;\n"
|
||||
" vec3 lr = vec3(0.437,0.449,0.164);\n"
|
||||
" vec3 lg = vec3(-0.062,-0.062,-0.024);\n"
|
||||
" vec3 lb = vec3(-0.048,-0.050,-0.017);\n"
|
||||
" vec3 rr = vec3(-0.011,-0.032,-0.007);\n"
|
||||
" vec3 rg = vec3(0.377,0.761,0.009);\n"
|
||||
" vec3 rb = vec3(-0.026,-0.093,1.234);\n"
|
||||
" vec3 c0 = vec3(dot(l, lr), dot(l, lg), dot(l, lb));\n"
|
||||
" vec3 c1 = vec3(dot(r, rr), dot(r, rg), dot(r, rb));\n"
|
||||
" SetOutput(vec4(c0 + c1, SampleLayer(0).a));\n"
|
||||
"}\n";
|
||||
|
||||
static const char s_default_shader[] = "void main() { SetOutput(Sample()); }\n";
|
||||
|
||||
OpenGLPostProcessing::OpenGLPostProcessing()
|
||||
: m_initialized(false)
|
||||
, m_anaglyph(false)
|
||||
|
@ -172,15 +194,13 @@ void OpenGLPostProcessing::ApplyShader()
|
|||
|
||||
// load shader code
|
||||
std::string code = "";
|
||||
std::string default_shader = "void main() { SetOutput(Sample()); }\n";
|
||||
|
||||
if (g_ActiveConfig.iStereoMode == STEREO_ANAGLYPH)
|
||||
code = "void main() { SetOutput(float4(pow(0.7 * SampleLayer(0).g + 0.3 * SampleLayer(0).b, 1.5), SampleLayer(1).gba)); }\n";
|
||||
code = s_anaglyph_shader;
|
||||
else if (g_ActiveConfig.sPostProcessingShader != "")
|
||||
code = m_config.LoadShader();
|
||||
|
||||
if (code == "")
|
||||
code = default_shader;
|
||||
code = s_default_shader;
|
||||
|
||||
code = LoadShaderOptions(code);
|
||||
|
||||
|
@ -194,7 +214,7 @@ void OpenGLPostProcessing::ApplyShader()
|
|||
{
|
||||
ERROR_LOG(VIDEO, "Failed to compile post-processing shader %s", m_config.GetShader().c_str());
|
||||
|
||||
code = LoadShaderOptions(default_shader);
|
||||
code = LoadShaderOptions(s_default_shader);
|
||||
ProgramShaderCache::CompileShader(m_shader, vertex_shader, code.c_str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue