mirror of
https://github.com/blender/blender
synced 2026-10-25 03:07:01 +03:00
On the user side it is implemented using extensible socket declaration: user now can add sockets to access attributes. It is done in the node settings panel: adding attribute creates input and output socket. The input socket is a string that denotes attribute to sample, and output socket provides access to the value of the attribute. A little caveat is that Color attribute create 2 sockets: one for color, and another for alpha. This is because color in shader nodes is RGB. Cycles SVM implementation is based on the existing NODE_ATTR SVM node: Raycast generates a set of these nodes and uses existing attribute evaluation on the hit_sd. Cycles OSL implementation required a bit of trickery to make it fit the AOT type of shader compilation. The node_raycast() shader outputs attributes as arrays, and there are extra converter shaders compiled dynamically to convert those arrays to individual values that could be addressed by the nodes that use those attribute sockets. There is a limitation: there could be only up to 32 or each of the float, alpha, or color/vector attributes. There is also a mechanism now in Cycles for shaders to request global attributes. Without this Cycles will optimize all attributes that are not used by a specific geometry, making it quite tedious to setup in a way that raycast could still access those attributes. Without such mechanism user would have need to add attribute nodes to every shader and mix it in with some low non-zero weight to the output so that it does not get optimized out. The implementation is not really ideal as it might lead to situation when attributes are requested by unused shaders, but it is the best we can do without more global refactor. EEVEE implementation returns 0 for the attributes. It is quite tricky to implement attribute sampling, so for now it is Cycles-only feature. Ref #155590 Pull Request: https://projects.blender.org/blender/blender/pulls/157344
3 lines
129 B
Text
3 lines
129 B
Text
version https://git-lfs.github.com/spec/v1
|
|
oid sha256:7f4ea8d4e05dd586703395cfb58821f3110dd6f220524516203b6c836ae34c1c
|
|
size 7840
|