… | |
… | |
84 | if (ctx.pass_data->l) |
84 | if (ctx.pass_data->l) |
85 | ctx.pass_data->l->vsh (); |
85 | ctx.pass_data->l->vsh (); |
86 | |
86 | |
87 | vsh (ctx); |
87 | vsh (ctx); |
88 | |
88 | |
|
|
89 | // compute logarithmic depth - see the frustum matrix in view.C |
89 | { |
90 | { |
90 | using namespace shader::compile; |
91 | using namespace shader::compile; |
91 | |
92 | |
92 | z (vout.position) = log2 (z (vout.position) / w (vout.position)) * w (vout.position); |
93 | z (vout.position) = (log2 (max (z (vout.position), 0)) * (2 / log2 (1e10)) - 1) * w (vout.position); |
93 | } |
94 | } |
94 | |
95 | |
95 | vsh_src = shader::shader_builder::stop (); |
96 | vsh_src = shader::shader_builder::stop (); |
96 | |
97 | |
97 | shader::shader_builder::start (); |
98 | shader::shader_builder::start (); |
… | |
… | |
103 | fsh (ctx); |
104 | fsh (ctx); |
104 | } |
105 | } |
105 | else |
106 | else |
106 | shader::compile::fout.frag_color = shader::compile::float4 (1., 0., 1., 1.); |
107 | shader::compile::fout.frag_color = shader::compile::float4 (1., 0., 1., 1.); |
107 | |
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 | |
108 | fsh_src = shader::shader_builder::stop (); |
116 | fsh_src = shader::shader_builder::stop (); |
109 | |
117 | |
110 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
118 | shader::program_object po = shader::get_program (vsh_src, fsh_src); |
111 | matmap.insert (pass::matmap_t::value_type (this, po)); |
119 | matmap.insert (pass::matmap_t::value_type (this, po)); |
112 | |
120 | |
113 | po->enable (); |
121 | po->enable (); |
114 | } |
122 | } |
115 | else |
123 | else |
116 | i->second->enable (); |
124 | i->second->enable (); |
|
|
125 | |
|
|
126 | if (ctx.pass_data->l) |
|
|
127 | ctx.pass_data->l->enable (); |
117 | } |
128 | } |
118 | |
129 | |
119 | void material::disable (view &ctx) |
130 | void material::disable (view &ctx) |
120 | { |
131 | { |
121 | } |
132 | } |