compositor effects/glow {
    technique {
        texture scene target_width target_height PF_A8R8G8B8
        texture glow_geometry target_width target_height PF_A8R8G8B8
        texture scene_combined target_width target_height PF_FLOAT16_RGB
        texture horizontal_pass_1 target_width_scaled 0.5 target_height_scaled 0.5 PF_FLOAT16_RGB
        texture horizontal_pass_2 target_width_scaled 0.25 target_height_scaled 0.25 PF_FLOAT16_RGB
        texture horizontal_pass_3 target_width_scaled 0.125 target_height_scaled 0.125 PF_FLOAT16_RGB
        texture horizontal_pass_4 target_width_scaled 0.0625 target_height_scaled 0.0625 PF_FLOAT16_RGB
        texture vertical_pass_1 target_width_scaled 0.5 target_height_scaled 0.5 PF_FLOAT16_RGB
        texture vertical_pass_2 target_width_scaled 0.25 target_height_scaled 0.25 PF_FLOAT16_RGB
        texture vertical_pass_3 target_width_scaled 0.125 target_height_scaled 0.125 PF_FLOAT16_RGB
        texture vertical_pass_4 target_width_scaled 0.0625 target_height_scaled 0.0625 PF_FLOAT16_RGB

        target scene
        { input previous }

        target glow_geometry {
            // must equal GLOWING_OBJECTS_MASK
            visibility_mask 2
            pass clear {
                clear
                { buffers colour }
            }
            pass render_scene {
                // must equal RENDER_QUEUE_MAIN
                first_render_queue 50
            }
        }

        target scene_combined {
            input none
            pass render_quad {
                material effects/glow/combine_scene_and_glow_geometry
                input 0 scene
                input 1 glow_geometry
            }
        }

        target horizontal_pass_1 {
            input none
            pass render_quad {
                material effects/glow/horizontal_pass_1
                input 0 scene_combined
            }
        }

        target vertical_pass_1 {
            input none
            pass render_quad {
                material effects/glow/vertical_pass_1
                input 0 horizontal_pass_1
            }
        }

        target horizontal_pass_2 {
            input none
            pass render_quad {
                material effects/glow/horizontal_pass_2
                input 0 vertical_pass_1
            }
        }

        target vertical_pass_2 {
            input none
            pass render_quad {
                material effects/glow/vertical_pass_2
                input 0 horizontal_pass_2
            }
        }

        target horizontal_pass_3 {
            input none
            pass render_quad {
                material effects/glow/horizontal_pass_3
                input 0 vertical_pass_2
            }
        }

        target vertical_pass_3 {
            input none
            pass render_quad {
                material effects/glow/vertical_pass_3
                input 0 horizontal_pass_3
            }
        }

        target horizontal_pass_4 {
            input none
            pass render_quad {
                material effects/glow/horizontal_pass_4
                input 0 vertical_pass_3
            }
        }

        target vertical_pass_4 {
            input none
            pass render_quad {
                material effects/glow/vertical_pass_4
                input 0 horizontal_pass_4
            }
        }

        // Re-using glow_geometry as a scratch buffer.
        target glow_geometry {
            input none
            pass render_quad {
                material effects/glow/combine_passes
                input 0 scene
                input 1 vertical_pass_1
                input 2 vertical_pass_2
                input 3 vertical_pass_3
                input 4 vertical_pass_4
            }
        }

        target_output {
            input none
            pass render_quad {
                material effects/glow/final_copy
                input 0 glow_geometry
            }
        }
    }
}
