… | |
… | |
69 | { |
69 | { |
70 | } |
70 | } |
71 | |
71 | |
72 | void material::enable (view &ctx) |
72 | void material::enable (view &ctx) |
73 | { |
73 | { |
|
|
74 | static shader::compile::varying_1f Z;//D |
|
|
75 | |
74 | pass::matmap_t &matmap = ctx.pass_data->matmap; |
76 | pass::matmap_t &matmap = ctx.pass_data->matmap; |
75 | |
77 | |
76 | pass::matmap_t::iterator i = matmap.find (this); |
78 | pass::matmap_t::iterator i = matmap.find (this); |
77 | |
79 | |
78 | if (i == matmap.end ()) |
80 | if (i == matmap.end ()) |
… | |
… | |
87 | vsh (ctx); |
89 | vsh (ctx); |
88 | |
90 | |
89 | { |
91 | { |
90 | using namespace shader::compile; |
92 | using namespace shader::compile; |
91 | |
93 | |
92 | //z (vout.position) = log2 (z (vout.position) / w (vout.position)) * w (vout.position); |
94 | Z = pow (z (vout.position) / 2.F, 0.2); |
|
|
95 | z (vout.position) = (Z * 2 - 1) * w (vout.position); |
|
|
96 | //z (vout.position) = z (vout.position) - 1; |
93 | } |
97 | } |
94 | |
98 | |
95 | vsh_src = shader::shader_builder::stop (); |
99 | vsh_src = shader::shader_builder::stop (); |
96 | |
100 | |
97 | shader::shader_builder::start (); |
101 | shader::shader_builder::start (); |
… | |
… | |
102 | |
106 | |
103 | fsh (ctx); |
107 | fsh (ctx); |
104 | } |
108 | } |
105 | else |
109 | else |
106 | shader::compile::fout.frag_color = shader::compile::float4 (1., 0., 1., 1.); |
110 | shader::compile::fout.frag_color = shader::compile::float4 (1., 0., 1., 1.); |
|
|
111 | |
|
|
112 | { |
|
|
113 | using namespace shader::compile; |
|
|
114 | //x (fout.frag_color) = Z;//D |
|
|
115 | //y (fout.frag_color) = Z;//D |
|
|
116 | //z (fout.frag_color) = Z;//D |
|
|
117 | } |
107 | |
118 | |
108 | fsh_src = shader::shader_builder::stop (); |
119 | fsh_src = shader::shader_builder::stop (); |
109 | |
120 | |
110 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
121 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
111 | matmap.insert (pass::matmap_t::value_type (this, po)); |
122 | matmap.insert (pass::matmap_t::value_type (this, po)); |