From 4ceef5e3d0bcbfbc49daa80292e0aa8ab0216a62 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Tue, 28 Nov 2023 15:58:35 +0300 Subject: [PATCH] Made DoF a bit closer to AFT's realisation --- src/CRE/auth_3d.cpp | 4 +- src/CRE/post_process.cpp | 5 +- src/CRE/post_process/dof.cpp | 152 ++++++++++--------- src/CRE/post_process/dof.hpp | 23 ++- src/CRE/pv_param.cpp | 6 +- src/ReDIVA/classes/graphics/post_process.cpp | 34 ++--- src/ReDIVA/pv_game/pv_game.cpp | 2 +- src/ReDIVA/x_pv_game.cpp | 4 +- 8 files changed, 121 insertions(+), 109 deletions(-) diff --git a/src/CRE/auth_3d.cpp b/src/CRE/auth_3d.cpp index 6f8e0ad9..6654096c 100644 --- a/src/CRE/auth_3d.cpp +++ b/src/CRE/auth_3d.cpp @@ -4246,7 +4246,7 @@ static void auth_3d_dof_restore_prev_value(auth_3d_dof* d, render_context* rctx) if (!d->has_dof) return; - rctx->post_process.dof->set_dof_pv(); + dof_pv_set(0); } static void auth_3d_dof_set(auth_3d_dof* d, render_context* rctx) { @@ -4264,7 +4264,7 @@ static void auth_3d_dof_set(auth_3d_dof* d, render_context* rctx) { pv.f2.focus_range = d->model_transform.scale_value.x; pv.f2.fuzzing_range = d->model_transform.rotation_value.x; pv.f2.ratio = d->model_transform.rotation_value.y; - rctx->post_process.dof->set_dof_pv(&pv); + dof_pv_set(&pv); } static void auth_3d_dof_store(auth_3d* auth, auth_3d_dof* d, auth_3d_dof_file* df) { diff --git a/src/CRE/post_process.cpp b/src/CRE/post_process.cpp index 3177d5cb..0fa97eed 100644 --- a/src/CRE/post_process.cpp +++ b/src/CRE/post_process.cpp @@ -167,7 +167,7 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param for (int32_t i = 0; i < 8; i++) gl_state_bind_sampler(i, 0); - dof->apply(&rend_texture, &buf_texture, samplers, cam); + dof->apply(&rend_texture, &buf_texture, cam); draw_lens_ghost(&rend_texture); @@ -815,7 +815,8 @@ void post_process::render_texture_free(texture* render_texture, bool task_photo) void post_process::reset() { mlaa = true; mag_filter = POST_PROCESS_MAG_FILTER_BILINEAR; - dof->initialize_data(0, 0); + dof_debug_set(0); + dof_pv_set(0); blur->initialize_data(2.0f, 1.0f); for (int32_t i = 0; i < 2; i++) { diff --git a/src/CRE/post_process/dof.cpp b/src/CRE/post_process/dof.cpp index 93ff96f3..d0ec23b7 100644 --- a/src/CRE/post_process/dof.cpp +++ b/src/CRE/post_process/dof.cpp @@ -43,21 +43,21 @@ static const dof_pv dof_pv_default = { namespace renderer { struct DOF3 { static void apply_f2(post_process_dof* dof, RenderTexture* rt, - RenderTexture* buf, GLuint* samplers, GLuint color_texture, + RenderTexture* buf, GLuint color_texture, GLuint depth_texture, float_t min_distance, float_t max_distance, float_t fov, float_t focus, float_t focus_range, float_t fuzzing_range, float_t ratio); static void apply_physical(post_process_dof* dof, RenderTexture* rt, - RenderTexture* buf, GLuint* samplers, GLuint color_texture, + RenderTexture* buf, GLuint color_texture, GLuint depth_texture, float_t min_distance, float_t max_distance, float_t focus, float_t focal_length, float_t fov, float_t f_number); static void render_tiles(post_process_dof* dof, - GLuint* samplers, GLuint depth_texture, bool f2); + GLuint depth_texture, bool f2); static void downsample(post_process_dof* dof, - GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2); - static void main_filter(post_process_dof* dof, GLuint* samplers, bool f2); + GLuint color_texture, GLuint depth_texture, bool f2); + static void main_filter(post_process_dof* dof, bool f2); static void upsample(post_process_dof* dof, RenderTexture* rt, RenderTexture* buf, - GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2); + GLuint color_texture, GLuint depth_texture, bool f2); static void update_data(post_process_dof* dof, float_t min_dist, float_t max_dist, float_t fov, float_t dist, float_t focal_length, @@ -68,8 +68,11 @@ namespace renderer { static void post_process_dof_calculate_texcoords(vec2* data, float_t size); static void post_process_dof_free_fbo(post_process_dof* dof); -post_process_dof::post_process_dof() : data(), width(), -height(), textures(), fbo(), vao(), texcoords_ubo() { +dof_debug dof_debug_data; +dof_pv dof_pv_data; + +post_process_dof::post_process_dof() : width(), height(), +textures(), fbo(), samplers(), vao(), texcoords_ubo() { } @@ -80,16 +83,16 @@ post_process_dof::~post_process_dof() { post_process_dof_free_fbo(this); } -void post_process_dof::apply(RenderTexture* rt, RenderTexture* buf, GLuint* samplers, camera* cam) { +void post_process_dof::apply(RenderTexture* rt, RenderTexture* buf, camera* cam) { if (!this) return; bool use_dof_f2 = false; - if (data.debug.flags & DOF_DEBUG_USE_UI_PARAMS) { - if (data.debug.flags & DOF_DEBUG_ENABLE_DOF) { - if (data.debug.flags & DOF_DEBUG_ENABLE_PHYS_DOF) { - float_t focus = data.debug.focus; - if (data.debug.flags & DOF_DEBUG_AUTO_FOCUS) { + if (dof_debug_data.flags & DOF_DEBUG_USE_UI_PARAMS) { + if (dof_debug_data.flags & DOF_DEBUG_ENABLE_DOF) { + if (dof_debug_data.flags & DOF_DEBUG_ENABLE_PHYS_DOF) { + float_t focus = dof_debug_data.focus; + if (dof_debug_data.flags & DOF_DEBUG_AUTO_FOCUS) { rob_chara* rob_chr = 0; for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) { rob_chara* rob_chr = rob_chara_array_get(i); @@ -111,33 +114,35 @@ void post_process_dof::apply(RenderTexture* rt, RenderTexture* buf, GLuint* samp } focus = max_def(focus, (float_t)cam->min_distance); - renderer::DOF3::apply_physical(this, rt, buf, samplers, + renderer::DOF3::apply_physical(this, rt, buf, rt->color_texture->tex, rt->depth_texture->tex, (float_t)cam->min_distance, (float_t)cam->max_distance, focus, - data.debug.focal_length, (float_t)cam->fov_rad, data.debug.f_number); + dof_debug_data.focal_length, (float_t)cam->fov_rad, dof_debug_data.f_number); } else { - float_t fuzzing_range = max_def(data.debug.f2.fuzzing_range, 0.01f); - renderer::DOF3::apply_f2(this, rt, buf, samplers, + float_t fuzzing_range = max_def(dof_debug_data.f2.fuzzing_range, 0.01f); + renderer::DOF3::apply_f2(this, rt, buf, rt->color_texture->tex, rt->depth_texture->tex, (float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad, - data.debug.f2.focus, data.debug.f2.focus_range, fuzzing_range, data.debug.f2.ratio); + dof_debug_data.f2.focus, dof_debug_data.f2.focus_range, + fuzzing_range, dof_debug_data.f2.ratio); use_dof_f2 = true; } } } - else if (data.pv.enable && data.pv.f2.ratio > 0.0f) { - float_t fuzzing_range = max_def(data.pv.f2.fuzzing_range, 0.01f); - renderer::DOF3::apply_f2(this, rt, buf, samplers, + else if (dof_pv_data.enable && dof_pv_data.f2.ratio > 0.0f) { + float_t fuzzing_range = max_def(dof_pv_data.f2.fuzzing_range, 0.01f); + renderer::DOF3::apply_f2(this, rt, buf, rt->color_texture->tex, rt->depth_texture->tex, (float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad, - data.pv.f2.focus, data.pv.f2.focus_range, fuzzing_range, data.pv.f2.ratio); - enum_or(data.debug.flags, DOF_DEBUG_ENABLE_DOF); - data.debug.f2 = data.pv.f2; + dof_pv_data.f2.focus, dof_pv_data.f2.focus_range, + fuzzing_range, dof_pv_data.f2.ratio); + enum_or(dof_debug_data.flags, DOF_DEBUG_ENABLE_DOF); + dof_debug_data.f2 = dof_pv_data.f2; use_dof_f2 = true; } else - enum_and(data.debug.flags, ~DOF_DEBUG_ENABLE_DOF); + enum_and(dof_debug_data.flags, ~DOF_DEBUG_ENABLE_DOF); } void post_process_dof::init_fbo(int32_t width, int32_t height) { @@ -175,36 +180,41 @@ void post_process_dof::init_fbo(int32_t width, int32_t height) { common_ubo.Create(sizeof(dof_common_shader_data)); texcoords_ubo.Create(sizeof(data), data); + glGenSamplers(2, samplers); + glSamplerParameteri(samplers[0], GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glSamplerParameteri(samplers[0], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glSamplerParameteri(samplers[0], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(samplers[0], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(samplers[1], GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glSamplerParameteri(samplers[1], GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); + glSamplerParameteri(samplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(samplers[1], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glGenVertexArrays(1, &vao); } -void post_process_dof::initialize_data(dof_debug* debug, dof_pv* pv) { - set_dof_debug(debug); - set_dof_pv(pv); -} - -void post_process_dof::get_dof_debug(dof_debug* debug) { +void dof_debug_get(dof_debug* debug) { if (debug) - *debug = data.debug; + *debug = dof_debug_data; } -void post_process_dof::set_dof_debug(dof_debug* debug) { +void dof_debug_set(dof_debug* debug) { if (debug) - data.debug = *debug; + dof_debug_data = *debug; else - data.debug = dof_debug_default; + dof_debug_data = dof_debug_default; } -void post_process_dof::get_dof_pv(dof_pv* pv) { +void dof_pv_get(dof_pv* pv) { if (pv) - *pv = data.pv; + *pv = dof_pv_data; } -void post_process_dof::set_dof_pv(dof_pv* pv) { +void dof_pv_set(dof_pv* pv) { if (pv) - data.pv = *pv; + dof_pv_data = *pv; else - data.pv = dof_pv_default; + dof_pv_data = dof_pv_default; } static void post_process_dof_calculate_texcoords(vec2* data, float_t size) { @@ -258,6 +268,11 @@ static void post_process_dof_free_fbo(post_process_dof* dof) { dof->vao = 0; } + if (dof->samplers[0]) { + glDeleteSamplers(2, dof->samplers); + dof->samplers[0] = 0; + } + dof->texcoords_ubo.Destroy(); dof->common_ubo.Destroy(); @@ -269,7 +284,7 @@ static void post_process_dof_free_fbo(post_process_dof* dof) { namespace renderer { void DOF3::apply_f2(post_process_dof* dof, RenderTexture* rt, - RenderTexture* buf, GLuint* samplers, GLuint color_texture, + RenderTexture* buf, GLuint color_texture, GLuint depth_texture, float_t min_distance, float_t max_distance, float_t fov, float_t focus, float_t focus_range, float_t fuzzing_range, float_t ratio) { gl_state_begin_event("renderer::DOF3::apply_f2"); @@ -282,10 +297,10 @@ namespace renderer { uniform_value[U_DOF] = 1; gl_state_bind_vertex_array(dof->vao); - render_tiles(dof, samplers, depth_texture, true); - downsample(dof, samplers, color_texture, depth_texture, true); - main_filter(dof, samplers, true); - upsample(dof, rt, buf, samplers, color_texture, depth_texture, true); + render_tiles(dof, depth_texture, true); + downsample(dof, color_texture, depth_texture, true); + main_filter(dof, true); + upsample(dof, rt, buf, color_texture, depth_texture, true); shader::unbind(); for (int32_t i = 0; i < 8; i++) { @@ -297,7 +312,7 @@ namespace renderer { } void DOF3::apply_physical(post_process_dof* dof, RenderTexture* rt, - RenderTexture* buf, GLuint* samplers, GLuint color_texture, + RenderTexture* buf, GLuint color_texture, GLuint depth_texture, float_t min_distance, float_t max_distance, float_t focus, float_t focal_length, float_t fov, float_t f_number) { gl_state_begin_event("renderer::DOF3::apply_physical"); @@ -310,10 +325,10 @@ namespace renderer { uniform_value[U_DOF] = 0; gl_state_bind_vertex_array(dof->vao); - render_tiles(dof, samplers, depth_texture, false); - downsample(dof, samplers, color_texture, depth_texture, false); - main_filter(dof, samplers, false); - upsample(dof, rt, buf, samplers, color_texture, depth_texture, false); + render_tiles(dof, depth_texture, false); + downsample(dof, color_texture, depth_texture, false); + main_filter(dof, false); + upsample(dof, rt, buf, color_texture, depth_texture, false); shader::unbind(); for (int32_t i = 0; i < 8; i++) { @@ -324,8 +339,7 @@ namespace renderer { gl_state_end_event(); } - void DOF3::render_tiles(post_process_dof* dof, - GLuint* samplers, GLuint depth_texture, bool f2) { + void DOF3::render_tiles(post_process_dof* dof, GLuint depth_texture, bool f2) { gl_state_begin_event("renderer::DOF3::render_tiles"); gl_state_bind_framebuffer(dof->fbo[0].buffer); glViewport(0, 0, dof->fbo[0].width, dof->fbo[0].height); @@ -333,7 +347,7 @@ namespace renderer { shaders_ft.set(SHADER_FT_DOF); dof->common_ubo.Bind(0); gl_state_active_bind_texture_2d(0, depth_texture); - gl_state_bind_sampler(0, samplers[1]); + gl_state_bind_sampler(0, dof->samplers[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_state_bind_framebuffer(dof->fbo[1].buffer); @@ -341,14 +355,14 @@ namespace renderer { uniform_value[U_DOF_STAGE] = 1; shaders_ft.set(SHADER_FT_DOF); gl_state_active_bind_texture_2d(0, dof->textures[0]); - gl_state_bind_sampler(0, samplers[1]); + gl_state_bind_sampler(0, dof->samplers[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_state_end_event(); } void DOF3::downsample(post_process_dof* dof, - GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2) { + GLuint color_texture, GLuint depth_texture, bool f2) { gl_state_begin_event("renderer::DOF3::downsample"); gl_state_bind_framebuffer(dof->fbo[2].buffer); glViewport(0, 0, dof->fbo[2].width, dof->fbo[2].height); @@ -356,16 +370,16 @@ namespace renderer { shaders_ft.set(SHADER_FT_DOF); dof->common_ubo.Bind(0); gl_state_active_bind_texture_2d(0, depth_texture); - gl_state_bind_sampler(0, samplers[1]); + gl_state_bind_sampler(0, dof->samplers[1]); gl_state_active_bind_texture_2d(1, color_texture); - gl_state_bind_sampler(1, samplers[0]); + gl_state_bind_sampler(1, dof->samplers[0]); gl_state_active_bind_texture_2d(2, dof->textures[1]); - gl_state_bind_sampler(2, samplers[1]); + gl_state_bind_sampler(2, dof->samplers[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_state_end_event(); } - void DOF3::main_filter(post_process_dof* dof, GLuint* samplers, bool f2) { + void DOF3::main_filter(post_process_dof* dof, bool f2) { gl_state_begin_event("renderer::DOF3::main_filter"); gl_state_bind_framebuffer(dof->fbo[3].buffer); glViewport(0, 0, dof->fbo[3].width, dof->fbo[3].height); @@ -374,17 +388,17 @@ namespace renderer { dof->common_ubo.Bind(0); dof->texcoords_ubo.Bind(1); gl_state_active_bind_texture_2d(0, dof->textures[3]); - gl_state_bind_sampler(0, samplers[1]); + gl_state_bind_sampler(0, dof->samplers[1]); gl_state_active_bind_texture_2d(1, dof->textures[2]); - gl_state_bind_sampler(1, samplers[1]); + gl_state_bind_sampler(1, dof->samplers[1]); gl_state_active_bind_texture_2d(2, dof->textures[1]); - gl_state_bind_sampler(2, samplers[1]); + gl_state_bind_sampler(2, dof->samplers[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl_state_end_event(); } void DOF3::upsample(post_process_dof* dof, RenderTexture* rt, RenderTexture* buf, - GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2) { + GLuint color_texture, GLuint depth_texture, bool f2) { gl_state_begin_event("renderer::DOF3::upsample"); buf->Bind(); glViewport(0, 0, dof->width, dof->height); @@ -392,15 +406,15 @@ namespace renderer { shaders_ft.set(SHADER_FT_DOF); dof->common_ubo.Bind(0); gl_state_active_bind_texture_2d(0, dof->textures[4]); - gl_state_bind_sampler(0, samplers[1]); + gl_state_bind_sampler(0, dof->samplers[1]); gl_state_active_bind_texture_2d(1, dof->textures[5]); - gl_state_bind_sampler(1, samplers[1]); + gl_state_bind_sampler(1, dof->samplers[1]); gl_state_active_bind_texture_2d(2, dof->textures[1]); - gl_state_bind_sampler(2, samplers[1]); + gl_state_bind_sampler(2, dof->samplers[1]); gl_state_active_bind_texture_2d(3, color_texture); - gl_state_bind_sampler(3, samplers[1]); + gl_state_bind_sampler(3, dof->samplers[1]); gl_state_active_bind_texture_2d(4, depth_texture); - gl_state_bind_sampler(4, samplers[1]); + gl_state_bind_sampler(4, dof->samplers[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); fbo::blit(buf->fbos[0], rt->fbos[0], diff --git a/src/CRE/post_process/dof.hpp b/src/CRE/post_process/dof.hpp index 7cc697c7..6f06ed2b 100644 --- a/src/CRE/post_process/dof.hpp +++ b/src/CRE/post_process/dof.hpp @@ -40,17 +40,12 @@ struct dof_pv { dof_f2 f2; }; -struct post_process_dof_data { - dof_debug debug; - dof_pv pv; -}; - struct post_process_dof { - post_process_dof_data data; int32_t width; int32_t height; GLuint textures[6]; fbo fbo[4]; + GLuint samplers[2]; GLuint vao; GL::UniformBuffer common_ubo; GL::UniformBuffer texcoords_ubo; @@ -58,12 +53,14 @@ struct post_process_dof { post_process_dof(); ~post_process_dof(); - void apply(RenderTexture* rt, RenderTexture* buf, GLuint* samplers, camera* cam); + void apply(RenderTexture* rt, RenderTexture* buf, camera* cam); void init_fbo(int32_t width, int32_t height); - void initialize_data(dof_debug* debug, dof_pv* pv); - - void get_dof_debug(dof_debug* debug); - void set_dof_debug(dof_debug* debug = 0); - void get_dof_pv(dof_pv* pv); - void set_dof_pv(dof_pv* pv = 0); }; + +extern dof_debug dof_debug_data; +extern dof_pv dof_pv_data; + +extern void dof_debug_get(dof_debug* debug); +extern void dof_debug_set(dof_debug* debug = 0); +extern void dof_pv_get(dof_pv* pv); +extern void dof_pv_set(dof_pv* pv = 0); diff --git a/src/CRE/pv_param.cpp b/src/CRE/pv_param.cpp index f9c88682..fd904870 100644 --- a/src/CRE/pv_param.cpp +++ b/src/CRE/pv_param.cpp @@ -1227,12 +1227,12 @@ namespace pv_param_task { post_process_dof* dof = rctx_ptr->post_process.dof; dof_pv pv; - dof->get_dof_pv(&pv); + dof_pv_get(&pv); pv.f2.focus = focus; pv.f2.focus_range = focus_range; pv.f2.fuzzing_range = fuzzing_range; pv.f2.ratio = ratio; - dof->set_dof_pv(&pv); + dof_pv_set(&pv); frame += get_delta_frame(); if (frame > duration) { @@ -1249,7 +1249,7 @@ namespace pv_param_task { if (fabsf(duration) > 0.000001f) { dof_pv pv; - rctx_ptr->post_process.dof->get_dof_pv(&pv); + dof_pv_get(&pv); data.data_prev.focus = pv.f2.focus; data.data_prev.focus_range = pv.f2.focus_range; data.data_prev.fuzzing_range = pv.f2.fuzzing_range; diff --git a/src/ReDIVA/classes/graphics/post_process.cpp b/src/ReDIVA/classes/graphics/post_process.cpp index d46799d5..2d008274 100644 --- a/src/ReDIVA/classes/graphics/post_process.cpp +++ b/src/ReDIVA/classes/graphics/post_process.cpp @@ -151,23 +151,23 @@ void graphics_post_process_imgui(class_data* data) { ImGui::SetDefaultColumnSpace(); if (ImGui::TreeNodeEx("DOF", ImGuiTreeNodeFlags_DefaultOpen)) { - bool use_ui_params = dof->data.debug.flags & DOF_DEBUG_USE_UI_PARAMS; - bool phys = use_ui_params && dof->data.debug.flags & DOF_DEBUG_ENABLE_PHYS_DOF; - bool f2 = use_ui_params && ~dof->data.debug.flags & DOF_DEBUG_ENABLE_PHYS_DOF; + bool use_ui_params = dof_debug_data.flags & DOF_DEBUG_USE_UI_PARAMS; + bool phys = use_ui_params && dof_debug_data.flags & DOF_DEBUG_ENABLE_PHYS_DOF; + bool f2 = use_ui_params && ~dof_debug_data.flags & DOF_DEBUG_ENABLE_PHYS_DOF; float_t alpha = style.Alpha * ImGui::AlphaDisabledScale; ImGui::CheckboxFlagsEnterKeyPressed("use UI params", - (uint32_t*)&dof->data.debug.flags, DOF_DEBUG_USE_UI_PARAMS); + (uint32_t*)&dof_debug_data.flags, DOF_DEBUG_USE_UI_PARAMS); if (!use_ui_params) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); } ImGui::CheckboxFlagsEnterKeyPressed("enable DOF", - (uint32_t*)&dof->data.debug.flags, DOF_DEBUG_ENABLE_DOF); + (uint32_t*)&dof_debug_data.flags, DOF_DEBUG_ENABLE_DOF); ImGui::CheckboxFlagsEnterKeyPressed("enable physical DOF", - (uint32_t*)&dof->data.debug.flags, DOF_DEBUG_ENABLE_PHYS_DOF); + (uint32_t*)&dof_debug_data.flags, DOF_DEBUG_ENABLE_PHYS_DOF); if (!use_ui_params) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); @@ -178,7 +178,7 @@ void graphics_post_process_imgui(class_data* data) { ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); } ImGui::CheckboxFlagsEnterKeyPressed("auto focus", - (uint32_t*)&dof->data.debug.flags, DOF_DEBUG_AUTO_FOCUS); + (uint32_t*)&dof_debug_data.flags, DOF_DEBUG_AUTO_FOCUS); if (!phys) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); @@ -190,15 +190,15 @@ void graphics_post_process_imgui(class_data* data) { ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); } ImGui::ColumnSliderFloatButton("distance to focus[m]", - &dof->data.debug.focus, 0.01f, 0.01f, 30.0f, 1.0f, "%.2f", 0); + &dof_debug_data.focus, 0.01f, 0.01f, 30.0f, 1.0f, "%.2f", 0); - float_t focal_length = dof->data.debug.focal_length * 1000.0f; + float_t focal_length = dof_debug_data.focal_length * 1000.0f; ImGui::ColumnSliderFloatButton("focal length[mm]", &focal_length, 0.01f, 0.1f, 100.0f, 1.0f, "%.2f", 0); - dof->data.debug.focal_length = focal_length / 1000.0f; + dof_debug_data.focal_length = focal_length / 1000.0f; ImGui::ColumnSliderFloatButton("F-Number", - &dof->data.debug.f_number, 0.01f, 0.1f, 40.0f, 1.0f, "%.2f", 0); + &dof_debug_data.f_number, 0.01f, 0.1f, 40.0f, 1.0f, "%.2f", 0); if (!phys) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); @@ -209,13 +209,13 @@ void graphics_post_process_imgui(class_data* data) { ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); } ImGui::ColumnSliderFloatButton("f2 distance to focus[m]", - &dof->data.debug.f2.focus, 0.01f, 0.01f, 30.0f, 1.0f, "%.2f", 0); + &dof_debug_data.f2.focus, 0.01f, 0.01f, 30.0f, 1.0f, "%.2f", 0); ImGui::ColumnSliderFloatButton("f2 focus range[m]", - &dof->data.debug.f2.focus_range, 0.01f, 0.0f, 10.0f, 1.0f, "%.2f", 0); + &dof_debug_data.f2.focus_range, 0.01f, 0.0f, 10.0f, 1.0f, "%.2f", 0); ImGui::ColumnSliderFloatButton("f2 fuzzing range[m]", - &dof->data.debug.f2.fuzzing_range, 0.01f, 0.0f, 10.0f, 1.0f, "%.2f", 0); + &dof_debug_data.f2.fuzzing_range, 0.01f, 0.0f, 10.0f, 1.0f, "%.2f", 0); ImGui::ColumnSliderFloatButton("f2 ratio", - &dof->data.debug.f2.ratio, 0.01f, 0.0f, 1.0f, 1.0f, "%.2f", 0); + &dof_debug_data.f2.ratio, 0.01f, 0.0f, 1.0f, 1.0f, "%.2f", 0); if (!f2) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); @@ -227,8 +227,8 @@ void graphics_post_process_imgui(class_data* data) { if (ImGui::ButtonEnterKeyPressed("Reset Post Process", { 0, 0 })) { stage* stg = task_stage_get_current_stage(); light_param_data_storage_data_set_stage(stg->index); - dof->set_dof_debug(); - dof->set_dof_pv(); + dof_debug_set(); + dof_pv_set(); } data->imgui_focus |= ImGui::IsWindowFocused(); diff --git a/src/ReDIVA/pv_game/pv_game.cpp b/src/ReDIVA/pv_game/pv_game.cpp index ac1a470a..34a1098f 100644 --- a/src/ReDIVA/pv_game/pv_game.cpp +++ b/src/ReDIVA/pv_game/pv_game.cpp @@ -4674,7 +4674,7 @@ bool pv_game::unload() { post_process& pp = rctx_ptr->post_process; pp.tone_map->reset_saturate_coeff(0, true); - pp.dof->set_dof_pv(); + dof_pv_set(); pp.tone_map->reset_scene_fade(0); /*if (!sub_140192E20()) diff --git a/src/ReDIVA/x_pv_game.cpp b/src/ReDIVA/x_pv_game.cpp index f102b6ee..ce334e34 100644 --- a/src/ReDIVA/x_pv_game.cpp +++ b/src/ReDIVA/x_pv_game.cpp @@ -2967,7 +2967,7 @@ bool x_pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, int32_t id = data[1]; float_t duration = (float_t)data[2]; - rctx_ptr->post_process.dof->data.pv.enable = enable == 1; + dof_pv_data.enable = enable == 1; if (enable == 1) pv_param_task::post_process_task_set_dof_data( pv_param::post_process_data_get_dof_data(id), duration); @@ -6632,7 +6632,7 @@ bool x_pv_game::Dest() { light_param_data_storage_data_reset(); rctx_ptr->post_process.tone_map->reset_saturate_coeff(0, false); rctx_ptr->post_process.tone_map->reset_scene_fade(0); - rctx_ptr->post_process.dof->data.pv.enable = false; + dof_pv_data.enable = false; rctx_ptr->disp_manager.object_culling = true; rctx_ptr->render_manager.shadow_ptr->range = 1.0f;