nightshade-editor 0.13.4

An interactive editor for the Nightshade game engine
use nightshade::prelude::*;

pub fn configure_editor_render_graph(
    graph: &mut RenderGraph<World>,
    device: &wgpu::Device,
    surface_format: wgpu::TextureFormat,
    resources: RenderResources,
) {
    let bloom_width = resources.surface_width / 2;
    let bloom_height = resources.surface_height / 2;

    let bloom_texture = graph
        .add_color_texture("bloom")
        .format(wgpu::TextureFormat::Rgba16Float)
        .size(bloom_width, bloom_height)
        .clear_color(wgpu::Color::BLACK)
        .transient();

    let dof_texture = graph
        .add_color_texture("dof_output")
        .format(wgpu::TextureFormat::Rgba16Float)
        .size(resources.surface_width, resources.surface_height)
        .clear_color(wgpu::Color::BLACK)
        .transient();

    let bloom_pass =
        passes::BloomPass::new(device, resources.surface_width, resources.surface_height);
    graph
        .pass(Box::new(bloom_pass))
        .read("hdr", resources.scene_color)
        .write("bloom", bloom_texture);

    let dof_pass = passes::DepthOfFieldPass::new(
        device,
        wgpu::TextureFormat::Rgba16Float,
        resources.surface_width,
        resources.surface_height,
    );
    graph
        .pass(Box::new(dof_pass))
        .read("hdr", resources.scene_color)
        .read("depth", resources.depth)
        .write("dof_output", dof_texture);

    let ssao_pass = passes::SsaoPass::new(device);
    graph
        .pass(Box::new(ssao_pass))
        .read("depth", resources.depth)
        .read("view_normals", resources.view_normals)
        .write("ssao_raw", resources.ssao_raw);

    let ssao_blur_pass = passes::SsaoBlurPass::new(device);
    graph
        .pass(Box::new(ssao_blur_pass))
        .read("ssao_raw", resources.ssao_raw)
        .read("depth", resources.depth)
        .read("view_normals", resources.view_normals)
        .write("ssao", resources.ssao);

    let postprocess_pass = passes::PostProcessPass::new(device, surface_format, 0.3);
    graph
        .pass(Box::new(postprocess_pass))
        .read("hdr", dof_texture)
        .read("bloom", bloom_texture)
        .read("ssao", resources.ssao)
        .write("output", resources.compute_output);

    let swapchain_blit_pass =
        passes::BlitPass::new(device, surface_format).with_name("swapchain_blit_pass");
    graph
        .pass(Box::new(swapchain_blit_pass))
        .read("input", resources.compute_output)
        .write("output", resources.swapchain);
}