Cleanup: Use NODE_STORAGE_FUNCS for compositor nodes

This patches replaces the custom node storage acessor functions from the
viewport compositor code and replaces it with NODE_STORAGE_FUNCS.
This commit is contained in:
Omar Emara 2022-09-02 18:12:31 +02:00
parent 49ca810bf3
commit 719a0378ae
22 changed files with 147 additions and 205 deletions

View File

@ -18,6 +18,8 @@
namespace blender::nodes::node_composite_alpha_over_cc {
NODE_STORAGE_FUNCS(NodeTwoFloats)
static void cmp_node_alphaover_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>(N_("Fac"))
@ -86,7 +88,7 @@ class AlphaOverShaderNode : public ShaderNode {
float get_premultiply_factor()
{
return ((const NodeTwoFloats *)bnode().storage)->x;
return node_storage(bnode()).x;
}
};

View File

@ -21,6 +21,8 @@
namespace blender::nodes::node_composite_bilateralblur_cc {
NODE_STORAGE_FUNCS(NodeBilateralBlurData)
static void cmp_node_bilateralblur_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -94,18 +96,12 @@ class BilateralBlurOperation : public NodeOperation {
int get_blur_radius()
{
return math::ceil(get_node_bilateral_blur_data().iter +
get_node_bilateral_blur_data().sigma_space);
return math::ceil(node_storage(bnode()).iter + node_storage(bnode()).sigma_space);
}
float get_threshold()
{
return get_node_bilateral_blur_data().sigma_color;
}
const NodeBilateralBlurData &get_node_bilateral_blur_data()
{
return *static_cast<const NodeBilateralBlurData *>(bnode().storage);
return node_storage(bnode()).sigma_color;
}
};

View File

@ -22,6 +22,8 @@
namespace blender::nodes::node_composite_bokehimage_cc {
NODE_STORAGE_FUNCS(NodeBokehImage)
static void cmp_node_bokehimage_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Color>(N_("Image"));
@ -66,9 +68,9 @@ class BokehImageOperation : public NodeOperation {
GPU_shader_uniform_1f(shader, "exterior_angle", get_exterior_angle());
GPU_shader_uniform_1f(shader, "rotation", get_rotation());
GPU_shader_uniform_1f(shader, "roundness", get_node_bokeh_image().rounding);
GPU_shader_uniform_1f(shader, "catadioptric", get_node_bokeh_image().catadioptric);
GPU_shader_uniform_1f(shader, "lens_shift", get_node_bokeh_image().lensshift);
GPU_shader_uniform_1f(shader, "roundness", node_storage(bnode()).rounding);
GPU_shader_uniform_1f(shader, "catadioptric", node_storage(bnode()).catadioptric);
GPU_shader_uniform_1f(shader, "lens_shift", node_storage(bnode()).lensshift);
Result &output = get_result("Image");
const Domain domain = compute_domain();
@ -86,16 +88,11 @@ class BokehImageOperation : public NodeOperation {
return Domain(int2(512));
}
const NodeBokehImage &get_node_bokeh_image()
{
return *static_cast<const NodeBokehImage *>(bnode().storage);
}
/* The exterior angle is the angle between each two consecutive vertices of the regular polygon
* from its center. */
float get_exterior_angle()
{
return (M_PI * 2.0f) / get_node_bokeh_image().flaps;
return (M_PI * 2.0f) / node_storage(bnode()).flaps;
}
float get_rotation()
@ -104,7 +101,7 @@ class BokehImageOperation : public NodeOperation {
* y axis, which is 90 degrees minus the angle that it makes with the positive x axis assuming
* the first vertex lies on the positive x axis. */
const float offset = M_PI_2 - get_exterior_angle();
return get_node_bokeh_image().angle - offset;
return node_storage(bnode()).angle - offset;
}
};

View File

@ -23,6 +23,8 @@
namespace blender::nodes::node_composite_boxmask_cc {
NODE_STORAGE_FUNCS(NodeBoxMask)
static void cmp_node_boxmask_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>(N_("Mask")).default_value(0.0f).min(0.0f).max(1.0f);
@ -123,24 +125,19 @@ class BoxMaskOperation : public NodeOperation {
}
}
const NodeBoxMask &get_node_box_mask()
{
return *static_cast<const NodeBoxMask *>(bnode().storage);
}
float2 get_location()
{
return float2(get_node_box_mask().x, get_node_box_mask().y);
return float2(node_storage(bnode()).x, node_storage(bnode()).y);
}
float2 get_size()
{
return float2(get_node_box_mask().width, get_node_box_mask().height);
return float2(node_storage(bnode()).width, node_storage(bnode()).height);
}
float get_angle()
{
return get_node_box_mask().rotation;
return node_storage(bnode()).rotation;
}
};

View File

@ -20,6 +20,8 @@
namespace blender::nodes::node_composite_channel_matte_cc {
NODE_STORAGE_FUNCS(NodeChroma)
static void cmp_node_channel_matte_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -130,15 +132,10 @@ class ChannelMatteShaderNode : public ShaderNode {
return bnode().custom2 - 1;
}
const NodeChroma *get_node_chroma()
{
return static_cast<const NodeChroma *>(bnode().storage);
}
/* Get the index of the channel used to compute the limit value. */
int get_limit_channel()
{
return get_node_chroma()->channel - 1;
return node_storage(bnode()).channel - 1;
}
/* Get the indices of the channels used to compute the limit value. We always assume the limit
@ -146,7 +143,7 @@ class ChannelMatteShaderNode : public ShaderNode {
* the maximum of two identical values is the same value. */
void get_limit_channels(float limit_channels[2])
{
if (get_node_chroma()->algorithm == CMP_NODE_CHANNEL_MATTE_LIMIT_ALGORITHM_MAX) {
if (node_storage(bnode()).algorithm == CMP_NODE_CHANNEL_MATTE_LIMIT_ALGORITHM_MAX) {
/* If the algorithm is Max, store the indices of the other two channels other than the matte
* channel. */
limit_channels[0] = (get_matte_channel() + 1) % 3;
@ -161,12 +158,12 @@ class ChannelMatteShaderNode : public ShaderNode {
float get_max_limit()
{
return get_node_chroma()->t1;
return node_storage(bnode()).t1;
}
float get_min_limit()
{
return get_node_chroma()->t2;
return node_storage(bnode()).t2;
}
};

View File

@ -22,6 +22,8 @@
namespace blender::nodes::node_composite_chroma_matte_cc {
NODE_STORAGE_FUNCS(NodeChroma)
static void cmp_node_chroma_matte_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -86,24 +88,19 @@ class ChromaMatteShaderNode : public ShaderNode {
GPU_uniform(&falloff));
}
const NodeChroma *get_node_chroma()
{
return static_cast<const NodeChroma *>(bnode().storage);
}
float get_acceptance()
{
return std::tan(get_node_chroma()->t1) / 2.0f;
return std::tan(node_storage(bnode()).t1) / 2.0f;
}
float get_cutoff()
{
return get_node_chroma()->t2;
return node_storage(bnode()).t2;
}
float get_falloff()
{
return get_node_chroma()->fstrength;
return node_storage(bnode()).fstrength;
}
};

View File

@ -18,6 +18,8 @@
namespace blender::nodes::node_composite_color_matte_cc {
NODE_STORAGE_FUNCS(NodeChroma)
static void cmp_node_color_matte_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -83,25 +85,20 @@ class ColorMatteShaderNode : public ShaderNode {
GPU_uniform(&value_epsilon));
}
const NodeChroma *get_node_chroma()
{
return static_cast<const NodeChroma *>(bnode().storage);
}
float get_hue_epsilon()
{
/* Divide by 2 because the hue wraps around. */
return get_node_chroma()->t1 / 2.0f;
return node_storage(bnode()).t1 / 2.0f;
}
float get_saturation_epsilon()
{
return get_node_chroma()->t2;
return node_storage(bnode()).t2;
}
float get_value_epsilon()
{
return get_node_chroma()->t3;
return node_storage(bnode()).t3;
}
};

View File

@ -20,6 +20,8 @@
namespace blender::nodes::node_composite_color_spill_cc {
NODE_STORAGE_FUNCS(NodeColorspill)
static void cmp_node_color_spill_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -131,18 +133,13 @@ class ColorSpillShaderNode : public ShaderNode {
return (CMPNodeColorSpillLimitAlgorithm)bnode().custom2;
}
const NodeColorspill *get_node_color_spill()
{
return static_cast<const NodeColorspill *>(bnode().storage);
}
void get_spill_scale(float spill_scale[3])
{
const NodeColorspill *node_color_spill = get_node_color_spill();
if (node_color_spill->unspill) {
spill_scale[0] = node_color_spill->uspillr;
spill_scale[1] = node_color_spill->uspillg;
spill_scale[2] = node_color_spill->uspillb;
const NodeColorspill &node_color_spill = node_storage(bnode());
if (node_color_spill.unspill) {
spill_scale[0] = node_color_spill.uspillr;
spill_scale[1] = node_color_spill.uspillg;
spill_scale[2] = node_color_spill.uspillb;
spill_scale[get_spill_channel()] *= -1.0f;
}
else {
@ -156,7 +153,7 @@ class ColorSpillShaderNode : public ShaderNode {
/* Get the index of the channel used for limiting. */
int get_limit_channel()
{
return get_node_color_spill()->limchan;
return node_storage(bnode()).limchan;
}
/* Get the indices of the channels used to compute the limit value. We always assume the limit
@ -179,7 +176,7 @@ class ColorSpillShaderNode : public ShaderNode {
float get_limit_scale()
{
return get_node_color_spill()->limscale;
return node_storage(bnode()).limscale;
}
};

View File

@ -48,6 +48,8 @@ void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node)
namespace blender::nodes::node_composite_colorbalance_cc {
NODE_STORAGE_FUNCS(NodeColorBalance)
static void cmp_node_colorbalance_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>(N_("Fac"))
@ -161,7 +163,7 @@ class ColorBalanceShaderNode : public ShaderNode {
GPUNodeStack *inputs = get_inputs_array();
GPUNodeStack *outputs = get_outputs_array();
const NodeColorBalance *node_color_balance = get_node_color_balance();
const NodeColorBalance &node_color_balance = node_storage(bnode());
if (get_color_balance_method() == CMP_NODE_COLOR_BALANCE_LGG) {
GPU_stack_link(material,
@ -169,9 +171,9 @@ class ColorBalanceShaderNode : public ShaderNode {
"node_composite_color_balance_lgg",
inputs,
outputs,
GPU_uniform(node_color_balance->lift),
GPU_uniform(node_color_balance->gamma),
GPU_uniform(node_color_balance->gain));
GPU_uniform(node_color_balance.lift),
GPU_uniform(node_color_balance.gamma),
GPU_uniform(node_color_balance.gain));
return;
}
@ -180,21 +182,16 @@ class ColorBalanceShaderNode : public ShaderNode {
"node_composite_color_balance_asc_cdl",
inputs,
outputs,
GPU_uniform(node_color_balance->offset),
GPU_uniform(node_color_balance->power),
GPU_uniform(node_color_balance->slope),
GPU_uniform(&node_color_balance->offset_basis));
GPU_uniform(node_color_balance.offset),
GPU_uniform(node_color_balance.power),
GPU_uniform(node_color_balance.slope),
GPU_uniform(&node_color_balance.offset_basis));
}
CMPNodeColorBalanceMethod get_color_balance_method()
{
return (CMPNodeColorBalanceMethod)bnode().custom1;
}
const NodeColorBalance *get_node_color_balance()
{
return static_cast<const NodeColorBalance *>(bnode().storage);
}
};
static ShaderNode *get_compositor_shader_node(DNode node)

View File

@ -20,6 +20,8 @@
namespace blender::nodes::node_composite_colorcorrection_cc {
NODE_STORAGE_FUNCS(NodeColorCorrection)
static void cmp_node_colorcorrection_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -294,7 +296,7 @@ class ColorCorrectionShaderNode : public ShaderNode {
float luminance_coefficients[3];
IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
const NodeColorCorrection *node_color_correction = get_node_color_correction();
const NodeColorCorrection &node_color_correction = node_storage(bnode());
GPU_stack_link(material,
&bnode(),
@ -302,28 +304,28 @@ class ColorCorrectionShaderNode : public ShaderNode {
inputs,
outputs,
GPU_constant(enabled_channels),
GPU_uniform(&node_color_correction->startmidtones),
GPU_uniform(&node_color_correction->endmidtones),
GPU_uniform(&node_color_correction->master.saturation),
GPU_uniform(&node_color_correction->master.contrast),
GPU_uniform(&node_color_correction->master.gamma),
GPU_uniform(&node_color_correction->master.gain),
GPU_uniform(&node_color_correction->master.lift),
GPU_uniform(&node_color_correction->shadows.saturation),
GPU_uniform(&node_color_correction->shadows.contrast),
GPU_uniform(&node_color_correction->shadows.gamma),
GPU_uniform(&node_color_correction->shadows.gain),
GPU_uniform(&node_color_correction->shadows.lift),
GPU_uniform(&node_color_correction->midtones.saturation),
GPU_uniform(&node_color_correction->midtones.contrast),
GPU_uniform(&node_color_correction->midtones.gamma),
GPU_uniform(&node_color_correction->midtones.gain),
GPU_uniform(&node_color_correction->midtones.lift),
GPU_uniform(&node_color_correction->highlights.saturation),
GPU_uniform(&node_color_correction->highlights.contrast),
GPU_uniform(&node_color_correction->highlights.gamma),
GPU_uniform(&node_color_correction->highlights.gain),
GPU_uniform(&node_color_correction->highlights.lift),
GPU_uniform(&node_color_correction.startmidtones),
GPU_uniform(&node_color_correction.endmidtones),
GPU_uniform(&node_color_correction.master.saturation),
GPU_uniform(&node_color_correction.master.contrast),
GPU_uniform(&node_color_correction.master.gamma),
GPU_uniform(&node_color_correction.master.gain),
GPU_uniform(&node_color_correction.master.lift),
GPU_uniform(&node_color_correction.shadows.saturation),
GPU_uniform(&node_color_correction.shadows.contrast),
GPU_uniform(&node_color_correction.shadows.gamma),
GPU_uniform(&node_color_correction.shadows.gain),
GPU_uniform(&node_color_correction.shadows.lift),
GPU_uniform(&node_color_correction.midtones.saturation),
GPU_uniform(&node_color_correction.midtones.contrast),
GPU_uniform(&node_color_correction.midtones.gamma),
GPU_uniform(&node_color_correction.midtones.gain),
GPU_uniform(&node_color_correction.midtones.lift),
GPU_uniform(&node_color_correction.highlights.saturation),
GPU_uniform(&node_color_correction.highlights.contrast),
GPU_uniform(&node_color_correction.highlights.gamma),
GPU_uniform(&node_color_correction.highlights.gain),
GPU_uniform(&node_color_correction.highlights.lift),
GPU_constant(luminance_coefficients));
}
@ -333,11 +335,6 @@ class ColorCorrectionShaderNode : public ShaderNode {
enabled_channels[i] = (bnode().custom1 & (1 << i)) ? 1.0f : 0.0f;
}
}
const NodeColorCorrection *get_node_color_correction()
{
return static_cast<const NodeColorCorrection *>(bnode().storage);
}
};
static ShaderNode *get_compositor_shader_node(DNode node)

View File

@ -27,6 +27,8 @@
namespace blender::nodes::node_composite_crop_cc {
NODE_STORAGE_FUNCS(NodeTwoXYs)
static void cmp_node_crop_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -163,11 +165,6 @@ class CropOperation : public NodeOperation {
return bnode().custom2;
}
const NodeTwoXYs &get_node_two_xys()
{
return *static_cast<const NodeTwoXYs *>(bnode().storage);
}
/* Returns true if the operation does nothing and the input can be passed through. */
bool is_identity()
{
@ -190,7 +187,7 @@ class CropOperation : public NodeOperation {
void compute_cropping_bounds(int2 &lower_bound, int2 &upper_bound)
{
const NodeTwoXYs &node_two_xys = get_node_two_xys();
const NodeTwoXYs &node_two_xys = node_storage(bnode());
const int2 input_size = get_input("Image").domain().size;
if (get_is_relative()) {

View File

@ -18,6 +18,8 @@
namespace blender::nodes::node_composite_diff_matte_cc {
NODE_STORAGE_FUNCS(NodeChroma)
static void cmp_node_diff_matte_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image 1"))
@ -71,19 +73,14 @@ class DifferenceMatteShaderNode : public ShaderNode {
GPU_uniform(&falloff));
}
const NodeChroma *get_node_chroma()
{
return static_cast<const NodeChroma *>(bnode().storage);
}
float get_tolerance()
{
return get_node_chroma()->t1;
return node_storage(bnode()).t1;
}
float get_falloff()
{
return get_node_chroma()->t2;
return node_storage(bnode()).t2;
}
};

View File

@ -22,6 +22,8 @@
namespace blender::nodes::node_composite_directionalblur_cc {
NODE_STORAGE_FUNCS(NodeDBlurData)
static void cmp_node_directional_blur_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -109,28 +111,27 @@ class DirectionalBlurOperation : public NodeOperation {
float2 get_translation()
{
const float diagonal_length = math::length(float2(get_input("Image").domain().size));
const float translation_amount = diagonal_length * get_node_directional_blur_data().distance;
const float3x3 rotation = float3x3::from_rotation(-get_node_directional_blur_data().angle);
const float translation_amount = diagonal_length * node_storage(bnode()).distance;
const float3x3 rotation = float3x3::from_rotation(-node_storage(bnode()).angle);
return rotation * float2(-translation_amount / get_iterations(), 0.0f);
}
/* Get the amount of rotation that will be applied on each iteration. */
float get_rotation()
{
return get_node_directional_blur_data().spin / get_iterations();
return node_storage(bnode()).spin / get_iterations();
}
/* Get the amount of scale that will be applied on each iteration. The scale is identity when the
* user supplies 0, so we add 1. */
float2 get_scale()
{
return float2(1.0f + get_node_directional_blur_data().zoom / get_iterations());
return float2(1.0f + node_storage(bnode()).zoom / get_iterations());
}
float2 get_origin()
{
const float2 center = float2(get_node_directional_blur_data().center_x,
get_node_directional_blur_data().center_y);
const float2 center = float2(node_storage(bnode()).center_x, node_storage(bnode()).center_y);
return float2(get_input("Image").domain().size) * center;
}
@ -151,7 +152,7 @@ class DirectionalBlurOperation : public NodeOperation {
* is the number of diagonal pixels. */
int get_iterations()
{
const int iterations = 2 << (get_node_directional_blur_data().iter - 1);
const int iterations = 2 << (node_storage(bnode()).iter - 1);
const int upper_limit = math::ceil(math::length(float2(get_input("Image").domain().size)));
return math::min(iterations, upper_limit);
}
@ -166,25 +167,20 @@ class DirectionalBlurOperation : public NodeOperation {
}
/* If any of the following options are non-zero, then the operation is not an identity. */
if (get_node_directional_blur_data().distance != 0.0f) {
if (node_storage(bnode()).distance != 0.0f) {
return false;
}
if (get_node_directional_blur_data().spin != 0.0f) {
if (node_storage(bnode()).spin != 0.0f) {
return false;
}
if (get_node_directional_blur_data().zoom != 0.0f) {
if (node_storage(bnode()).zoom != 0.0f) {
return false;
}
return true;
}
const NodeDBlurData &get_node_directional_blur_data()
{
return *static_cast<const NodeDBlurData *>(bnode().storage);
}
};
static NodeOperation *get_compositor_operation(Context &context, DNode node)

View File

@ -18,6 +18,8 @@
namespace blender::nodes::node_composite_distance_matte_cc {
NODE_STORAGE_FUNCS(NodeChroma)
static void cmp_node_distance_matte_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -90,24 +92,19 @@ class DistanceMatteShaderNode : public ShaderNode {
GPU_uniform(&falloff));
}
const NodeChroma *get_node_chroma()
{
return static_cast<const NodeChroma *>(bnode().storage);
}
CMPNodeDistanceMatteColorSpace get_color_space()
{
return (CMPNodeDistanceMatteColorSpace)get_node_chroma()->channel;
return (CMPNodeDistanceMatteColorSpace)node_storage(bnode()).channel;
}
float get_tolerance()
{
return get_node_chroma()->t1;
return node_storage(bnode()).t1;
}
float get_falloff()
{
return get_node_chroma()->t2;
return node_storage(bnode()).t2;
}
};

View File

@ -23,6 +23,8 @@
namespace blender::nodes::node_composite_ellipsemask_cc {
NODE_STORAGE_FUNCS(NodeEllipseMask)
static void cmp_node_ellipsemask_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>(N_("Mask")).default_value(0.0f).min(0.0f).max(1.0f);
@ -121,24 +123,19 @@ class EllipseMaskOperation : public NodeOperation {
}
}
const NodeEllipseMask &get_node_ellipse_mask()
{
return *static_cast<const NodeEllipseMask *>(bnode().storage);
}
float2 get_location()
{
return float2(get_node_ellipse_mask().x, get_node_ellipse_mask().y);
return float2(node_storage(bnode()).x, node_storage(bnode()).y);
}
float2 get_size()
{
return float2(get_node_ellipse_mask().width, get_node_ellipse_mask().height);
return float2(node_storage(bnode()).width, node_storage(bnode()).height);
}
float get_angle()
{
return get_node_ellipse_mask().rotation;
return node_storage(bnode()).rotation;
}
};

View File

@ -32,6 +32,8 @@
namespace blender::nodes::node_composite_lensdist_cc {
NODE_STORAGE_FUNCS(NodeLensDist)
static void cmp_node_lensdist_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -197,22 +199,17 @@ class LensDistortionOperation : public NodeOperation {
bool get_is_projector()
{
return get_node_lens_distortion().proj;
return node_storage(bnode()).proj;
}
bool get_is_jitter()
{
return get_node_lens_distortion().jit;
return node_storage(bnode()).jit;
}
bool get_is_fit()
{
return get_node_lens_distortion().fit;
}
NodeLensDist &get_node_lens_distortion()
{
return *static_cast<NodeLensDist *>(bnode().storage);
return node_storage(bnode()).fit;
}
/* Returns true if the operation does nothing and the input can be passed through. */

View File

@ -20,6 +20,8 @@
namespace blender::nodes::node_composite_luma_matte_cc {
NODE_STORAGE_FUNCS(NodeChroma)
static void cmp_node_luma_matte_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -74,19 +76,14 @@ class LuminanceMatteShaderNode : public ShaderNode {
GPU_constant(luminance_coefficients));
}
NodeChroma *get_node_chroma()
{
return static_cast<NodeChroma *>(bnode().storage);
}
float get_high()
{
return get_node_chroma()->t1;
return node_storage(bnode()).t1;
}
float get_low()
{
return get_node_chroma()->t2;
return node_storage(bnode()).t2;
}
};

View File

@ -22,6 +22,8 @@
namespace blender::nodes::node_composite_map_value_cc {
NODE_STORAGE_FUNCS(TexMapping)
static void cmp_node_map_value_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>(N_("Value"))
@ -69,7 +71,7 @@ class MapValueShaderNode : public ShaderNode {
GPUNodeStack *inputs = get_inputs_array();
GPUNodeStack *outputs = get_outputs_array();
const TexMapping *texture_mapping = get_texture_mapping();
const TexMapping &texture_mapping = node_storage(bnode());
const float use_min = get_use_min();
const float use_max = get_use_max();
@ -79,27 +81,22 @@ class MapValueShaderNode : public ShaderNode {
"node_composite_map_value",
inputs,
outputs,
GPU_uniform(texture_mapping->loc),
GPU_uniform(texture_mapping->size),
GPU_uniform(texture_mapping.loc),
GPU_uniform(texture_mapping.size),
GPU_constant(&use_min),
GPU_uniform(texture_mapping->min),
GPU_uniform(texture_mapping.min),
GPU_constant(&use_max),
GPU_uniform(texture_mapping->max));
}
const TexMapping *get_texture_mapping()
{
return static_cast<const TexMapping *>(bnode().storage);
GPU_uniform(texture_mapping.max));
}
bool get_use_min()
{
return get_texture_mapping()->flag & TEXMAP_CLIP_MIN;
return node_storage(bnode()).flag & TEXMAP_CLIP_MIN;
}
bool get_use_max()
{
return get_texture_mapping()->flag & TEXMAP_CLIP_MAX;
return node_storage(bnode()).flag & TEXMAP_CLIP_MAX;
}
};

View File

@ -239,7 +239,7 @@ class MovieClipOperation : public NodeOperation {
GPUTexture *get_movie_clip_texture()
{
MovieClip *movie_clip = get_movie_clip();
MovieClipUser *movie_clip_user = static_cast<MovieClipUser *>(bnode().storage);
MovieClipUser *movie_clip_user = get_movie_clip_user();
BKE_movieclip_user_set_frame(movie_clip_user, context().get_frame_number());
return BKE_movieclip_get_gpu_texture(movie_clip, movie_clip_user);
}
@ -256,6 +256,11 @@ class MovieClipOperation : public NodeOperation {
{
return (MovieClip *)bnode().id;
}
MovieClipUser *get_movie_clip_user()
{
return static_cast<MovieClipUser *>(bnode().storage);
}
};
static NodeOperation *get_compositor_operation(Context &context, DNode node)

View File

@ -62,6 +62,8 @@ static void node_cmp_combsep_color_label(const ListBase *sockets, CMPNodeCombSep
namespace blender::nodes::node_composite_separate_color_cc {
NODE_STORAGE_FUNCS(NodeCMPCombSepColor)
static void cmp_node_separate_color_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -93,14 +95,9 @@ class SeparateColorShaderNode : public ShaderNode {
GPU_stack_link(material, &bnode(), get_shader_function_name(), inputs, outputs);
}
NodeCMPCombSepColor *get_node_combine_separate_color()
{
return static_cast<NodeCMPCombSepColor *>(bnode().storage);
}
const char *get_shader_function_name()
{
switch (get_node_combine_separate_color()->mode) {
switch (node_storage(bnode()).mode) {
case CMP_NODE_COMBSEP_COLOR_RGB:
return "node_composite_separate_rgba";
case CMP_NODE_COMBSEP_COLOR_HSV:
@ -110,7 +107,7 @@ class SeparateColorShaderNode : public ShaderNode {
case CMP_NODE_COMBSEP_COLOR_YUV:
return "node_composite_separate_yuva_itu_709";
case CMP_NODE_COMBSEP_COLOR_YCC:
switch (get_node_combine_separate_color()->ycc_mode) {
switch (node_storage(bnode()).ycc_mode) {
case BLI_YCC_ITU_BT601:
return "node_composite_separate_ycca_itu_601";
case BLI_YCC_ITU_BT709:
@ -153,6 +150,8 @@ void register_node_type_cmp_separate_color()
namespace blender::nodes::node_composite_combine_color_cc {
NODE_STORAGE_FUNCS(NodeCMPCombSepColor)
static void cmp_node_combine_color_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>(N_("Red"))
@ -202,14 +201,9 @@ class CombineColorShaderNode : public ShaderNode {
GPU_stack_link(material, &bnode(), get_shader_function_name(), inputs, outputs);
}
NodeCMPCombSepColor *get_node_combine_separate_color()
{
return static_cast<NodeCMPCombSepColor *>(bnode().storage);
}
const char *get_shader_function_name()
{
switch (get_node_combine_separate_color()->mode) {
switch (node_storage(bnode()).mode) {
case CMP_NODE_COMBSEP_COLOR_RGB:
return "node_composite_combine_rgba";
case CMP_NODE_COMBSEP_COLOR_HSV:
@ -219,7 +213,7 @@ class CombineColorShaderNode : public ShaderNode {
case CMP_NODE_COMBSEP_COLOR_YUV:
return "node_composite_combine_yuva_itu_709";
case CMP_NODE_COMBSEP_COLOR_YCC:
switch (get_node_combine_separate_color()->ycc_mode) {
switch (node_storage(bnode()).ycc_mode) {
case BLI_YCC_ITU_BT601:
return "node_composite_combine_ycca_itu_601";
case BLI_YCC_ITU_BT709:

View File

@ -18,6 +18,8 @@
namespace blender::nodes::node_composite_setalpha_cc {
NODE_STORAGE_FUNCS(NodeSetAlpha)
static void cmp_node_setalpha_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -54,18 +56,13 @@ class SetAlphaShaderNode : public ShaderNode {
GPUNodeStack *inputs = get_inputs_array();
GPUNodeStack *outputs = get_outputs_array();
if (get_node_set_alpha()->mode == CMP_NODE_SETALPHA_MODE_APPLY) {
if (node_storage(bnode()).mode == CMP_NODE_SETALPHA_MODE_APPLY) {
GPU_stack_link(material, &bnode(), "node_composite_set_alpha_apply", inputs, outputs);
return;
}
GPU_stack_link(material, &bnode(), "node_composite_set_alpha_replace", inputs, outputs);
}
const NodeSetAlpha *get_node_set_alpha()
{
return static_cast<const NodeSetAlpha *>(bnode().storage);
}
};
static ShaderNode *get_compositor_shader_node(DNode node)

View File

@ -19,6 +19,8 @@
namespace blender::nodes::node_composite_translate_cc {
NODE_STORAGE_FUNCS(NodeTranslateData)
static void cmp_node_translate_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>(N_("Image"))
@ -76,24 +78,19 @@ class TranslateOperation : public NodeOperation {
result.get_realization_options().repeat_y = get_repeat_y();
}
const NodeTranslateData &get_node_translate()
{
return *static_cast<const NodeTranslateData *>(bnode().storage);
}
bool get_use_relative()
{
return get_node_translate().relative;
return node_storage(bnode()).relative;
}
bool get_repeat_x()
{
return ELEM(get_node_translate().wrap_axis, CMP_NODE_WRAP_X, CMP_NODE_WRAP_XY);
return ELEM(node_storage(bnode()).wrap_axis, CMP_NODE_WRAP_X, CMP_NODE_WRAP_XY);
}
bool get_repeat_y()
{
return ELEM(get_node_translate().wrap_axis, CMP_NODE_WRAP_Y, CMP_NODE_WRAP_XY);
return ELEM(node_storage(bnode()).wrap_axis, CMP_NODE_WRAP_Y, CMP_NODE_WRAP_XY);
}
};