… | |
… | |
88 | |
88 | |
89 | // compute logarithmic depth - see the frustum matrix in view.C |
89 | // compute logarithmic depth - see the frustum matrix in view.C |
90 | { |
90 | { |
91 | using namespace shader::compile; |
91 | using namespace shader::compile; |
92 | |
92 | |
|
|
93 | temp_1f lz; |
|
|
94 | |
|
|
95 | // TODO: negative z is not calculated in an acceptable way |
|
|
96 | lz = z (vout.position); |
93 | z (vout.position) = (log2 (max (z (vout.position), 0)) * (2 / log2 (1e10)) - 1) * w (vout.position); |
97 | z (vout.position) = (log2 (lz) * (2 / log2 (1e10)) - 1) * w (vout.position); |
94 | } |
98 | } |
95 | |
99 | |
96 | vsh_src = shader::shader_builder::stop (); |
100 | vsh_src = shader::shader_builder::stop (); |
97 | |
101 | |
98 | shader::shader_builder::start (); |
102 | shader::shader_builder::start (); |
… | |
… | |
103 | |
107 | |
104 | fsh (ctx); |
108 | fsh (ctx); |
105 | } |
109 | } |
106 | else |
110 | else |
107 | shader::compile::fout.frag_color = shader::compile::float4 (1., 0., 1., 1.); |
111 | shader::compile::fout.frag_color = shader::compile::float4 (1., 0., 1., 1.); |
108 | |
|
|
109 | { |
|
|
110 | using namespace shader::compile; |
|
|
111 | //x (fout.frag_color) = Z;//D |
|
|
112 | //y (fout.frag_color) = Z;//D |
|
|
113 | //z (fout.frag_color) = Z;//D |
|
|
114 | } |
|
|
115 | |
112 | |
116 | fsh_src = shader::shader_builder::stop (); |
113 | fsh_src = shader::shader_builder::stop (); |
117 | |
114 | |
118 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
115 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
119 | matmap.insert (pass::matmap_t::value_type (this, po)); |
116 | matmap.insert (pass::matmap_t::value_type (this, po)); |