Draw background images

Authored by Marcelo Mutzbauer (1xundoredo) on Sep 5 2017, 7:31 PM.



Implementation of T51366

note: Currently, there is an issue in the 2.8 branch where the frame manipulator for the camera is too big if the camera is selected (or maybe it is intentional?). The issue was not introduced by this patch.

Diff Detail

rB Blender
Build Status
Buildable 800
Build 800: arc lint + arc unit

BTW, I stumbled across what might be an error in gpu_draw.c:

diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -579,10 +579,10 @@ int GPU_verify_image(
 				if (do_color_management) {
 					srgb_frect = MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "floar_buf_col_cor");
 					gpu_verify_high_bit_srgb_buffer(srgb_frect, ibuf);
-					frect = srgb_frect + texwinsy * ibuf->x + texwinsx;
+					frect = srgb_frect + 4 * (texwinsy * ibuf->x + texwinsx);
 				else {
-					frect = ibuf->rect_float + texwinsy * ibuf->x + texwinsx;
+					frect = ibuf->rect_float + ibuf->channels * (texwinsy * ibuf->x + texwinsx);
 			else {

Generally seems fine, though there are some details to look into.

Applied fix rB47b7f06d0e13efba04290d4cfa8c28d2342eebf7


Picky - but this is not an object, its isn't related to object mode, not a blocker and easy to change.
It might be best to add this elsewhere, like we have for - text overlay's for eg.


Duplicate checks, caller checks - best assert here to make sure caller always checks.


These need to be float[3]

20–42 ↗(On Diff #9222)

Would prefer to use separate shader, since this is different enough from an empty object.

Then we can avoid storing the color in DNA too and use the alpha as a uniform.

  • Create separate shader for reference images
  • fixed mistake with float[3]
Marcelo Mutzbauer (1xundoredo) marked 2 inline comments as done.Sep 6 2017, 6:26 PM
Marcelo Mutzbauer (1xundoredo) added inline comments.

This map is acting as system to remember what textures will need to be freed. The only reason the object mode engine needs to free the textures on its own is that we want to able to load movie clips.
Loading textures from clips seems to be quite specific to reference images, so I'm not fully convinced other engines would need this as a general system for now?


OBJECT_cache_init checks background image visibility in general, this function checks visibility flags of individual images.


thoughts on this?

Campbell Barton (campbellbarton) added inline comments.

Talked with @Clément Foucault (fclem) & @Dalai Felinto (dfelinto) - they assure me this is the correct place to draw bg images.

We're considering limiting this functionality only to cameras: T52668

I think it's best to keep this on hold for now. The code from this patch can still be used (the camera part), but it's probably more straightforward to handle T52668 first.

Closing, since background images are mostly removed now (besides the camera view)