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