This PR updates the [Copy Off-screen Rendering result back to RAM
example in the Python GPU Module docs. As recommended by @Lia-32 in
#147614, copying the buffer using the list slicing notation is much
faster than the list comprehension currently used in the example.
Pull Request: https://projects.blender.org/blender/blender/pulls/163354
Instead of reusing `ERROR` for both warnings and errors, and the Info
Editor icon for "info" label comments, use the new icons from !161002.
* Use `STATUS_WARNING` when the code refers to simple warnings, the
feature might still work.
* Use `STATUS_ERROR` when the code refers to incompatibility, broken
functionality, general errors.
* Use `STATUS_INFO` for every info label. Keep `INFO` for the editor.
* Sometimes `WARNING_LARGE` was used, that should only be used for
dialogs. Use the regular warning instead, it looks almost the same.
* When extra contrast is needed, the filled version is used.
Mostly no big visual changes, other than warnings that were meant as
actual errors using the proper icon now.
See !161038 for details and screenshots.
Pull Request: https://projects.blender.org/blender/blender/pulls/161038
Each `ImBuf` now behaves as if it can only have one pixel buffer.
- `imbuf.new()` takes a new keyword-only `buffer_type` argument
(FLOAT, BYTE).
- `ImBuf.buffer_type` - new read only attribute.
- `ImBuf.convert_buffer_type(bufrer_type)` - function for
converting between types.
- `ImBuf.with_buffer()` no longer takes a type argument.
- In the unlikely even both buffers are missing,
`ValueError("ImBuf has no pixel data")` is raised.
Removed: (recently added, not regressions)
- `ImBuf.ensure_buffer`
- `ImBuf.has_buffer`
- `ImBuf.clear_buffer`
Ref !158532
Capture the contents of a window as a read-only `memoryview` of RGBA
bytes shaped `(height, width, 4)`, matching numpy's image convention.
Advantages over the operator for the Python API:
- It's not possible to set the image format from Python.
- It wasn't possible to capture pixel data without writing it to disk.
The documentation example shows how a screenshot can be captured
and written to an image file using imbuf.
Ref !158030
sphinx_doc_gen.py:
- Add _PRIVATE_ATTR_INCLUDE so underscore-prefixed types can be
selectively included in API docs (needed to reference return values).
- Add :return:/:rtype: for operators.
- Fix context type entries (AnnotationLayer, FluidModifier, Curves).
bpy.props:
- Add :return:/:rtype: for property declaration functions.
gpu:
- Expose MatrixStackContext and OffScreenStackContext as documented
gpu.types so :rtype: references resolve.
bmesh.ops:
- Use Sequence[float] for vector input params.
- Add default_value for single-element BMO_OP_SLOT_ELEMENT_BUF slots.
bpy.types:
- Convert `tuple of X` to `tuple[X, ...]` and `list of X` to `list[X]`.
- Add :return:/:rtype: to Context.path_resolve and Operator.as_keywords.
- Fix Menu example link reference.
bpy_extras:
- Convert Python type annotations to :param:/:type:/:rtype:,
add missing doc-strings.
bpy.app.handlers:
- Add :type: with callable signatures.
- Fix depsgraph_update handler description
(the second argument is optional).
- Fix missing argument descriptions for render and undo/redo handlers.
bpy.context
- Use type hints for for property listing.
mathutils.kdtree:
- Fix doc-string syntax.
- Clarify that the size is an upper limit.
Various minor corrections to other modules.
Examples were supported with/without number suffix,
this caused problems using mypy for type checking because it attempted
to resolve imports such as `mathutils` to the example file.
Having only some examples numbered already complicated documentation
for conventions with examples - simplify extraction and number all.
Add an example with some notes on keymap usage, targeted at add-on
developers.
- Avoid pitfalls, add-on developers sometimes incorrectly modify user
keymaps directly, which persists after the add-on is disabled and
interferes with user preferences.
- Documents subtle/non-obvious requirements.
- Mention edge case regarding modal operator key-maps.
Ref !153111
Add hide_missing keyword argument to temp_override.logging_set().
This reduces noise from members that aren't available in the current
context while still showing members that exist but are empty.
- Add CTX_LogFlag enum with Access and HideMissing flags to control
context member logging behavior during temporary overrides.
- Store & restore original logging with a temporary context so each
context override properly stores & restores the logging options.
Ref !148760
Changes to example code introduced with db88381e75 contains a typo,
using `data block` instead of the standard `data-block`.
This changes ensures consistency with the spelling of `data-block` with
other API example files.
Pull Request: https://projects.blender.org/blender/blender/pulls/151850
This patch standardizes ellipses on labels that require further input
from the user before running the operator as per our
HIG.
- PR does not include buttons (e.g. "Purge" in Outliner) and only
modifies menu items.
- PR does not include operators that wait for input from the user during
modal operation (e.g. `view3d.select_box`, `paint.sample_color`).
- Some usage of ellipses were removed since they were only present to
indicate the start of the sentence (to be finished by submenu items).
E.g. "Make Local...", "Sort Elements...", "Move..." do not require extra
input from the user.
Pull Request: https://projects.blender.org/blender/blender/pulls/150950
644fb2b679 fixed a long standing issue
that offscreen example showed the wrong colors. However the fix assumes
that input texture color space is always sRGB.
This adds a shader variation that draws textures that are stored in scene referred
linear color space (like all of our Image data-block).
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/147788
Add a new section to the `Context` page that includes an explanation
on how to invoke "on demand" logging for context member access.
Design task: #144746
Logging added in: !144810
Ref !146862
The grid layout for UI lists wasn't used in practice from all we can
tell. It was badly maintained for a long time (bugs went unnoticed). I
think it was added for an earlier version of the asset UI design.
This was planned for removal in 5.0, see blender/blender#110461.
Usages in bundled scripts were already removed in efa8d942b8.
Pull Request: https://projects.blender.org/blender/blender/pulls/146656
"Use Nodes" was removed in the compositor to simplify the compositing
workflow. This introduced a slight inconsistency with the Shader Node
Editor.
This PR removes "Use Nodes" for object materials.
For Line Style, no changes are planned (not sure how to preserve
compatibility yet).
This simplifies the state of objects; either they have a material or
they don't.
Backward compatibility:
- If Use Nodes is turned Off, new nodes are added to the node tree to
simulate the same material:
- DNA: Only `use_nodes` is marked deprecated
- Python API:
- `material.use_nodes` is marked deprecated and will be removed in
6.0. Reading it always returns `True` and setting it has no effect.
- `material.diffuse_color`, `material.specular` etc.. Are not used by
EEVEE anymore but are kept because they are used by Workbench.
Forward compatibility:
Always enable 'Use Nodes' when writing blend files.
Known Issues:
Some UI tests are failing on macOS
Pull Request: https://projects.blender.org/blender/blender/pulls/141278
This makes the shader node inlining from #141936 available to external renderers
which use the Python API. Existing external renderer add-ons need to be updated
to get the inlined node tree from a material like below instead of using the
original node tree of the material directly.
The main contribution are these three methods: `Material.inline_shader_nodes()`,
`Light.inline_shader_nodes()` and `World.inline_shader_nodes()`.
In theory, there could be an inlining API for node trees more generally, but
some aspects of the inlining are specific to shader nodes currently. For example
the detection of output nodes and implicit input handling. Furthermore, having
the method on e.g. `Material` instead of on the node tree might be more future
proof for the case when we want to store input properties of the material on the
`Material` which are then passed into the shader node tree.
Example from API docs:
```python
import bpy
# The materials should be retrieved from the evaluated object to make sure that
# e.g. edits of Geometry Nodes are applied.
depsgraph = bpy.context.view_layer.depsgraph
ob = bpy.context.active_object
ob_eval = depsgraph.id_eval_get(ob)
material_eval = ob_eval.material_slots[0].material
# Compute the inlined shader nodes.
# Important: Do not loose the reference to this object while accessing the inlined
# node tree. Otherwise there will be a crash due to a dangling pointer.
inline_shader_nodes = material_eval.inline_shader_nodes()
# Get the actual inlined `bpy.types.NodeTree`.
tree = inline_shader_nodes.node_tree
for node in tree.nodes:
print(node.name)
```
Pull Request: https://projects.blender.org/blender/blender/pulls/145811
Fix several documentation related typos.
Found via `codespell -S "*.desktop,*.diff,./intern,./extern,./locale,./AUTHORS,./source/blender/blenlib/tests/BLI_string_utf8_test.cc,./doc/license/bf-members.txt" -L accessort,abd,aci,alo,ans,ba,bording,childrens,clen,constructin,datas,dependees,domin,eary,ege,eiter,elemt,eles,endianess,enew,espace,finded,fiter,fpt,groupd,hist,implementating,indext,ine,infront,inout,inouts,inpt,ist,lene,listenter,lod,maks,masia,mata,mis,mke,nam,nd,ned,opose,ot,outlow,parm,parms,passt,pinter,pixelx,poin,pres,ptd,re-usable,re-use,re-used,re-uses,re-using,ridiculus,schem,soler,strack,suh,te,tesselate,tham,ue,vai,varius,wew`
Pull Request: https://projects.blender.org/blender/blender/pulls/145824
Added the following notes to documentation:
- `msgbus` interaction with undo system that particularly makes
it not completely reliable, since users they easily skip it's effect.
- Details on when and how often message bus updates are triggered.
Pull Request: https://projects.blender.org/blender/blender/pulls/138557
This PR adds builtin shaders for drawing points. Using `FLAT_COLOR`,
`SMOOTH_COLOR`, `UNIFORM_COLOR` can lead to undesired behavior
on Metal and Vulkan backends. To ensure future compatibility this PR
adds `POINT_FLAT_COLOR` and `POINT_UNIFORM_COLOR`.
The point size can be set using `gpu.state.point_size_set`.
Pull Request: https://projects.blender.org/blender/blender/pulls/139583
When submitting #135854 I've assumed that `RuntimeError` is
connected particularly to `{'CANCELLED'}` return status. Turned
out error is raised regardless of what return status is and it's
only based on the presence of error reports during operator
execution. Submitting a clarification for this.
Pull Request: https://projects.blender.org/blender/blender/pulls/138558