This patch implements basic support for evaluating function nodes on volume grids. Conceptually, a function node always creates a new grid for the output, though the output is often a modified version of the input. The topology of the output grid is a union of all the input grids. All input grids have to have the same transform. Otherwise one has to use resampling to make grids compatible. Non-grid inputs are allowed to be single values or fields. The fields are evaluated in a voxel/tile context, so they compute a value per voxel or per tile. One optimization is missing that will probably be key in the future: the ability to merge multiple function nodes and execute them at the same time. Currently the entire function evaluation is started and finished for every function node that outputs a grid. This will add significant overhead in some situations. Implementing this optimization requires some more changes outside of the scope of this patch though. It's good to have something that works first. Note: Not all function nodes are supported yet, because we don't have grid types for all of them yet. Most notably, there are no color/float4 grids yet. Implementing those properly is not super straight forward and may require some more changes, because there isn't a 1-to-1 mapping between grid types and socket types (a float4 grid may correspond to a color or vector socket later on). Using grids with function nodes and fields can result in false positive warnings in the UI currently. That's a limitation of our current socket type inferencing and can be improved once we have better socket shape inferencing. Pull Request: https://projects.blender.org/blender/blender/pulls/125110
35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup nodes
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "FN_multi_function.hh"
|
|
|
|
#include "NOD_geometry_exec.hh"
|
|
|
|
namespace blender::nodes {
|
|
|
|
/**
|
|
* Execute the multi-function with the given parameters. It is assumed that at least one of the
|
|
* inputs is a grid. Otherwise the topology of the output grids is not known.
|
|
*
|
|
* \param fn: The multi-function to call.
|
|
* \param input_values: All input values which may be grids, fields or single values.
|
|
* \param output_values: Where the output grids will be stored.
|
|
* \param r_error_message: An error message that is set if false is returned.
|
|
*
|
|
* \return False if an error occurred. In this case the output values should not be used.
|
|
*/
|
|
[[nodiscard]] bool execute_multi_function_on_value_variant__volume_grid(
|
|
const mf::MultiFunction &fn,
|
|
const Span<SocketValueVariant *> input_values,
|
|
const Span<SocketValueVariant *> output_values,
|
|
std::string &r_error_message);
|
|
|
|
} // namespace blender::nodes
|