Fix bloom in pathtraced mode
This commit is contained in:
Binary file not shown.
@@ -4,6 +4,7 @@ const constants: {
|
||||
screen_size_inv: float2;
|
||||
current_mip_level: int;
|
||||
sample_scale: float;
|
||||
bloom_strength: float;
|
||||
};
|
||||
|
||||
#[set(everything)]
|
||||
@@ -21,8 +22,6 @@ struct vert_out {
|
||||
tex: float2;
|
||||
}
|
||||
|
||||
const bloom_strength: float = 0.02;
|
||||
|
||||
fun bloom_upsample_pass_vert(input: vert_in): vert_out {
|
||||
var output: vert_out;
|
||||
output.tex = input.pos.xy * 0.5 + 0.5;
|
||||
@@ -52,7 +51,7 @@ fun bloom_upsample_pass_frag(input: vert_out): float4 {
|
||||
color.rgb = upsample_dual_filter(input.tex, constants.screen_size_inv);
|
||||
|
||||
if (constants.current_mip_level == 0) {
|
||||
color.rgb = color.rgb * float3(bloom_strength, bloom_strength, bloom_strength);
|
||||
color.rgb = color.rgb * float3(constants.bloom_strength, constants.bloom_strength, constants.bloom_strength);
|
||||
}
|
||||
|
||||
color.a = 1.0;
|
||||
|
||||
@@ -160,7 +160,7 @@ function render_path_base_commands(draw_commands: ()=>void) {
|
||||
render_path_base_end();
|
||||
}
|
||||
|
||||
function render_path_base_draw_bloom() {
|
||||
function render_path_base_draw_bloom(source: string, target: string) {
|
||||
if (config_raw.rp_bloom == false) {
|
||||
return;
|
||||
}
|
||||
@@ -193,13 +193,13 @@ function render_path_base_draw_bloom() {
|
||||
for (let i: i32 = 0; i < num_mips; ++i) {
|
||||
render_path_base_bloom_current_mip = i;
|
||||
render_path_set_target(render_path_base_bloom_mipmaps[i].name, null, null, clear_flag_t.COLOR, 0x00000000);
|
||||
render_path_bind_target(i == 0 ? "buf" : render_path_base_bloom_mipmaps[i - 1].name, "tex");
|
||||
render_path_bind_target(i == 0 ? source : render_path_base_bloom_mipmaps[i - 1].name, "tex");
|
||||
render_path_draw_shader("shader_datas/bloom_pass/bloom_downsample_pass");
|
||||
}
|
||||
for (let i: i32 = 0; i < num_mips; ++i) {
|
||||
let mip_level: i32 = num_mips - 1 - i;
|
||||
render_path_base_bloom_current_mip = mip_level;
|
||||
render_path_set_target(mip_level == 0 ? "buf" : render_path_base_bloom_mipmaps[mip_level - 1].name);
|
||||
render_path_set_target(mip_level == 0 ? target : render_path_base_bloom_mipmaps[mip_level - 1].name);
|
||||
render_path_bind_target(render_path_base_bloom_mipmaps[mip_level].name, "tex");
|
||||
render_path_draw_shader("shader_datas/bloom_pass/bloom_upsample_pass");
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ function render_path_deferred_commands() {
|
||||
function render_path_deferred_draw_deferred() {
|
||||
render_path_base_draw_ssao();
|
||||
render_path_base_draw_deferred_light();
|
||||
render_path_base_draw_bloom();
|
||||
render_path_base_draw_bloom("buf", "buf");
|
||||
// draw_histogram();
|
||||
|
||||
render_path_set_target("gbuffer1");
|
||||
|
||||
@@ -221,7 +221,6 @@ function render_path_raytrace_draw(use_live_layer: bool) {
|
||||
///end
|
||||
|
||||
render_path_raytrace_commands(use_live_layer);
|
||||
render_path_base_draw_bloom();
|
||||
render_path_set_target("buf");
|
||||
render_path_draw_meshes("overlay");
|
||||
render_path_set_target("buf");
|
||||
@@ -229,6 +228,7 @@ function render_path_raytrace_draw(use_live_layer: bool) {
|
||||
render_path_set_target("last");
|
||||
render_path_bind_target("buf", "tex");
|
||||
render_path_draw_shader("shader_datas/compositor_pass/compositor_pass");
|
||||
render_path_base_draw_bloom("buf", "last");
|
||||
render_path_set_target("");
|
||||
render_path_bind_target("last", "tex");
|
||||
render_path_draw_shader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
@@ -68,6 +68,9 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str
|
||||
else if (link == "_bloom_sample_scale") {
|
||||
return render_path_base_bloom_sample_scale;
|
||||
}
|
||||
else if (link == "_bloom_strength") {
|
||||
return context_raw.viewport_mode == viewport_mode_t.PATH_TRACE ? 0.2 : 0.02;
|
||||
}
|
||||
else if (link == "_brush_scale_x") {
|
||||
return 1 / context_raw.brush_scale_x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user