Fix T91398 Overlay: Camera BG jitter offset (regression)
This was caused by camera background being rendered in world space, causing floating point imprecision issues when camera was far from origin. Adding a uniform to change vertex shader to process everything in viewspace to fix the problem.
This commit is contained in:
parent
583939c54d
commit
42d79a6041
Notes:
blender-bot
2023-02-14 08:45:09 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93 Referenced by issue #88449, Blender LTS: Maintenance Task 2.93 Referenced by issue #91398, Camera BG jitter offset (regression)
|
@ -344,7 +344,6 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
if (tex) {
|
||||
image_camera_background_matrix_get(cam, bgpic, draw_ctx, aspect, mat);
|
||||
|
||||
mul_m4_m4m4(mat, modelmat, mat);
|
||||
const bool is_foreground = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != 0;
|
||||
/* Alpha is clamped just below 1.0 to fix background images to interfere with foreground
|
||||
* images. Without this a background image with 1.0 will be rendered on top of a transparent
|
||||
|
@ -361,6 +360,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
DRW_shgroup_uniform_texture(grp, "imgTexture", tex);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "imgPremultiplied", use_alpha_premult);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "imgAlphaBlend", true);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "isCameraBackground", true);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "depthSet", true);
|
||||
DRW_shgroup_uniform_vec4_copy(grp, "color", color_premult_alpha);
|
||||
DRW_shgroup_call_obmat(grp, DRW_cache_quad_get(), mat);
|
||||
|
@ -446,6 +446,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
DRW_shgroup_uniform_texture(grp, "imgTexture", tex);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "imgPremultiplied", use_alpha_premult);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "imgAlphaBlend", use_alpha_blend);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "isCameraBackground", false);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "depthSet", depth_mode != OB_EMPTY_IMAGE_DEPTH_DEFAULT);
|
||||
DRW_shgroup_uniform_vec4_copy(grp, "color", ob->color);
|
||||
DRW_shgroup_call_obmat(grp, DRW_cache_quad_get(), mat);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
uniform bool depthSet;
|
||||
uniform bool isCameraBackground;
|
||||
|
||||
in vec3 pos;
|
||||
|
||||
|
@ -7,8 +8,14 @@ out vec2 uvs;
|
|||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
if (isCameraBackground) {
|
||||
vec3 vP = (ModelMatrix * vec4(pos, 1.0)).xyz;
|
||||
gl_Position = point_view_to_ndc(vP);
|
||||
}
|
||||
else {
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
}
|
||||
|
||||
if (depthSet) {
|
||||
/* Result in a position at 1.0 (far plane). Small epsilon to avoid precision issue.
|
||||
|
|
Loading…
Reference in New Issue