diff --git a/src/CRE/post_process.cpp b/src/CRE/post_process.cpp index aab3d995..0992f61a 100644 --- a/src/CRE/post_process.cpp +++ b/src/CRE/post_process.cpp @@ -194,12 +194,13 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param get_frame_texture(rend_texture.GetColorTex(), POST_PROCESS_FRAME_TEXTURE_PRE_PP); - blur->get_blur(&rend_texture); + blur->downsample(&rend_texture); + blur->get_blur(); exposure->get_exposure(cam, render_width, render_height, reset_exposure, - blur->tex[4].GetColorTex(), blur->tex[2].GetColorTex()); + blur->reduce_texture[4].GetColorTex(), blur->reduce_texture[2].GetColorTex()); tone_map->apply(&rend_texture, light_proj_tex, (texture*)(aet_back ? aet_back_tex : 0), &rend_texture, &buf_texture, /* sss_contour_texture,*/ - blur->tex[0].GetColorTex(), exposure->exposure.GetColorTex(), npr_param, this); + blur->reduce_texture[0].GetColorTex(), exposure->exposure.GetColorTex(), npr_param, this); if (mlaa) apply_mlaa(samplers, ss_alpha_mask); @@ -219,7 +220,8 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param gl_state_active_bind_texture_2d(0, rend_texture.GetColorTex()); gl_state_bind_sampler(0, samplers[0]); shaders_ft.set(SHADER_FT_REDUCE); - RenderTexture::DrawQuad(&shaders_ft, render_width, render_height); + RenderTexture::DrawQuad(&shaders_ft, render_width, render_height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); } get_frame_texture(rend_texture.GetColorTex(), POST_PROCESS_FRAME_TEXTURE_POST_PP); @@ -234,7 +236,8 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param uniform_value[U_ALPHA_MASK] = ss_alpha_mask ? 1 : 0; uniform_value[U_REDUCE] = 0; shaders_ft.set(SHADER_FT_REDUCE); - RenderTexture::DrawQuad(&shaders_ft, render_width, render_height); + RenderTexture::DrawQuad(&shaders_ft, render_width, render_height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); uniform_value[U_ALPHA_MASK] = 0; } else { @@ -265,7 +268,8 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param } shaders_ft.set(SHADER_FT_MAGNIFY); - RenderTexture::DrawQuad(&shaders_ft, render_width, render_height); + RenderTexture::DrawQuad(&shaders_ft, render_width, render_height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); } shader::unbind(); @@ -280,7 +284,8 @@ void post_process::apply_mlaa(GLuint* samplers, int32_t ss_alpha_mask) { gl_state_bind_sampler(0, samplers[1]); uniform_value[U_MLAA] = 0; shaders_ft.set(SHADER_FT_MLAA); - RenderTexture::DrawQuad(&shaders_ft, render_width, render_height); + RenderTexture::DrawQuad(&shaders_ft, render_width, render_height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); temp_buffer.Bind(); gl_state_active_bind_texture_2d(0, mlaa_buffer.GetColorTex()); @@ -290,7 +295,8 @@ void post_process::apply_mlaa(GLuint* samplers, int32_t ss_alpha_mask) { uniform_value[U_MLAA] = 1; uniform_value[U_MLAA_SEARCH] = 2; shaders_ft.set(SHADER_FT_MLAA); - RenderTexture::DrawQuad(&shaders_ft, render_width, render_height); + RenderTexture::DrawQuad(&shaders_ft, render_width, render_height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); buf_texture.Bind(); gl_state_active_bind_texture_2d(0, rend_texture.GetColorTex()); @@ -299,7 +305,8 @@ void post_process::apply_mlaa(GLuint* samplers, int32_t ss_alpha_mask) { uniform_value[U_MLAA] = 2; uniform_value[U_ALPHA_MASK] = ss_alpha_mask ? 1 : 0; shaders_ft.set(SHADER_FT_MLAA); - RenderTexture::DrawQuad(&shaders_ft, render_width, render_height); + RenderTexture::DrawQuad(&shaders_ft, render_width, render_height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); uniform_value[U_ALPHA_MASK] = 0; gl_state_active_bind_texture_2d(0, 0); gl_state_active_bind_texture_2d(1, 0); @@ -821,7 +828,8 @@ void post_process::get_frame_texture(GLuint tex, post_process_frame_texture_type glViewport(0, 0, dst_tex->width, dst_tex->height); uniform_value[U_REDUCE] = 0; shaders_ft.set(SHADER_FT_REDUCE); - RenderTexture::DrawQuad(&shaders_ft, dst_tex->width, dst_tex->height); + RenderTexture::DrawQuad(&shaders_ft, dst_tex->width, dst_tex->height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); gl_state_bind_framebuffer(0); } } diff --git a/src/CRE/post_process/blur.cpp b/src/CRE/post_process/blur.cpp index c1b92bdd..7ececda4 100644 --- a/src/CRE/post_process/blur.cpp +++ b/src/CRE/post_process/blur.cpp @@ -20,12 +20,19 @@ static void post_process_blur_radius_calculate_gaussian_kernel(float_t* gaussian post_process_blur::post_process_blur() : data(), width(), height(), width_down(), height_down(), tex_down(), count_down() { - tex[0].Init(256, 144, 0, GL_RGBA16F, 0); - tex[1].Init(128, 72, 0, GL_RGBA16F, 0); - tex[2].Init(64, 36, 0, GL_RGBA16F, 0); - tex[3].Init(32, 18, 0, GL_RGBA16F, 0); - tex[4].Init(8, 8, 0, GL_RGBA16F, 0); - tex[5].Init(256, 144, 0, GL_RGBA16F, 0); + reduce_width[0] = 256; + reduce_height[0] = 144; + reduce_width[1] = 128; + reduce_height[1] = 72; + reduce_width[2] = 64; + reduce_height[2] = 36; + reduce_width[3] = 32; + reduce_height[3] = 18; + reduce_width[4] = 8; + reduce_height[4] = 8; + for (int32_t i = 0; i < 5; i++) + reduce_texture[i].Init(reduce_width[i], reduce_height[i], 0, GL_RGBA16F, 0); + downsample_texture.Init(reduce_width[0], reduce_height[0], 0, GL_RGBA16F, 0); gaussian_coef_ubo.Create(sizeof(gaussian_coef_shader_data)); } @@ -41,20 +48,7 @@ post_process_blur:: ~post_process_blur() { free_def(width_down); } -void post_process_blur::get_blur(RenderTexture* rt) { - uniform_value[U_ALPHA_MASK] = 0; - - vec3 intensity = data.intensity; - vec3* gauss = data.gauss; - - gaussian_coef_shader_data gaussian_coef = {}; - for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE && i < 8; i++) { - vec3 coef = gauss[i] * intensity; - gaussian_coef.g_coef[i] = { coef.x, coef.y, coef.z, 0.0f }; - } - - gaussian_coef_ubo.WriteMemory(gaussian_coef); - +void post_process_blur::downsample(RenderTexture* rt) { int32_t i = 0; if (count_down > 0) { uniform_value[U_REDUCE] = 1; @@ -63,7 +57,8 @@ void post_process_blur::get_blur(RenderTexture* rt) { glViewport(0, 0, width_down[i], height_down[i]); tex_down[i].Bind(); gl_state_active_bind_texture_2d(0, (i ? tex_down[i - 1] : *rt).GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, width_down[i], height_down[i]); + RenderTexture::DrawQuad(&shaders_ft, width_down[i], height_down[i], + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); } i--; } @@ -71,114 +66,91 @@ void post_process_blur::get_blur(RenderTexture* rt) { uniform_value[U_REDUCE] = 3; shaders_ft.set(SHADER_FT_REDUCE); - glViewport(0, 0, 256, 144); - tex[0].Bind(); + glViewport(0, 0, reduce_width[0], reduce_height[0]); + reduce_texture[0].Bind(); gl_state_active_bind_texture_2d(0, (count_down > 0 ? tex_down[i] : *rt).GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, width, height, 1.0f, 1.0f, 1.1f, 1.1f, 1.1f, 0.0f); + RenderTexture::DrawQuad(&shaders_ft, width, height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.1f, 1.1f, 1.1f, 0.0f); - uniform_value[U_GAUSS] = 1; - shaders_ft.set(SHADER_FT_GAUSS); + downsample_texture.Bind(); + gl_state_active_bind_texture_2d(0, reduce_texture[0].GetColorTex()); + for (int32_t i = 1; i < 5; i++) { + float_t scale; + if (i == 4) { + scale = 1.0f; + uniform_value[U_EXPOSURE] = 0; + shaders_ft.set(SHADER_FT_EXPOSURE); + } + else + { + scale = 0.75; + uniform_value[U_REDUCE] = 1; + shaders_ft.set(SHADER_FT_REDUCE); + } - glViewport(0, 0, 256, 144); - tex[5].Bind(); - gl_state_active_bind_texture_2d(0, tex[0].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 256, 144, 1.0f, 1.0f, - data.intensity.x * 0.5f, data.intensity.y * 0.5f, data.intensity.z * 0.5f, 1.0f); + glViewport(0, 0, reduce_width[i], reduce_height[i]); + RenderTexture::DrawQuad(&shaders_ft, reduce_width[i - 1], reduce_height[i - 1], + 1.0f, 1.0f, 0.0f, 0.0f, scale, 1.0f, 1.0f, 1.0f, 1.0f); + gl_state_active_bind_texture_2d(0, reduce_texture[i].GetColorTex()); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, reduce_width[i], reduce_height[i]); + } +} - uniform_value[U_REDUCE] = 1; - shaders_ft.set(SHADER_FT_REDUCE); +void post_process_blur::get_blur() { + uniform_value[U_ALPHA_MASK] = 0; - glViewport(0, 0, 128, 72); - tex[1].Bind(); - gl_state_active_bind_texture_2d(0, tex[0].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 256, 144); + vec3 intensity = data.intensity; + vec3* gauss = data.gauss; - uniform_value[U_REDUCE] = 1; - shaders_ft.set(SHADER_FT_REDUCE); + gaussian_coef_shader_data gaussian_coef = {}; + for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE && i < 8; i++) { + *(vec3*)&gaussian_coef.g_coef[i] = gauss[i] * intensity; + gaussian_coef.g_coef[i].w = 0.0f; + } - glViewport(0, 0, 64, 36); - tex[2].Bind(); - gl_state_active_bind_texture_2d(0, tex[1].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 128, 72); - - uniform_value[U_REDUCE] = 1; - shaders_ft.set(SHADER_FT_REDUCE); - - glViewport(0, 0, 32, 18); - tex[3].Bind(); - gl_state_active_bind_texture_2d(0, tex[2].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 64, 36); - - uniform_value[U_EXPOSURE] = 0; - shaders_ft.set(SHADER_FT_EXPOSURE); - - glViewport(0, 0, 8, 8); - tex[4].Bind(); - gl_state_active_bind_texture_2d(0, tex[3].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 32, 18); + gaussian_coef_ubo.WriteMemory(gaussian_coef); uniform_value[U_GAUSS] = 0; shaders_ft.set(SHADER_FT_GAUSS); gaussian_coef_ubo.Bind(1); - glViewport(0, 0, 128, 72); - tex[0].Bind(); - gl_state_active_bind_texture_2d(0, tex[1].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 128, 72, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f); - fbo::blit(tex[0].fbos[0], tex[1].fbos[0], - 0, 0, 128, 72, - 0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR); + downsample_texture.Bind(); + for (int32_t i = 1; i < 4; i++) { + glViewport(0, 0, reduce_width[i], reduce_height[i]); + gl_state_active_bind_texture_2d(0, reduce_texture[i].GetColorTex()); + RenderTexture::DrawQuad(&shaders_ft, reduce_width[i], reduce_height[i], + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, reduce_width[i], reduce_height[i]); + } - glViewport(0, 0, 64, 36); - tex[0].Bind(); - gl_state_active_bind_texture_2d(0, tex[2].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 64, 36, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f); - fbo::blit(tex[0].fbos[0], tex[2].fbos[0], - 0, 0, 64, 36, - 0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR); + for (int32_t i = 1; i < 4; i++) { + glViewport(0, 0, reduce_width[i], reduce_height[i]); + gl_state_active_bind_texture_2d(0, reduce_texture[i].GetColorTex()); + RenderTexture::DrawQuad(&shaders_ft, reduce_width[i], reduce_height[i], + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, reduce_width[i], reduce_height[i]); + } - glViewport(0, 0, 32, 18); - tex[0].Bind(); - gl_state_active_bind_texture_2d(0, tex[3].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 32, 18); - fbo::blit(tex[0].fbos[0], tex[3].fbos[0], - 0, 0, 32, 18, - 0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR); + uniform_value[U_GAUSS] = 1; + shaders_ft.set(SHADER_FT_GAUSS); - glViewport(0, 0, 128, 72); - tex[0].Bind(); - gl_state_active_bind_texture_2d(0, tex[1].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 128, 72, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f); - fbo::blit(tex[0].fbos[0], tex[1].fbos[0], - 0, 0, 128, 72, - 0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - glViewport(0, 0, 64, 36); - tex[0].Bind(); - gl_state_active_bind_texture_2d(0, tex[2].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 64, 36, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f); - fbo::blit(tex[0].fbos[0], tex[2].fbos[0], - 0, 0, 64, 36, - 0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - glViewport(0, 0, 32, 18); - tex[0].Bind(); - gl_state_active_bind_texture_2d(0, tex[3].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 32, 18, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f); - fbo::blit(tex[0].fbos[0], tex[3].fbos[0], - 0, 0, 32, 18, - 0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR); + glViewport(0, 0, reduce_width[0], reduce_height[0]); + gl_state_active_bind_texture_2d(0, reduce_texture[0].GetColorTex()); + RenderTexture::DrawQuad(&shaders_ft, reduce_width[0], reduce_height[0], + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, + data.intensity.x * 0.5f, data.intensity.y * 0.5f, data.intensity.z * 0.5f, 1.0f); uniform_value[U_REDUCE] = 7; shaders_ft.set(SHADER_FT_REDUCE); - glViewport(0, 0, 256, 144); - tex[0].Bind(); - gl_state_active_bind_texture_2d(0, tex[5].GetColorTex()); - gl_state_active_bind_texture_2d(1, tex[1].GetColorTex()); - gl_state_active_bind_texture_2d(2, tex[2].GetColorTex()); - gl_state_active_bind_texture_2d(3, tex[3].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 32, 18, 0.25f, 0.25f, 0.15f, 0.25f, 0.25f, 0.25f); + glViewport(0, 0, reduce_width[0], reduce_height[0]); + reduce_texture[0].Bind(); + gl_state_active_bind_texture_2d(0, downsample_texture.GetColorTex()); + gl_state_active_bind_texture_2d(1, reduce_texture[1].GetColorTex()); + gl_state_active_bind_texture_2d(2, reduce_texture[2].GetColorTex()); + gl_state_active_bind_texture_2d(3, reduce_texture[3].GetColorTex()); + RenderTexture::DrawQuad(&shaders_ft, reduce_width[3], reduce_height[3], + 1.0f, 1.0f, 0.0f, 0.0f, 0.25f, 0.15f, 0.25f, 0.25f, 0.25f); } void post_process_blur::init_fbo(int32_t width, int32_t height) { diff --git a/src/CRE/post_process/blur.hpp b/src/CRE/post_process/blur.hpp index da58c858..eecf3231 100644 --- a/src/CRE/post_process/blur.hpp +++ b/src/CRE/post_process/blur.hpp @@ -23,7 +23,10 @@ struct post_process_blur { post_process_blur_data data; int32_t width; int32_t height; - RenderTexture tex[6]; + RenderTexture reduce_texture[5]; + RenderTexture downsample_texture; + int32_t reduce_width[5]; + int32_t reduce_height[5]; int32_t* width_down; int32_t* height_down; RenderTexture* tex_down; @@ -33,7 +36,8 @@ struct post_process_blur { post_process_blur(); ~post_process_blur(); - void get_blur(RenderTexture* rt); + void downsample(RenderTexture* rt); + void get_blur(); void init_fbo(int32_t width, int32_t height); void initialize_data(const vec3& radius, const vec3& intensity); diff --git a/src/CRE/post_process/exposure.cpp b/src/CRE/post_process/exposure.cpp index 4579b02e..74874108 100644 --- a/src/CRE/post_process/exposure.cpp +++ b/src/CRE/post_process/exposure.cpp @@ -174,7 +174,8 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width, exposure_measure_ubo.Bind(1); gl_state_active_bind_texture_2d(0, in_tex_0); gl_state_active_bind_texture_2d(1, in_tex_1); - RenderTexture::DrawQuad(&shaders_ft, reset_exposure ? 32 : 1, 1); + RenderTexture::DrawQuad(&shaders_ft, reset_exposure ? 32 : 1, 1, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); exposure_history_counter++; exposure_history_counter %= 32; } @@ -184,7 +185,8 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width, uniform_value[U_EXPOSURE] = 2; shaders_ft.set(SHADER_FT_EXPOSURE); gl_state_active_bind_texture_2d(0, exposure_history.GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 1, 1); + RenderTexture::DrawQuad(&shaders_ft, 1, 1, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); } void post_process_exposure::get_exposure_chara_data(void* pp_data, camera* cam) { diff --git a/src/CRE/render_manager.cpp b/src/CRE/render_manager.cpp index 8de5ea8e..868512a8 100644 --- a/src/CRE/render_manager.cpp +++ b/src/CRE/render_manager.cpp @@ -1197,7 +1197,8 @@ static void draw_pass_sss_contour(render_context* rctx, post_process* pp) { shaders_ft.set(SHADER_FT_CONTOUR); rctx->contour_coef_ubo.Bind(2); - RenderTexture::DrawQuad(&shaders_ft, pp->render_width, pp->render_height); + RenderTexture::DrawQuad(&shaders_ft, pp->render_width, pp->render_height, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); } static void draw_pass_sss_filter_calc_coef(double_t a1, size_t a2, double_t a3, size_t a4, @@ -1305,14 +1306,16 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* sss) { uniform_value[U_REDUCE] = 0; shaders_ft.set(SHADER_FT_REDUCE); gl_state_bind_texture_2d(pp->rend_texture.GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f); + RenderTexture::DrawQuad(&shaders_ft, 640, 360, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f); } sss->textures[2].Bind(); glViewport(0, 0, 320, 180); uniform_value[U_SSS_FILTER] = 0; shaders_ft.set(SHADER_FT_SSS_FILT); gl_state_bind_texture_2d(sss->textures[0].GetColorTex()); - RenderTexture::DrawQuad(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f); + RenderTexture::DrawQuad(&shaders_ft, 640, 360, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f); sss_filter_gaussian_coef_shader_data shader_data = {}; shader_data.g_param = { (float_t)(sss_count - 1), 0.0f, 1.0f, 1.0f }; @@ -1330,7 +1333,8 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* sss) { shaders_ft.set(SHADER_FT_SSS_FILT); gl_state_bind_texture_2d(sss->textures[2].GetColorTex()); rctx->sss_filter_gaussian_coef_ubo.Bind(1); - RenderTexture::DrawQuad(&shaders_ft, 320, 180, 1.0f, 1.0f, 1.0f, 0.96f, 1.0f, 0.0f); + RenderTexture::DrawQuad(&shaders_ft, 320, 180, + 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.96f, 1.0f, 0.0f); gl_state_bind_texture_2d(0); } diff --git a/src/CRE/render_texture.cpp b/src/CRE/render_texture.cpp index 6008f4ff..1baeac51 100644 --- a/src/CRE/render_texture.cpp +++ b/src/CRE/render_texture.cpp @@ -146,14 +146,18 @@ void RenderTexture::DrawCustom() { } void RenderTexture::DrawQuad(shader_set_data* set, int32_t width, int32_t height, - float_t scale_x, float_t scale_y, float_t param_x, float_t param_y, float_t param_z, float_t param_w) { + float_t s0, float_t t0, float_t s1, float_t t1, float_t scale, + float_t param_x, float_t param_y, float_t param_z, float_t param_w) { extern render_context* rctx_ptr; + s0 -= s1; + t0 -= t1; + float_t w = (float_t)max_def(width, 1); float_t h = (float_t)max_def(height, 1); quad_shader_data quad = {}; - quad.g_texcoord_modifier = { 0.5f, 0.5f, 0.5f, 0.5f }; // x * 0.5 + 0.5 - quad.g_texel_size = { scale_x / w, scale_y / h, w, h }; + quad.g_texcoord_modifier = { 0.5f * s0, 0.5f * t0, 0.5f * s0 + s1, 0.5f * t0 + t1 }; // x * 0.5 * y0 + 0.5 * y0 + y1 + quad.g_texel_size = { scale / w, scale / h, w, h }; quad.g_color = { param_x, param_y, param_z, param_w }; quad.g_texture_lod = 0.0f; diff --git a/src/CRE/render_texture.hpp b/src/CRE/render_texture.hpp index 542cd50f..e0fb034b 100644 --- a/src/CRE/render_texture.hpp +++ b/src/CRE/render_texture.hpp @@ -30,9 +30,9 @@ struct RenderTexture { static void Draw(shader_set_data* set); static void DrawCustom(); - static void DrawQuad(shader_set_data* set, - int32_t width, int32_t height, float_t scale_x = 1.0f, float_t scale_y = 1.0f, - float_t param_x = 1.0f, float_t param_y = 1.0f, float_t param_z = 1.0f, float_t param_w = 1.0f); + static void DrawQuad(shader_set_data* set, int32_t width, int32_t height, + float_t s0, float_t t0, float_t s1, float_t t1, float_t scale, + float_t param_x, float_t param_y, float_t param_z, float_t param_w); inline GLuint GetColorTex() { return color_texture->tex;