- // Find a texture for this phase.
- inform_input_sizes(phase);
- if (phase_num != phases.size() - 1) {
- find_output_size(phase);
-
- GLuint tex_num = resource_pool->create_2d_texture(GL_RGBA16F, phase->output_width, phase->output_height);
- output_textures.insert(make_pair(phase, tex_num));
- }
-
- const GLuint glsl_program_num = phase->glsl_program_num;
- check_error();
- glUseProgram(glsl_program_num);
- check_error();
-
- // Set up RTT inputs for this phase.
- for (unsigned sampler = 0; sampler < phase->inputs.size(); ++sampler) {
- glActiveTexture(GL_TEXTURE0 + sampler);
- Phase *input = phase->inputs[sampler];
- input->output_node->bound_sampler_num = sampler;
- glBindTexture(GL_TEXTURE_2D, output_textures[input]);
- check_error();
- if (phase->input_needs_mipmaps) {
- if (generated_mipmaps.count(input) == 0) {
- glGenerateMipmap(GL_TEXTURE_2D);
- check_error();
- generated_mipmaps.insert(input);
- }
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
- check_error();
- } else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- check_error();
- }
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- check_error();
-
- string texture_name = string("tex_") + phase->effect_ids[input->output_node];
- glUniform1i(glGetUniformLocation(glsl_program_num, texture_name.c_str()), sampler);
- check_error();
- }
-
- // And now the output.