diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_render.c | 15 | ||||
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 17 | ||||
-rw-r--r-- | source/blender/gpu/GPU_shader_interface.h | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_interface.c | 1 |
6 files changed, 25 insertions, 16 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index df587424ba2..8ef613f3711 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -53,6 +53,8 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph * EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); Scene *scene = DEG_get_evaluated_scene(depsgraph); const float *size_orig = DRW_viewport_size_get(); + float size_final[2]; + float camtexcofac[4]; /* Init default FB and render targets: * In render mode the default framebuffer is not generated @@ -73,10 +75,22 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph * if (scene->eevee.flag & SCE_EEVEE_OVERSCAN) { g_data->overscan = scene->eevee.overscan / 100.0f; g_data->overscan_pixels = roundf(max_ff(size_orig[0], size_orig[1]) * g_data->overscan); + + madd_v2_v2v2fl(size_final, size_orig, (float[2]){2.0f, 2.0f}, g_data->overscan_pixels); + + camtexcofac[0] = size_final[0] / size_orig[0]; + camtexcofac[1] = size_final[1] / size_orig[1]; + + camtexcofac[2] = -camtexcofac[0] * g_data->overscan_pixels / size_final[0]; + camtexcofac[3] = -camtexcofac[1] * g_data->overscan_pixels / size_final[1]; + + print_v4_id(camtexcofac); } else { + copy_v2_v2(size_final, size_orig); g_data->overscan = 0.0f; g_data->overscan_pixels = 0.0f; + copy_v4_fl4(camtexcofac, 1.0f, 1.0f, 0.0f, 0.0f); } /* XXX overiding viewport size. Simplify things but is not really 100% safe. */ @@ -114,6 +128,7 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph * invert_m4_m4(viewmat, viewinv); DRWView *view = DRW_view_create(viewmat, winmat, NULL, NULL, NULL); + DRW_view_camtexco_set(view, camtexcofac); DRW_view_default_set(view); DRW_view_set_active(view); diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 938f9921972..0f019df9d86 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -548,6 +548,7 @@ void DRW_view_default_set(DRWView *view); void DRW_view_set_active(DRWView *view); void DRW_view_clip_planes_set(DRWView *view, float (*planes)[4], int plane_len); +void DRW_view_camtexco_set(DRWView *view, float texco[4]); /* For all getters, if view is NULL, default view is assumed. */ void DRW_view_winmat_get(const DRWView *view, float mat[4][4], bool inverse); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index cabf6849e43..be046abfc8c 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -656,7 +656,7 @@ static void drw_viewport_var_init(void) DST.pixsize = rv3d->pixsize; DST.view_default = DRW_view_create(rv3d->viewmat, rv3d->winmat, NULL, NULL, NULL); - copy_v4_v4(DST.view_default->storage.viewcamtexcofac, rv3d->viewcamtexcofac); + DRW_view_camtexco_set(DST.view_default, rv3d->viewcamtexcofac); if (DST.draw_ctx.sh_cfg == GPU_SHADER_CFG_CLIPPED) { int plane_len = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6; diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index d0480108920..70f7d28d551 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -874,8 +874,6 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader) drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION_INV, storage->persinv, 16, 1); drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION, storage->winmat, 16, 1); drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION_INV, storage->wininv, 16, 1); - drw_shgroup_builtin_uniform( - shgroup, GPU_UNIFORM_CAMERATEXCO, DST.view_storage_cpy.viewcamtexcofac, 4, 1); } /* Not supported. */ @@ -1327,10 +1325,7 @@ DRWView *DRW_view_create(const float viewmat[4][4], view->visibility_fn = visibility_fn; view->parent = NULL; - /* TODO move elsewhere */ - if (DST.view_default) { - copy_v4_v4(view->storage.viewcamtexcofac, DST.view_default->storage.viewcamtexcofac); - } + copy_v4_fl4(view->storage.viewcamtexcofac, 1.0f, 1.0f, 0.0f, 0.0f); DRW_view_update(view, viewmat, winmat, culling_viewmat, culling_winmat); @@ -1350,11 +1345,6 @@ DRWView *DRW_view_create_sub(const DRWView *parent_view, *view = *parent_view; view->parent = (DRWView *)parent_view; - /* TODO move elsewhere */ - if (DST.view_default) { - copy_v4_v4(view->storage.viewcamtexcofac, DST.view_default->storage.viewcamtexcofac); - } - DRW_view_update_sub(view, viewmat, winmat); return view; @@ -1471,6 +1461,11 @@ void DRW_view_clip_planes_set(DRWView *view, float (*planes)[4], int plane_len) } } +void DRW_view_camtexco_set(DRWView *view, float texco[4]) +{ + copy_v4_v4(view->storage.viewcamtexcofac, texco); +} + /* Return world space frustum corners. */ void DRW_view_frustum_corners_get(const DRWView *view, BoundBox *corners) { diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index fc7d9e22ea3..441f7290cc5 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -44,9 +44,8 @@ typedef enum { GPU_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ - GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */ - GPU_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ - GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ + GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */ + GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ GPU_UNIFORM_COLOR, /* vec4 color */ GPU_UNIFORM_CALLID, /* int callId */ diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 97dbb80d736..3993ee4df24 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -61,7 +61,6 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u) [GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", [GPU_UNIFORM_NORMAL] = "NormalMatrix", - [GPU_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors", [GPU_UNIFORM_ORCO] = "OrcoTexCoFactors", [GPU_UNIFORM_COLOR] = "color", |