add grab output mipmap level feature

This commit is contained in:
2023-08-14 13:54:20 +03:00
parent c3bb81f72d
commit ef764d947d
7 changed files with 59 additions and 6 deletions

View File

@@ -47,7 +47,9 @@ Renderer::Renderer(QGLView * view_)
, rend_service(this)
, rend_selection(this)
, tone_proc(this)
, tex_env(view_, 512) {
, tex_env(view_, 512)
, img_mips(fbo_out, obrLighting, 4)
, img_f_mips(fbo_out, obrLighting, 4) {
mat_norm_to_tex_coord.scale(0.5, 0.5);
mat_norm_to_tex_coord.translate(1, 1);
mat_proj_90 = glMatrixPerspective(90., 1., 0.1);
@@ -137,6 +139,10 @@ void Renderer::init(int width, int height) {
shadow_maps_omni.reinit();
depth_maps_cone.reinit();
depth_maps_omni.reinit();
img_mips.reinit();
img_f_mips.reinit();
img_mips.enablePixelBuffer();
img_f_mips.enablePixelBuffer();
resize(width, height);
rend_mat.init(256, 256);
rend_service.init(width, height);
@@ -158,6 +164,8 @@ void Renderer::resize(int width, int height) {
rend_selection.resize(width, height);
fbo_ds.resize(width, height);
fbo_out.resize(width, height);
img_mips.resize();
img_f_mips.resize();
tone_proc.resize();
}
@@ -712,12 +720,26 @@ void Renderer::renderScene() {
/// grab framebuffer
phase.begin("grab");
if (view->grabFormats().testFlag(gfImage)) {
fbo_out.queryImage(cur_write_plane);
last_img = fbo_out.getImage().mirrored();
if (grab_mipmap == 0) {
fbo_out.queryImage(cur_write_plane);
last_img = fbo_out.getImage().mirrored();
} else {
img_mips.setIndexFrom(cur_write_plane);
img_mips.create();
img_mips.plane(grab_mipmap - 1).queryImage(0);
last_img = img_mips.plane(grab_mipmap - 1).getImage().mirrored();
}
}
if (view->grabFormats().testFlag(gfFloat)) {
fbo_out.queryImageF(obrLighting);
last_img_f = fbo_out.getPointsFloat();
if (grab_mipmap_f == 0) {
fbo_out.queryImage(obrLighting);
last_img_f = fbo_out.getPointsFloat();
} else {
img_f_mips.setIndexFrom(obrLighting);
img_f_mips.create();
img_f_mips.plane(grab_mipmap_f - 1).queryImageF(0);
last_img_f = img_f_mips.plane(grab_mipmap_f - 1).getPointsFloat();
}
}
// qDebug() << last_img.size();
phase.end();