… | |
… | |
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 | lz = ifelse (lz <= 0, |
|
|
98 | lz, |
|
|
99 | log (lz + 1) / log (1e10 + 1) |
|
|
100 | ) - 1; |
97 | z (vout.position) = (log2 (lz) * (2 / log2 (1e10)) - 1) * w (vout.position); |
101 | z (vout.position) = lz * w (vout.position); |
98 | #if 0 |
|
|
99 | z (vout.position) = |
|
|
100 | ifelse ( |
|
|
101 | z < 0, |
|
|
102 | -1, |
|
|
103 | log2 (lz) * (2 / log2 (1e10)) - 1 |
|
|
104 | ) * w (vout.position); |
|
|
105 | #endif |
|
|
106 | } |
102 | } |
107 | |
103 | |
108 | vsh_src = shader::shader_builder::stop (); |
104 | vsh_src = shader::shader_builder::stop (); |
109 | |
105 | |
110 | shader::shader_builder::start (); |
106 | shader::shader_builder::start (); |
111 | |
107 | |
112 | if (ctx.pass->l) |
108 | if (ctx.pass->l) |
113 | { |
109 | { |
114 | ctx.pass->l->fsh (); |
110 | ctx.pass->l->fsh (); |
115 | |
|
|
116 | fsh (ctx); |
111 | fsh (ctx); |
117 | } |
112 | } |
118 | else |
113 | else |
|
|
114 | // many drivers need both vertex and fragment shader, 'caboom!' otherwise |
119 | 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.); |
120 | |
116 | |
121 | fsh_src = shader::shader_builder::stop (); |
117 | fsh_src = shader::shader_builder::stop (); |
122 | |
118 | |
123 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
119 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
124 | matmap.insert (pass_data::matmap_t::value_type (this, po)); |
120 | matmap.insert (pass_data::matmap_t::value_type (this, po)); |