… | |
… | |
90 | { |
90 | { |
91 | using namespace shader::compile; |
91 | using namespace shader::compile; |
92 | |
92 | |
93 | temp_1f lz; |
93 | temp_1f lz; |
94 | |
94 | |
95 | // TODO: negative z is not calculated in an acceptable way |
95 | // TODO: negative z is not calculated in an acceptable way, clipping does horrible things(?) |
96 | lz = z (vout.position); |
96 | lz = z (vout.position); |
97 | z (vout.position) = (ifelse (lz < 0, lz, log (lz) * (2 / log (1e10))) - 1) * w (vout.position); |
97 | lz = ifelse (lz <= 0, |
|
|
98 | 0, |
|
|
99 | log (lz + 1) / log (1e18) |
|
|
100 | ) - 1; |
|
|
101 | z (vout.position) = lz * w (vout.position); |
98 | } |
102 | } |
99 | |
103 | |
100 | vsh_src = shader::shader_builder::stop (); |
104 | vsh_src = shader::shader_builder::stop (); |
101 | |
105 | |
102 | shader::shader_builder::start (); |
106 | shader::shader_builder::start (); |
103 | |
107 | |
104 | if (ctx.pass->l) |
108 | if (ctx.pass->l) |
105 | { |
109 | { |
106 | ctx.pass->l->fsh (); |
110 | ctx.pass->l->fsh (); |
107 | |
|
|
108 | fsh (ctx); |
111 | fsh (ctx); |
109 | } |
112 | } |
110 | else |
113 | else |
|
|
114 | // many drivers need both vertex and fragment shader, 'caboom!' otherwise |
111 | shader::compile::fout.frag_color = shader::compile::float4 (1., 0., 1., 1.); |
115 | shader::compile::fout.frag_color = shader::compile::float4 (0., 0., 0., 0.); |
112 | |
116 | |
113 | fsh_src = shader::shader_builder::stop (); |
117 | fsh_src = shader::shader_builder::stop (); |
114 | |
118 | |
115 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
119 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
116 | matmap.insert (pass_data::matmap_t::value_type (this, po)); |
120 | matmap.insert (pass_data::matmap_t::value_type (this, po)); |