mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-06 21:58:09 +03:00
Added samplers in post_process
This commit is contained in:
+45
-17
@@ -1262,6 +1262,8 @@ namespace rndr {
|
||||
}
|
||||
|
||||
void Render::downsample() {
|
||||
render_context* rctx = rctx_ptr;
|
||||
|
||||
uniform_value[U_REDUCE] = 1;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
for (int32_t i = 1; i < downsample_count - 1; i++) {
|
||||
@@ -1281,6 +1283,7 @@ namespace rndr {
|
||||
glViewport(0, 0, reduce_width[0], reduce_height[0]);
|
||||
reduce_texture[0].Bind();
|
||||
gl_state_active_bind_texture_2d(0, rend_texture[downsample].GetColorTex());
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
draw_quad(
|
||||
render_post_width[downsample], render_post_height[downsample],
|
||||
render_post_width_scale, render_post_height_scale,
|
||||
@@ -1288,6 +1291,7 @@ namespace rndr {
|
||||
|
||||
downsample_texture.Bind();
|
||||
gl_state_active_bind_texture_2d(0, reduce_tex[0]->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
for (int32_t i = 1; i < 5; i++) {
|
||||
float_t scale;
|
||||
if (i == 4) {
|
||||
@@ -1306,6 +1310,7 @@ namespace rndr {
|
||||
draw_quad(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_tex[i]->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, reduce_width[i], reduce_height[i]);
|
||||
}
|
||||
}
|
||||
@@ -1407,7 +1412,7 @@ namespace rndr {
|
||||
gl_state_active_bind_texture_2d(0, mlaa_buffer.GetColorTex());
|
||||
gl_state_active_bind_texture_2d(1, mlaa_area_texture);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
gl_state_bind_sampler(1, rctx->render_samplers[1]);
|
||||
gl_state_bind_sampler(1, rctx->render_samplers[3]);
|
||||
uniform_value[U_MLAA] = 1;
|
||||
uniform_value[U_MLAA_SEARCH] = 2;
|
||||
shaders_ft.set(SHADER_FT_MLAA);
|
||||
@@ -1420,6 +1425,7 @@ namespace rndr {
|
||||
gl_state_active_bind_texture_2d(0, taa_tex[2]->tex);
|
||||
gl_state_active_bind_texture_2d(1, temp_buffer.GetColorTex());
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[1]);
|
||||
gl_state_bind_sampler(1, rctx->render_samplers[1]);
|
||||
uniform_value[U_MLAA] = 2;
|
||||
uniform_value[U_ALPHA_MASK] = ss_alpha_mask ? 1 : 0;
|
||||
shaders_ft.set(SHADER_FT_MLAA);
|
||||
@@ -1437,8 +1443,7 @@ namespace rndr {
|
||||
}
|
||||
|
||||
void Render::apply_tone_map(texture* light_proj_tex, int32_t npr_param) {
|
||||
if (!this)
|
||||
return;
|
||||
render_context* rctx = rctx_ptr;
|
||||
|
||||
gl_state_begin_event("PostProcess::tone_map");
|
||||
|
||||
@@ -1455,9 +1460,16 @@ namespace rndr {
|
||||
gl_state_active_bind_texture_2d(1, reduce_tex_draw);
|
||||
gl_state_active_bind_texture_2d(2, tonemap_lut_texture);
|
||||
gl_state_active_bind_texture_2d(3, exposure_tex);
|
||||
gl_state_active_bind_texture_2d(4, rctx_ptr->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(5, rctx_ptr->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(6, rctx_ptr->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(4, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(5, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(6, rctx->empty_texture_2d);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[1]);
|
||||
gl_state_bind_sampler(1, rctx->render_samplers[2]);
|
||||
gl_state_bind_sampler(2, rctx->render_samplers[0]);
|
||||
gl_state_bind_sampler(3, rctx->render_samplers[3]);
|
||||
gl_state_bind_sampler(4, rctx->render_samplers[2]);
|
||||
gl_state_bind_sampler(5, rctx->render_samplers[2]);
|
||||
gl_state_bind_sampler(6, rctx->render_samplers[2]);
|
||||
|
||||
if (aet_back) {
|
||||
gl_state_active_bind_texture_2d(6, aet_back_tex->tex);
|
||||
@@ -1501,7 +1513,7 @@ namespace rndr {
|
||||
|
||||
uniform_value[U_FLARE] = 1;
|
||||
gl_state_active_bind_texture_2d(4, lens_flare_texture);
|
||||
gl_state_bind_sampler(4, rctx_ptr->render_samplers[2]);
|
||||
gl_state_bind_sampler(4, rctx->render_samplers[2]);
|
||||
mat4 mat;
|
||||
mat4_translate(0.5f, 0.5f, 0.0f, &mat);
|
||||
mat4_scale_rot(&mat, 0.75f, 0.75f, 1.0f, &mat);
|
||||
@@ -1517,7 +1529,7 @@ namespace rndr {
|
||||
if (lens_shaft_scale < 50.0f) {
|
||||
uniform_value[U_FLARE] = 2;
|
||||
gl_state_active_bind_texture_2d(5, lens_shaft_texture);
|
||||
gl_state_bind_sampler(5, rctx_ptr->render_samplers[2]);
|
||||
gl_state_bind_sampler(5, rctx->render_samplers[2]);
|
||||
mat4_translate(0.5f, 0.5f, 0.0f, &mat);
|
||||
mat4_scale_rot(&mat, lens_shaft_scale, lens_shaft_scale, 1.0f, &mat);
|
||||
mat4_mul_rotate_z(&mat, (lens_flare_pos.x / (float_t)width)
|
||||
@@ -1543,26 +1555,28 @@ namespace rndr {
|
||||
|
||||
if (npr_param == 1) {
|
||||
/*gl_state_active_bind_texture_2d(16, sss_contour_texture->GetColorTex());
|
||||
gl_state_bind_sampler(16, rctx_ptr->render_samplers[1]);
|
||||
gl_state_bind_sampler(16, rctx->render_samplers[1]);
|
||||
gl_state_active_bind_texture_2d(17, sss_contour_texture->GetDepthTex());
|
||||
gl_state_bind_sampler(17, rctx_ptr->render_samplers[1]);*/
|
||||
gl_state_bind_sampler(17, rctx->render_samplers[1]);*/
|
||||
gl_state_active_bind_texture_2d(14, rend_texture[0].GetDepthTex());
|
||||
gl_state_bind_sampler(14, rctx_ptr->render_samplers[1]);
|
||||
gl_state_bind_sampler(14, rctx->render_samplers[1]);
|
||||
}
|
||||
|
||||
rctx_ptr->tone_map_ubo.WriteMemory(shader_data);
|
||||
rctx->tone_map_ubo.WriteMemory(shader_data);
|
||||
|
||||
glViewport(0, 0, render_width[0], render_height[0]);
|
||||
taa_buffer[2].Bind();
|
||||
shaders_ft.set(SHADER_FT_TONEMAP);
|
||||
rctx_ptr->tone_map_ubo.Bind(1);
|
||||
gl_state_bind_vertex_array(rctx_ptr->common_vao);
|
||||
rctx->tone_map_ubo.Bind(1);
|
||||
gl_state_bind_vertex_array(rctx->common_vao);
|
||||
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_state_active_bind_texture_2d(2, 0);
|
||||
gl_state_end_event();
|
||||
}
|
||||
|
||||
void Render::calc_exposure(camera* cam) {
|
||||
render_context* rctx = rctx_ptr;
|
||||
|
||||
bool v2 = false;
|
||||
if (!reset_exposure) {
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++)
|
||||
@@ -1681,7 +1695,7 @@ namespace rndr {
|
||||
for (int32_t i = 0; i < 4 && i < ROB_CHARA_COUNT; i++, chara_data++)
|
||||
for (int32_t j = 0; j < 8; j++)
|
||||
exposure_measure.g_spot_coefficients[i * 8 + j] = chara_data->spot_coefficients[j];
|
||||
rctx_ptr->exposure_measure_ubo.WriteMemory(exposure_measure);
|
||||
rctx->exposure_measure_ubo.WriteMemory(exposure_measure);
|
||||
|
||||
if (reset_exposure)
|
||||
glViewport(0, 0, 32, 1);
|
||||
@@ -1691,13 +1705,16 @@ namespace rndr {
|
||||
|
||||
uniform_value[U_EXPOSURE] = 1;
|
||||
shaders_ft.set(SHADER_FT_EXPOSURE);
|
||||
rctx_ptr->exposure_measure_ubo.Bind(1);
|
||||
rctx->exposure_measure_ubo.Bind(1);
|
||||
gl_state_active_bind_texture_2d(0, reduce_tex[4]->tex);
|
||||
gl_state_active_bind_texture_2d(1, reduce_tex[2]->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
gl_state_bind_sampler(1, rctx->render_samplers[2]);
|
||||
draw_quad(1, 1, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
gl_state_active_bind_texture_2d(0, exposure_history->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
if (reset_exposure)
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 32, 1);
|
||||
else
|
||||
@@ -1710,6 +1727,7 @@ namespace rndr {
|
||||
uniform_value[U_EXPOSURE] = 2;
|
||||
shaders_ft.set(SHADER_FT_EXPOSURE);
|
||||
gl_state_active_bind_texture_2d(0, exposure_history->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
draw_quad(1, 1, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
@@ -1854,6 +1872,7 @@ namespace rndr {
|
||||
uniform_value[U_REDUCE] = 4;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
gl_state_active_bind_texture_2d(0, lens_ghost_texture);
|
||||
gl_state_bind_sampler(0, rctx_ptr->render_samplers[0]);
|
||||
gl_state_bind_vertex_array(rctx_ptr->lens_ghost_vao);
|
||||
shaders_ft.draw_arrays(GL_TRIANGLES, 0, (GLsizei)(lens_ghost_count * 6LL));
|
||||
gl_state_bind_vertex_array(0);
|
||||
@@ -1869,16 +1888,19 @@ namespace rndr {
|
||||
}
|
||||
|
||||
void Render::get_blur() {
|
||||
render_context* rctx = rctx_ptr;
|
||||
|
||||
uniform_value[U_ALPHA_MASK] = 0;
|
||||
uniform_value[U_GAUSS] = 0;
|
||||
shaders_ft.set(SHADER_FT_GAUSS);
|
||||
calc_gaussian_blur(1.0f, 1.0f, 7, 0.8f, 1.0f);
|
||||
rctx_ptr->gaussian_coef_ubo.Bind(1);
|
||||
rctx->gaussian_coef_ubo.Bind(1);
|
||||
|
||||
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_tex[i]->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
draw_quad(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]);
|
||||
@@ -1887,6 +1909,7 @@ namespace rndr {
|
||||
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_tex[i]->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
draw_quad(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]);
|
||||
@@ -1897,6 +1920,7 @@ namespace rndr {
|
||||
|
||||
glViewport(0, 0, reduce_width[0], reduce_height[0]);
|
||||
gl_state_active_bind_texture_2d(0, reduce_tex[0]->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
draw_quad(reduce_width[0], reduce_height[0],
|
||||
1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
||||
intensity.x * 0.5f, intensity.y * 0.5f, intensity.z * 0.5f, 1.0f);
|
||||
@@ -1910,6 +1934,10 @@ namespace rndr {
|
||||
gl_state_active_bind_texture_2d(1, reduce_tex[1]->tex);
|
||||
gl_state_active_bind_texture_2d(2, reduce_tex[2]->tex);
|
||||
gl_state_active_bind_texture_2d(3, reduce_tex[3]->tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
gl_state_bind_sampler(1, rctx->render_samplers[2]);
|
||||
gl_state_bind_sampler(2, rctx->render_samplers[2]);
|
||||
gl_state_bind_sampler(3, rctx->render_samplers[2]);
|
||||
draw_quad(reduce_width[3], reduce_height[3],
|
||||
1.0f, 1.0f, 0.0f, 0.0f, 0.25f, 0.15f, 0.25f, 0.25f, 0.25f);
|
||||
reduce_tex_draw = reduce_tex[0]->tex;
|
||||
|
||||
Reference in New Issue
Block a user