blender/intern/cycles/render/nodes.h

529 lines
10 KiB
C
Raw Normal View History

/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __NODES_H__
#define __NODES_H__
#include "graph.h"
#include "util_string.h"
CCL_NAMESPACE_BEGIN
class ImageManager;
class Shader;
/* Texture Mapping */
class TextureMapping {
public:
TextureMapping();
Transform compute_transform();
bool skip();
void compile(SVMCompiler& compiler, int offset_in, int offset_out);
void compile(OSLCompiler &compiler);
float3 translation;
float3 rotation;
float3 scale;
float3 min, max;
bool use_minmax;
enum Mapping { NONE = 0, X = 1, Y = 2, Z = 3 };
Mapping x_mapping, y_mapping, z_mapping;
enum Projection { FLAT, CUBE, TUBE, SPHERE };
Projection projection;
};
/* Nodes */
class TextureNode : public ShaderNode {
public:
TextureNode(const char *name_) : ShaderNode(name_) {}
TextureMapping tex_mapping;
};
class ImageTextureNode : public TextureNode {
public:
SHADER_NODE_NO_CLONE_CLASS(ImageTextureNode)
~ImageTextureNode();
ShaderNode *clone() const;
ImageManager *image_manager;
int slot;
int is_float;
string filename;
Packed and generated images support for Cycles This commit adds support of packed and generated images for Cycles when using SVM backend. Movies are still not supported. This changes also doesn't touch OSL which is much less trivial to adopt for any images which are not saved to disk. Implementation details: - When adding images to Image Manager is now possible to mark image as builtin. Builtin images will bypass OIIO loader and will use special loading callbacks. - Callbacks are set by Blender Session and they're using C++ RNA interface to obtain needed data (pixels, dimensions, is_float flag). - Image Manager assumes file path is used as reference to a builtin images, but in fact currently image datablock name is used for reference. This makes it easy to find an image in BlendData database. - Added some extra properties to Image RNA: * channels, which denotes actual number of channels in ImBuf. This is needed to treat image's pixels correct (before it wasn't possible because API used internal number of channels for pixels which is in fact doesn't correlate with image depth) * is_float, which is truth if image is stored in float buffer of ImBuf. - Implemented string lookup for C++ RNA collections for cases there's no manual lookup function. OSL is not supported because it used own image loading and filtering routines and there's seems to be no API to feed pre-loaded pixels directly to the library. Think we'll either need to add some API to support such kind of feeding or consider OSL does not have support of packed images at all. Movies are not supported at this moment because of lack of RNA API to load specified frame. It's not difficult to solve, just need to consider what to best here: * Either write some general python interface for ImBuf and use it via C++ API, or * Write a PY API function which will return pixels for given frame, or * Use bad-level BKE_* call Anyway, small steps, further improvements later. Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
bool is_builtin;
ustring color_space;
ustring projection;
float projection_blend;
bool animated;
static ShaderEnum color_space_enum;
static ShaderEnum projection_enum;
};
class EnvironmentTextureNode : public TextureNode {
public:
SHADER_NODE_NO_CLONE_CLASS(EnvironmentTextureNode)
~EnvironmentTextureNode();
ShaderNode *clone() const;
ImageManager *image_manager;
int slot;
int is_float;
string filename;
Packed and generated images support for Cycles This commit adds support of packed and generated images for Cycles when using SVM backend. Movies are still not supported. This changes also doesn't touch OSL which is much less trivial to adopt for any images which are not saved to disk. Implementation details: - When adding images to Image Manager is now possible to mark image as builtin. Builtin images will bypass OIIO loader and will use special loading callbacks. - Callbacks are set by Blender Session and they're using C++ RNA interface to obtain needed data (pixels, dimensions, is_float flag). - Image Manager assumes file path is used as reference to a builtin images, but in fact currently image datablock name is used for reference. This makes it easy to find an image in BlendData database. - Added some extra properties to Image RNA: * channels, which denotes actual number of channels in ImBuf. This is needed to treat image's pixels correct (before it wasn't possible because API used internal number of channels for pixels which is in fact doesn't correlate with image depth) * is_float, which is truth if image is stored in float buffer of ImBuf. - Implemented string lookup for C++ RNA collections for cases there's no manual lookup function. OSL is not supported because it used own image loading and filtering routines and there's seems to be no API to feed pre-loaded pixels directly to the library. Think we'll either need to add some API to support such kind of feeding or consider OSL does not have support of packed images at all. Movies are not supported at this moment because of lack of RNA API to load specified frame. It's not difficult to solve, just need to consider what to best here: * Either write some general python interface for ImBuf and use it via C++ API, or * Write a PY API function which will return pixels for given frame, or * Use bad-level BKE_* call Anyway, small steps, further improvements later. Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
bool is_builtin;
ustring color_space;
ustring projection;
bool animated;
static ShaderEnum color_space_enum;
static ShaderEnum projection_enum;
};
class SkyTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(SkyTextureNode)
float3 sun_direction;
float turbidity;
};
class OutputNode : public ShaderNode {
public:
SHADER_NODE_CLASS(OutputNode)
};
class GradientTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(GradientTextureNode)
ustring type;
static ShaderEnum type_enum;
};
class NoiseTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(NoiseTextureNode)
};
class VoronoiTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(VoronoiTextureNode)
ustring coloring;
static ShaderEnum coloring_enum;
};
class MusgraveTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(MusgraveTextureNode)
ustring type;
static ShaderEnum type_enum;
};
class WaveTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(WaveTextureNode)
ustring type;
static ShaderEnum type_enum;
};
class MagicTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(MagicTextureNode)
int depth;
};
class CheckerTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(CheckerTextureNode)
};
class BrickTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(BrickTextureNode)
float offset, squash;
int offset_frequency, squash_frequency;
};
class MappingNode : public ShaderNode {
public:
SHADER_NODE_CLASS(MappingNode)
TextureMapping tex_mapping;
};
class ConvertNode : public ShaderNode {
public:
ConvertNode(ShaderSocketType from, ShaderSocketType to);
SHADER_NODE_BASE_CLASS(ConvertNode)
ShaderSocketType from, to;
};
class ProxyNode : public ShaderNode {
public:
ProxyNode(ShaderSocketType from, ShaderSocketType to);
SHADER_NODE_BASE_CLASS(ProxyNode)
ShaderSocketType from, to;
};
class BsdfNode : public ShaderNode {
public:
SHADER_NODE_CLASS(BsdfNode)
void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL);
ClosureType closure;
};
class WardBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(WardBsdfNode)
void attributes(AttributeRequestSet *attributes);
};
class DiffuseBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(DiffuseBsdfNode)
};
class TranslucentBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(TranslucentBsdfNode)
};
class TransparentBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(TransparentBsdfNode)
bool has_surface_transparent() { return true; }
};
class VelvetBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(VelvetBsdfNode)
};
class GlossyBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(GlossyBsdfNode)
ustring distribution;
static ShaderEnum distribution_enum;
};
class GlassBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(GlassBsdfNode)
ustring distribution;
static ShaderEnum distribution_enum;
};
class RefractionBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(RefractionBsdfNode)
ustring distribution;
static ShaderEnum distribution_enum;
};
class EmissionNode : public ShaderNode {
public:
SHADER_NODE_CLASS(EmissionNode)
bool has_surface_emission() { return true; }
bool total_power;
};
class BackgroundNode : public ShaderNode {
public:
SHADER_NODE_CLASS(BackgroundNode)
};
class HoldoutNode : public ShaderNode {
public:
SHADER_NODE_CLASS(HoldoutNode)
};
class AmbientOcclusionNode : public ShaderNode {
public:
SHADER_NODE_CLASS(AmbientOcclusionNode)
};
class VolumeNode : public ShaderNode {
public:
SHADER_NODE_CLASS(VolumeNode)
void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2);
ClosureType closure;
};
class TransparentVolumeNode : public VolumeNode {
public:
SHADER_NODE_CLASS(TransparentVolumeNode)
};
class IsotropicVolumeNode : public VolumeNode {
public:
SHADER_NODE_CLASS(IsotropicVolumeNode)
};
class GeometryNode : public ShaderNode {
public:
SHADER_NODE_CLASS(GeometryNode)
void attributes(AttributeRequestSet *attributes);
};
class TextureCoordinateNode : public ShaderNode {
public:
SHADER_NODE_CLASS(TextureCoordinateNode)
void attributes(AttributeRequestSet *attributes);
bool from_dupli;
};
class LightPathNode : public ShaderNode {
public:
SHADER_NODE_CLASS(LightPathNode)
};
class LightFalloffNode : public ShaderNode {
public:
SHADER_NODE_CLASS(LightFalloffNode)
};
class ObjectInfoNode : public ShaderNode {
public:
SHADER_NODE_CLASS(ObjectInfoNode)
};
class ParticleInfoNode : public ShaderNode {
public:
SHADER_NODE_CLASS(ParticleInfoNode)
void attributes(AttributeRequestSet *attributes);
};
class HairInfoNode : public ShaderNode {
public:
SHADER_NODE_CLASS(HairInfoNode)
void attributes(AttributeRequestSet *attributes);
};
class ValueNode : public ShaderNode {
public:
SHADER_NODE_CLASS(ValueNode)
float value;
};
class ColorNode : public ShaderNode {
public:
SHADER_NODE_CLASS(ColorNode)
float3 value;
};
class AddClosureNode : public ShaderNode {
public:
SHADER_NODE_CLASS(AddClosureNode)
};
class MixClosureNode : public ShaderNode {
public:
SHADER_NODE_CLASS(MixClosureNode)
};
class MixClosureWeightNode : public ShaderNode {
public:
SHADER_NODE_CLASS(MixClosureWeightNode);
};
class InvertNode : public ShaderNode {
public:
SHADER_NODE_CLASS(InvertNode)
};
class MixNode : public ShaderNode {
public:
SHADER_NODE_CLASS(MixNode)
bool use_clamp;
ustring type;
static ShaderEnum type_enum;
};
class CombineRGBNode : public ShaderNode {
public:
SHADER_NODE_CLASS(CombineRGBNode)
};
class GammaNode : public ShaderNode {
public:
SHADER_NODE_CLASS(GammaNode)
};
class BrightContrastNode : public ShaderNode {
public:
SHADER_NODE_CLASS(BrightContrastNode)
};
class SeparateRGBNode : public ShaderNode {
public:
SHADER_NODE_CLASS(SeparateRGBNode)
};
class HSVNode : public ShaderNode {
public:
SHADER_NODE_CLASS(HSVNode)
};
class AttributeNode : public ShaderNode {
public:
SHADER_NODE_CLASS(AttributeNode)
void attributes(AttributeRequestSet *attributes);
ustring attribute;
};
class CameraNode : public ShaderNode {
public:
SHADER_NODE_CLASS(CameraNode)
};
class FresnelNode : public ShaderNode {
public:
SHADER_NODE_CLASS(FresnelNode)
};
class LayerWeightNode : public ShaderNode {
public:
SHADER_NODE_CLASS(LayerWeightNode)
};
class MathNode : public ShaderNode {
public:
SHADER_NODE_CLASS(MathNode)
bool use_clamp;
ustring type;
static ShaderEnum type_enum;
};
class NormalNode : public ShaderNode {
public:
SHADER_NODE_CLASS(NormalNode)
float3 direction;
};
class VectorMathNode : public ShaderNode {
public:
SHADER_NODE_CLASS(VectorMathNode)
ustring type;
static ShaderEnum type_enum;
};
class BumpNode : public ShaderNode {
public:
SHADER_NODE_CLASS(BumpNode)
};
2012-03-26 12:45:14 +00:00
class RGBCurvesNode : public ShaderNode {
public:
SHADER_NODE_CLASS(RGBCurvesNode)
float4 curves[RAMP_TABLE_SIZE];
};
class VectorCurvesNode : public ShaderNode {
public:
SHADER_NODE_CLASS(VectorCurvesNode)
float4 curves[RAMP_TABLE_SIZE];
};
2012-03-26 12:45:14 +00:00
class RGBRampNode : public ShaderNode {
public:
SHADER_NODE_CLASS(RGBRampNode)
float4 ramp[RAMP_TABLE_SIZE];
};
class SetNormalNode : public ShaderNode {
public:
SHADER_NODE_CLASS(SetNormalNode)
};
class OSLScriptNode : public ShaderNode {
public:
SHADER_NODE_CLASS(OSLScriptNode)
string filepath;
string bytecode_hash;
/* ShaderInput/ShaderOutput only stores a shallow string copy (const char *)!
* The actual socket names have to be stored externally to avoid memory errors. */
vector<ustring> input_names;
vector<ustring> output_names;
};
class NormalMapNode : public ShaderNode {
public:
SHADER_NODE_CLASS(NormalMapNode)
void attributes(AttributeRequestSet *attributes);
ustring space;
static ShaderEnum space_enum;
ustring attribute;
};
class TangentNode : public ShaderNode {
public:
SHADER_NODE_CLASS(TangentNode)
void attributes(AttributeRequestSet *attributes);
ustring direction_type;
static ShaderEnum direction_type_enum;
ustring axis;
static ShaderEnum axis_enum;
ustring attribute;
};
CCL_NAMESPACE_END
#endif /* __NODES_H__ */