Anaglyph: Use matrices instead of vectors.

This commit is contained in:
Jules Blok 2015-01-02 13:35:53 +01:00
parent 491de39325
commit 26a9afa0e7
2 changed files with 18 additions and 22 deletions

View File

@ -73,17 +73,15 @@ const char anaglyph_program_code[] = {
"out float4 ocol0 : SV_Target,\n" "out float4 ocol0 : SV_Target,\n"
"in float4 pos : SV_Position,\n" "in float4 pos : SV_Position,\n"
"in float3 uv0 : TEXCOORD0){\n" "in float3 uv0 : TEXCOORD0){\n"
"float3 l = Tex0.Sample(samp0, float3(uv0.xy, 0.0)).rgb;\n" "float4 c0 = Tex0.Sample(samp0, float3(uv0.xy, 0.0));\n"
"float3 r = Tex0.Sample(samp0, float3(uv0.xy, 1.0)).rgb;\n" "float4 c1 = Tex0.Sample(samp0, float3(uv0.xy, 1.0));\n"
"float3 lr = float3(0.437,0.449,0.164);\n" "float3x3 l = float3x3( 0.437, 0.449, 0.164,\n"
"float3 lg = float3(-0.062,-0.062,-0.024);\n" " -0.062,-0.062,-0.024,\n"
"float3 lb = float3(-0.048,-0.050,-0.017);\n" " -0.048,-0.050,-0.017);\n"
"float3 rr = float3(-0.011,-0.032,-0.007);\n" "float3x3 r = float3x3(-0.011,-0.032,-0.007,\n"
"float3 rg = float3(0.377,0.761,0.009);\n" " 0.377, 0.761, 0.009,\n"
"float3 rb = float3(-0.026,-0.093,1.234);\n" " -0.026,-0.093, 1.234);\n"
"float3 c0 = float3(dot(l, lr), dot(l, lg), dot(l, lb));\n" "ocol0 = float4(mul(l, c0.rgb) + mul(r, c1.rgb), c0.a);\n"
"float3 c1 = float3(dot(r, rr), dot(r, rg), dot(r, rb));\n"
"ocol0 = float4(c0 + c1, 1.0);\n"
"}\n" "}\n"
}; };

View File

@ -43,17 +43,15 @@ static char s_vertex_shader[] =
// Eric Dubois, March 2009 // Eric Dubois, March 2009
static char s_anaglyph_shader[] = static char s_anaglyph_shader[] =
"void main() {\n" "void main() {\n"
" vec3 l = SampleLayer(0).rgb;\n" " vec4 c0 = SampleLayer(0);\n"
" vec3 r = SampleLayer(1).rgb;\n" " vec4 c1 = SampleLayer(1);\n"
" vec3 lr = vec3(0.437,0.449,0.164);\n" " mat3 l = mat3( 0.437, 0.449, 0.164,\n"
" vec3 lg = vec3(-0.062,-0.062,-0.024);\n" " -0.062,-0.062,-0.024,\n"
" vec3 lb = vec3(-0.048,-0.050,-0.017);\n" " -0.048,-0.050,-0.017);\n"
" vec3 rr = vec3(-0.011,-0.032,-0.007);\n" " mat3 r = mat3(-0.011,-0.032,-0.007,\n"
" vec3 rg = vec3(0.377,0.761,0.009);\n" " 0.377, 0.761, 0.009,\n"
" vec3 rb = vec3(-0.026,-0.093,1.234);\n" " -0.026,-0.093, 1.234);\n"
" vec3 c0 = vec3(dot(l, lr), dot(l, lg), dot(l, lb));\n" " SetOutput(vec4(c0.rgb * l + c1.rgb * r, c0.a));\n"
" vec3 c1 = vec3(dot(r, rr), dot(r, rg), dot(r, rb));\n"
" SetOutput(vec4(c0 + c1, SampleLayer(0).a));\n"
"}\n"; "}\n";
static const char s_default_shader[] = "void main() { SetOutput(Sample()); }\n"; static const char s_default_shader[] = "void main() { SetOutput(Sample()); }\n";