diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-02-06 13:49:41 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-02-06 18:11:51 +0300 |
commit | 8c87af74409a3e6681698ba1bf150dd6155e202f (patch) | |
tree | a9549a2315fed37625e8bd126e91c8855a00147a /source/blender/blenkernel/intern/image.c | |
parent | e21ae0bb267a54482108ddd4feed99c89241804b (diff) |
Improvements and fixes to Cycles metadata
This is a request by the studio here to make it possible to see how
many samples were used to render a specific shot or a frame. It is a
bit more tricky than simply stamping number of samples from a scene
since rendering is happening in multiple ranges of samples.
This change makes it so Cycles saves configured number of samples for
the specific view layer, and also stores start sample and number of
samples when rendering only a subrange of all samples.
The format used is "cycles.<view_layer_name>.><field>", which allows
to have information about all layers in a multi-layer EXR file.
Ideally we can store simplified "cycles.<field>" if we know that there
is only one render layer in the file, but detecting this is somewhat
tricky since Cycles operates on an evaluated scene which always have
single view layer.
The metadata is shown in the Metadata panels for clip, image and
sequencer spaces.
Example screenshot which shows the metadata:
{F6527727}
Reviewers: brecht
Reviewed By: brecht
Subscribers: fsiddi
Differential Revision: https://developer.blender.org/D4311
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3ba216dcc13..5428c921042 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2094,6 +2094,24 @@ struct StampData *BKE_stamp_info_from_scene_static(Scene *scene) return stamp_data; } +static const char *stamp_metadata_fields[] = { + "File", + "Note", + "Date", + "Marker", + "Time", + "Frame", + "FrameRange", + "Camera", + "Lens", + "Scene", + "Strip", + "RenderTime", + "Memory", + "Hostname", + NULL +}; + void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip) { if ((callback == NULL) || (stamp_data == NULL)) { @@ -2105,6 +2123,8 @@ void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCall callback(data, value_str, stamp_data->member, sizeof(stamp_data->member)); \ } ((void)0) + /* TODO(sergey): Use stamp_metadata_fields somehow, or make it more generic + * meta information to avoid duplication. */ CALL(file, "File"); CALL(note, "Note"); CALL(date, "Date"); @@ -2177,6 +2197,30 @@ void BKE_imbuf_stamp_info(RenderResult *rr, struct ImBuf *ibuf) BKE_stamp_info_callback(ibuf, stamp_data, metadata_set_field, false); } +BLI_INLINE bool metadata_is_copyable(const char *field_name) +{ + int i = 0; + while (stamp_metadata_fields[i] != NULL) { + if (STREQ(field_name, stamp_metadata_fields[i])) { + return false; + } + i++; + } + return true; +} + +static void metadata_copy_custom_fields( + const char *field, + const char *value, + void *rr_v) +{ + if (!metadata_is_copyable(field)) { + return; + } + RenderResult *rr = (RenderResult *)rr_v; + BKE_render_result_stamp_data(rr, field, value); +} + void BKE_stamp_info_from_imbuf(RenderResult *rr, struct ImBuf *ibuf) { if (rr->stamp_data == NULL) { @@ -2185,6 +2229,8 @@ void BKE_stamp_info_from_imbuf(RenderResult *rr, struct ImBuf *ibuf) struct StampData *stamp_data = rr->stamp_data; IMB_metadata_ensure(&ibuf->metadata); BKE_stamp_info_callback(ibuf, stamp_data, metadata_get_field, true); + /* Copy render engine specific settings. */ + IMB_metadata_foreach(ibuf, metadata_copy_custom_fields, rr); } bool BKE_imbuf_alpha_test(ImBuf *ibuf) |