Changeset View
Standalone View
intern/cycles/render/nodes.h
| Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | public: | ||||
| float3 vector; | float3 vector; | ||||
| TextureMapping tex_mapping; | TextureMapping tex_mapping; | ||||
| }; | }; | ||||
| class RGBToBWNode : public ShaderNode { | class RGBToBWNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(RGBToBWNode) | SHADER_NODE_CLASS(RGBToBWNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
sergey: <Controversiality>
For own projects found it more readable/reliable to use const references… | |||||
Not Done Inline ActionsI don't really see the point of using using references and pointers to distinguish between const and non-const, I rather use it to distinguish between nullable and non-nullable. That way you can train yourself to remember to check for NULL whenever you use ->. But we are not doing that consistently in Cycles at all, so there's not much value in that at the moment and I don't care much which convention we use. brecht: I don't really see the point of using using references and pointers to distinguish between… | |||||
Not Done Inline ActionsThe point is to avoid possible override of external data. It's quite often in code you operate on arguments directly (like, ensuring they're within a range) instead of using temp variables for that. And it's not rare this causes issues, especially when something is passed by reference. The point of NULL-able is valid tho. So we need two types of references! :)
That's what makes me sad. Consistency level is not great :( But let's leave this for another discussion, outside of this patch. sergey: The point is to avoid possible override of external data. It's quite often in code you operate… | |||||
Not Done Inline Actions
Actually the main point about non-const references in C++ is that at the *call site* you can't immediately see if the parameter can be modified by the called function or not. For comparison, when passing by reference in C# the ref keyword is required both in parameter declaration and in the actuall call so it's obvious. Here however it's not much of a problem, especially because even without const all fields of the class are constant. angavrilov: > The point is to avoid possible override of external data.
Actually the main point about non… | |||||
| float3 color; | float3 color; | ||||
| }; | }; | ||||
| class ConvertNode : public ShaderNode { | class ConvertNode : public ShaderNode { | ||||
| public: | public: | ||||
| ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert = false); | ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert = false); | ||||
| SHADER_NODE_BASE_CLASS(ConvertNode) | SHADER_NODE_BASE_CLASS(ConvertNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| SocketType::Type from, to; | SocketType::Type from, to; | ||||
| union { | union { | ||||
| float value_float; | float value_float; | ||||
| int value_int; | int value_int; | ||||
| float3 value_color; | float3 value_color; | ||||
| float3 value_vector; | float3 value_vector; | ||||
| ▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | public: | ||||
| float sharpness; | float sharpness; | ||||
| float texture_blur; | float texture_blur; | ||||
| ClosureType falloff; | ClosureType falloff; | ||||
| }; | }; | ||||
| class EmissionNode : public ShaderNode { | class EmissionNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(EmissionNode) | SHADER_NODE_CLASS(EmissionNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual ClosureType get_closure_type() { return CLOSURE_EMISSION_ID; } | virtual ClosureType get_closure_type() { return CLOSURE_EMISSION_ID; } | ||||
| bool has_surface_emission() { return true; } | bool has_surface_emission() { return true; } | ||||
| float3 color; | float3 color; | ||||
| float strength; | float strength; | ||||
| float surface_mix_weight; | float surface_mix_weight; | ||||
| }; | }; | ||||
| class BackgroundNode : public ShaderNode { | class BackgroundNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(BackgroundNode) | SHADER_NODE_CLASS(BackgroundNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual ClosureType get_closure_type() { return CLOSURE_BACKGROUND_ID; } | virtual ClosureType get_closure_type() { return CLOSURE_BACKGROUND_ID; } | ||||
| float3 color; | float3 color; | ||||
| float strength; | float strength; | ||||
| float surface_mix_weight; | float surface_mix_weight; | ||||
| }; | }; | ||||
| class HoldoutNode : public ShaderNode { | class HoldoutNode : public ShaderNode { | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | virtual int get_feature() { | ||||
| return ShaderNode::get_feature() | NODE_FEATURE_HAIR; | return ShaderNode::get_feature() | NODE_FEATURE_HAIR; | ||||
| } | } | ||||
| }; | }; | ||||
| class ValueNode : public ShaderNode { | class ValueNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(ValueNode) | SHADER_NODE_CLASS(ValueNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| float value; | float value; | ||||
| }; | }; | ||||
| class ColorNode : public ShaderNode { | class ColorNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(ColorNode) | SHADER_NODE_CLASS(ColorNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| float3 value; | float3 value; | ||||
| }; | }; | ||||
| class AddClosureNode : public ShaderNode { | class AddClosureNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(AddClosureNode) | SHADER_NODE_CLASS(AddClosureNode) | ||||
| void constant_fold(const ConstantFolder& folder); | |||||
| }; | }; | ||||
| class MixClosureNode : public ShaderNode { | class MixClosureNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(MixClosureNode) | SHADER_NODE_CLASS(MixClosureNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| float fac; | float fac; | ||||
| }; | }; | ||||
| class MixClosureWeightNode : public ShaderNode { | class MixClosureWeightNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(MixClosureWeightNode); | SHADER_NODE_CLASS(MixClosureWeightNode); | ||||
| float weight; | float weight; | ||||
| float fac; | float fac; | ||||
| }; | }; | ||||
| class InvertNode : public ShaderNode { | class InvertNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(InvertNode) | SHADER_NODE_CLASS(InvertNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float fac; | float fac; | ||||
| float3 color; | float3 color; | ||||
| }; | }; | ||||
| class MixNode : public ShaderNode { | class MixNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(MixNode) | SHADER_NODE_CLASS(MixNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| NodeMix type; | NodeMix type; | ||||
| bool use_clamp; | bool use_clamp; | ||||
| float3 color1; | float3 color1; | ||||
| float3 color2; | float3 color2; | ||||
| float fac; | float fac; | ||||
| }; | }; | ||||
| class CombineRGBNode : public ShaderNode { | class CombineRGBNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(CombineRGBNode) | SHADER_NODE_CLASS(CombineRGBNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float r, g, b; | float r, g, b; | ||||
| }; | }; | ||||
| class CombineHSVNode : public ShaderNode { | class CombineHSVNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(CombineHSVNode) | SHADER_NODE_CLASS(CombineHSVNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float h, s, v; | float h, s, v; | ||||
| }; | }; | ||||
| class CombineXYZNode : public ShaderNode { | class CombineXYZNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(CombineXYZNode) | SHADER_NODE_CLASS(CombineXYZNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float x, y, z; | float x, y, z; | ||||
| }; | }; | ||||
| class GammaNode : public ShaderNode { | class GammaNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(GammaNode) | SHADER_NODE_CLASS(GammaNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_1; } | virtual int get_group() { return NODE_GROUP_LEVEL_1; } | ||||
| float3 color; | float3 color; | ||||
| float gamma; | float gamma; | ||||
| }; | }; | ||||
| class BrightContrastNode : public ShaderNode { | class BrightContrastNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(BrightContrastNode) | SHADER_NODE_CLASS(BrightContrastNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_1; } | virtual int get_group() { return NODE_GROUP_LEVEL_1; } | ||||
| float3 color; | float3 color; | ||||
| float bright; | float bright; | ||||
| float contrast; | float contrast; | ||||
| }; | }; | ||||
| class SeparateRGBNode : public ShaderNode { | class SeparateRGBNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(SeparateRGBNode) | SHADER_NODE_CLASS(SeparateRGBNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float3 color; | float3 color; | ||||
| }; | }; | ||||
| class SeparateHSVNode : public ShaderNode { | class SeparateHSVNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(SeparateHSVNode) | SHADER_NODE_CLASS(SeparateHSVNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float3 color; | float3 color; | ||||
| }; | }; | ||||
| class SeparateXYZNode : public ShaderNode { | class SeparateXYZNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(SeparateXYZNode) | SHADER_NODE_CLASS(SeparateXYZNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float3 vector; | float3 vector; | ||||
| }; | }; | ||||
| class HSVNode : public ShaderNode { | class HSVNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(HSVNode) | SHADER_NODE_CLASS(HSVNode) | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public: | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float wavelength; | float wavelength; | ||||
| }; | }; | ||||
| class BlackbodyNode : public ShaderNode { | class BlackbodyNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(BlackbodyNode) | SHADER_NODE_CLASS(BlackbodyNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float temperature; | float temperature; | ||||
| }; | }; | ||||
| class MathNode : public ShaderNode { | class MathNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(MathNode) | SHADER_NODE_CLASS(MathNode) | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_1; } | virtual int get_group() { return NODE_GROUP_LEVEL_1; } | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| float value1; | float value1; | ||||
| float value2; | float value2; | ||||
| NodeMath type; | NodeMath type; | ||||
| bool use_clamp; | bool use_clamp; | ||||
| }; | }; | ||||
| class NormalNode : public ShaderNode { | class NormalNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(NormalNode) | SHADER_NODE_CLASS(NormalNode) | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_2; } | virtual int get_group() { return NODE_GROUP_LEVEL_2; } | ||||
| float3 direction; | float3 direction; | ||||
| float3 normal; | float3 normal; | ||||
| }; | }; | ||||
| class VectorMathNode : public ShaderNode { | class VectorMathNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(VectorMathNode) | SHADER_NODE_CLASS(VectorMathNode) | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_1; } | virtual int get_group() { return NODE_GROUP_LEVEL_1; } | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| float3 vector1; | float3 vector1; | ||||
| float3 vector2; | float3 vector2; | ||||
| NodeVectorMath type; | NodeVectorMath type; | ||||
| }; | }; | ||||
| class VectorTransformNode : public ShaderNode { | class VectorTransformNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(VectorTransformNode) | SHADER_NODE_CLASS(VectorTransformNode) | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| NodeVectorTransformType type; | NodeVectorTransformType type; | ||||
| NodeVectorTransformConvertSpace convert_from; | NodeVectorTransformConvertSpace convert_from; | ||||
| NodeVectorTransformConvertSpace convert_to; | NodeVectorTransformConvertSpace convert_to; | ||||
| float3 vector; | float3 vector; | ||||
| }; | }; | ||||
| class BumpNode : public ShaderNode { | class BumpNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(BumpNode) | SHADER_NODE_CLASS(BumpNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | void constant_fold(const ConstantFolder& folder); | ||||
| bool has_spatial_varying() { return true; } | bool has_spatial_varying() { return true; } | ||||
| virtual int get_feature() { | virtual int get_feature() { | ||||
| return NODE_FEATURE_BUMP; | return NODE_FEATURE_BUMP; | ||||
| } | } | ||||
| bool invert; | bool invert; | ||||
| float height; | float height; | ||||
| float sample_center; | float sample_center; | ||||
| ▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines | |||||
<Controversiality>
For own projects found it more readable/reliable to use const references only (so you don't accidentally assign value and so) and for non-const use pointers.
What do you guys think of using such approach in Cycles as well?
</Controversiality>