void FinalPass::run(const GraphicContextPtr &gc, SceneImpl *scene) { ScopeTimeFunction(); //Texture2DPtr &log_average_light_texture = log_average_light.find_log_average_light(gc, lightsource_pass.final_color); inout.bloom_contribution->set_min_filter(filter_linear); inout.bloom_contribution->set_mag_filter(filter_linear); inout.ambient_occlusion->set_min_filter(filter_linear); inout.ambient_occlusion->set_mag_filter(filter_linear); inout.final_color->set_min_filter(filter_nearest); inout.final_color->set_mag_filter(filter_nearest); if (inout.fb_viewport) gc->set_frame_buffer(inout.fb_viewport); gc->set_viewport(inout.viewport, gc->texture_image_y_axis()); gc->set_texture(0, inout.final_color); gc->set_texture(2, inout.bloom_contribution); gc->set_texture(3, inout.ambient_occlusion); gc->set_program_object(present_shader); gc->set_rasterizer_state(rasterizer_state); gc->draw_primitives(type_triangles, 6, rect_primarray); gc->reset_program_object(); gc->reset_texture(0); gc->reset_texture(2); gc->reset_texture(3); gc->reset_frame_buffer(); }
void ZMinMax::minmax(const GraphicContextPtr &gc) { update_buffers(gc); normal_z->set_min_filter(filter_nearest); normal_z->set_mag_filter(filter_nearest); normal_z->set_wrap_mode(wrap_clamp_to_edge, wrap_clamp_to_edge); gc->set_primitives_array(prim_array); gc->set_program_object(program0); gc->set_blend_state(blend_state); Size texture_size = find_texture_size(normal_z); for (int i = 0; i < iterations; i++) { if (i == 1) gc->set_program_object(program1); int iteration_width = texture_size.width >> i; int iteration_height = texture_size.height >> i; gc->set_frame_buffer((i % 2 == 0) ? fb0 : fb1); gc->set_viewport(Size(iteration_width, iteration_height), gc->texture_image_y_axis()); if (i == 0) gc->set_texture(0, normal_z); else gc->set_texture(0, (i % 2 == 0) ? texture1 : texture0); gc->draw_primitives_array(type_triangles, 6); } gc->reset_texture(0); gc->reset_program_object(); gc->reset_primitives_array(); gc->reset_frame_buffer(); gc->set_viewport(viewport.size(), gc->texture_image_y_axis()); }