Is it possible to take arbitrary properties and display them in the render stamp as some other software do.
3 Answers
While Blender has no build-in support for this feature. You can do this using Python:
Add a script into your file, call it stamp_init.py
(for example).
- Press Run Script (only need to do once)
- Enable the Register option in the text editor (so it runs automatically)
Here is a sample script.
import bpy
def stamp_set(scene):
note = "Samples: " + str(scene.cycles.samples)
note += ", ApertireBlades: " + str(scene.camera.data.cycles.aperture_blades)
note += ", Version: " + bpy.app.version_string
scene.render.stamp_note_text = note
bpy.app.handlers.render_pre.append(stamp_set)
To add more settings you can find the data-paths to them by right clicking and selecting Copy Data-Path.
Global Stamp (applies to any file you render)
Having to define a script in every-file could be tedious, if you want to use these extra stamp options in all your files, you can make this a persistent
handler.
If you want to have the same stamp notes apply to all your renders (where the Note is enabled). You can add the same script into your startup file and
@bpy.app.handlers.persistent
def stamp_set(scene):
.... same as before ...
String Formatting (further reading if you're new to Python)
Python has some clever ways you can format strings, see Python docs.
This uses the format
method which some people may prefer.
def stamp_set(scene):
scene.render.stamp_note_text = \
"Samples: {samples}, Blades: {blades}, Version: {ver}".format(
samples=scene.cycles.samples,
blades=scene.camera.data.cycles.aperture_blades,
ver=bpy.app.version_string,
)
New Lines
As of 2.77 the note will be wrapped onto new lines, you can also add in explicit \n
newline characters to format the text yourself.
Floating point numbers
A lot could be written on this, just a quick hint, if you have unwanted precision removed, eg:2.514000002324
displayed as 2.51
, there are a few ways to go about it.
- If you used
"Text " + str(some.number)
you can useround
, eg:"Text " + str(round(some.number, 2))
- If you use the
format()
method you can replace:{myvar}
with{myvar:.2f}
.
For more details see https://stackoverflow.com/a/455634/432509
-
1$\begingroup$ Thanks for the information! Is it possible to reduce the amount of digits for example Aperture Size (scene.camera.data.cycles.aperture_size) string returns? - Because number 0.55 in the DOF panel returns 0.5499997735023499 $\endgroup$ Mar 24, 2015 at 16:31
-
1$\begingroup$ Added hint on reducing excess precision. $\endgroup$ Mar 24, 2015 at 17:39
-
$\begingroup$ Is there a way to do this for values that change over time? For instance, the Lens stamp setting don't update when I change the focal length of the camera. What if I wanted to have a custom note that includes the camera's focal length and change it over time? Would that be possible? $\endgroup$ Apr 21, 2020 at 16:46
-
$\begingroup$ Have a look at the different handlers, after changing the frame might be a good time to run this. $\endgroup$ Apr 27, 2020 at 2:32
For Blender 2.8+
Note that the aforementioned solutions do not seem to work in newer versions of Blender (I'm using 2.92.0, but I imagine the changes are from 2.8+).
Herewith a working solution:
import bpy
cycles = bpy.context.scene.cycles
view_settings = bpy.context.scene.view_settings
def stamp_set(scene):
note = "-------------\nCustom data\n-------------"
note += "\nSamples: " + str(cycles.aa_samples)
note += "\nLook: " + str(view_settings.look)
note += "\nExposure: " + str(round(view_settings.exposure, 2))
scene.render.stamp_note_text = note
bpy.app.handlers.render_pre.append(stamp_set)
This solution:
- Works in latest versions of Blender
- Incorporates number rounding and newlines as per comment by ideasman42
- Allows you to add new lines of data just by duplicating any of the
note += ...
lines
Sample output: