Blender Git Loki

Git Commits -> Revision 6fdcca8

Revision 6fdcca8 by Alexander Gavrilov (master)
November 3, 2020, 13:35 (GMT)
Materials: add custom object properties as uniform attributes.

This patch allows the user to type a property name into the
Attribute node, which will then output the value of the property
for each individual object, allowing to e.g. customize shaders
by object without duplicating the shader.

In order to make supporting this easier for Eevee, it is necessary
to explicitly choose whether the attribute is varying or uniform
via a dropdown option of the Attribute node. The dropdown also
allows choosing whether instancing should be taken into account.

The Cycles design treats all attributes as one common namespace,
so the Blender interface converts the enum to a name prefix that
can't be entered using keyboard.

In Eevee, the attributes are provided to the shader via a UBO indexed
with resource_id, similar to the existing Object Info data. Unlike it,
however, it is necessary to maintain a separate buffer for every
requested combination of attributes.

This is done using a hash table with the attribute set as the key,
as it is expected that technically different but similar materials
may use the same set of attributes. In addition, in order to minimize
wasted memory, a sparse UBO pool is implemented, so that chunks that
don't contain any data don't have to be allocated.

The back-end Cycles code is already refactored and committed by Brecht.

Differential Revision: https://developer.blender.org/D2057

Commit Details:

Full Hash: 6fdcca8de64cd70f237640b67ce2d0068b918d05
Parent Commit: 91d320e
Lines Changed: +904, -4

25 Modified Paths:

/intern/cycles/blender/blender_object.cpp (+130, -0) (Diff)
/intern/cycles/blender/blender_shader.cpp (+49, -1) (Diff)
/intern/cycles/blender/blender_sync.h (+2, -0) (Diff)
/intern/cycles/blender/blender_util.h (+3, -0) (Diff)
/source/blender/blenlib/BLI_bitmap.h (+1, -1) (Diff)
/source/blender/draw/DRW_engine.h (+2, -0) (Diff)
/source/blender/draw/intern/draw_instance_data.c (+367, -0) (Diff)
/source/blender/draw/intern/draw_instance_data.h (+22, -0) (Diff)
/source/blender/draw/intern/draw_manager.c (+5, -0) (Diff)
/source/blender/draw/intern/draw_manager.h (+16, -0) (Diff)
/source/blender/draw/intern/draw_manager_data.c (+22, -0) (Diff)
/source/blender/draw/intern/draw_manager_exec.c (+18, -0) (Diff)
/source/blender/editors/space_node/drawnode.c (+1, -0) (Diff)
/source/blender/gpu/GPU_material.h (+27, -0) (Diff)
/source/blender/gpu/GPU_shader.h (+3, -0) (Diff)
/source/blender/gpu/GPU_uniform_buffer.h (+1, -0) (Diff)
/source/blender/gpu/GPU_viewport.h (+2, -0) (Diff)
/source/blender/gpu/intern/gpu_codegen.c (+17, -0) (Diff)
/source/blender/gpu/intern/gpu_material.c (+6, -0) (Diff)
/source/blender/gpu/intern/gpu_node_graph.c (+149, -0) (Diff)
/source/blender/gpu/intern/gpu_node_graph.h (+10, -0) (Diff)
/source/blender/gpu/intern/gpu_viewport.c (+3, -0) (Diff)
/source/blender/makesdna/DNA_node_types.h (+9, -0) (Diff)
/source/blender/makesrna/intern/rna_nodetree.c (+28, -0) (Diff)
/source/blender/nodes/shader/nodes/node_shader_attribute.c (+11, -2) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021