Page MenuHome

Nodes: Add Float Curve
ClosedPublic

Authored by Charlie Jolly (charlie) on Sep 29 2021, 12:38 AM.

Details

Summary

Add Float Curve for GN and Shader nodes.

Possible replacement for Attribute Curve Map node.

Uses code for Vector Curves as a basis with some minor adjustments.
Lookup data is still stored as XYZ with only the X channel used.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 17462
Build 17462: arc lint + arc unit

Event Timeline

Charlie Jolly (charlie) requested review of this revision.Sep 29 2021, 12:38 AM
Charlie Jolly (charlie) created this revision.

A couple comments:

  • I wonder about whether this should be a function node or a shader node. I think the idea was to use the function node for the "simple" nodes that could have an implementation for different contexts.
  • The socket name should be "Factor" rather than "Fac". This is something we want to change with versioning on other nodes too.

Fix factor interpolation on GN.
Use node label to change socket to "Factor".
Cycles is using "Fac" internally and would need versioning which can happen later.

Jacques Lucke (JacquesLucke) requested changes to this revision.Sep 29 2021, 3:39 PM

I get a compiler error currently:

home/jacques/blender-git/blender/intern/cycles/render/nodes.cpp
In file included from /home/jacques/blender-git/blender/intern/cycles/render/../util/util_types.h:28,
                 from /home/jacques/blender-git/blender/intern/cycles/render/../util/util_aligned_malloc.h:20,
                 from /home/jacques/blender-git/blender/intern/cycles/render/../util/util_array.h:23,
                 from /home/jacques/blender-git/blender/intern/cycles/render/../graph/node_type.h:20,
                 from /home/jacques/blender-git/blender/intern/cycles/render/../graph/node.h:21,
                 from /home/jacques/blender-git/blender/intern/cycles/render/../render/nodes.h:20,
                 from /home/jacques/blender-git/blender/intern/cycles/render/nodes.cpp:17:
/home/jacques/blender-git/blender/intern/cycles/render/nodes.cpp: In instantiation of ‘static const ccl::NodeType* ccl::FloatCurveNode::register_type() [with T = ccl::FloatCurveNode]’:
/home/jacques/blender-git/blender/intern/cycles/render/nodes.cpp:6536:1:   required from here
/home/jacques/blender-git/blender/intern/cycles/render/../util/util_defines.h:119:13: error: cannot convert ‘float*’ to ‘ccl::float3*’ in assignment
  119 |       __tmp = (type *)NULL; \
      |             ^
/home/jacques/blender-git/blender/intern/cycles/render/../graph/node_type.h:187:5: note: in expansion of macro ‘CHECK_TYPE’
  187 |     CHECK_TYPE(T::name, datatype); \
      |     ^~~~~~~~~~
/home/jacques/blender-git/blender/intern/cycles/render/../graph/node_type.h:308:3: note: in expansion of macro ‘SOCKET_DEFINE’
  308 |   SOCKET_DEFINE(name, \
      |   ^~~~~~~~~~~~~
/home/jacques/blender-git/blender/intern/cycles/render/nodes.cpp:6545:3: note: in expansion of macro ‘SOCKET_IN_FLOAT’
 6545 |   SOCKET_IN_FLOAT(value, "Value", 0.0f);
      |   ^~~~~~~~~~~~~~~
This revision now requires changes to proceed.Sep 29 2021, 3:39 PM
Brecht Van Lommel (brecht) requested changes to this revision.Sep 29 2021, 3:42 PM

For the Cycles part, this should use a float array instead of float3. It's more code but from the public API point of view it makes no sense to have a float curve node have a float3 array.

Cycles, use float array instead of float3 array.
No compiling error on Windows MSVS 2019.

Whitespace in OSL file

Find from my side.

Got one inline comment, but other than that, looks good.

source/blender/nodes/shader/nodes/node_shader_curves.cc
380

Think we shouldn't have different behavior for geometry nodes for now. If that is asked for in the future, we can add it then. Maybe even make it easier to switch between different ranges.

This revision is now accepted and ready to land.Sep 30 2021, 6:28 PM