Blender  V3.3
node_shader_vector_displacement.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
4 #include "node_shader_util.hh"
5 
7 
9 {
10  b.add_input<decl::Color>(N_("Vector")).hide_value();
11  b.add_input<decl::Float>(N_("Midlevel")).default_value(0.0f).min(0.0f).max(1000.0f);
12  b.add_input<decl::Float>(N_("Scale")).default_value(1.0f).min(0.0f).max(1000.0f);
13  b.add_output<decl::Vector>(N_("Displacement"));
14 }
15 
17 {
18  node->custom1 = SHD_SPACE_TANGENT; /* space */
19 }
20 
22  bNode *node,
23  bNodeExecData *UNUSED(execdata),
24  GPUNodeStack *in,
26 {
27  switch (node->custom1) {
28  case SHD_SPACE_TANGENT:
29  return GPU_stack_link(mat,
30  node,
31  "node_vector_displacement_tangent",
32  in,
33  out,
34  GPU_attribute(mat, CD_TANGENT, ""));
35  case SHD_SPACE_OBJECT:
36  return GPU_stack_link(mat, node, "node_vector_displacement_object", in, out);
37  case SHD_SPACE_WORLD:
38  default:
39  return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out);
40  }
41 }
42 
43 } // namespace blender::nodes::node_shader_vector_displacement_cc
44 
45 /* node type definition */
47 {
49 
50  static bNodeType ntype;
51 
53  &ntype, SH_NODE_VECTOR_DISPLACEMENT, "Vector Displacement", NODE_CLASS_OP_VECTOR);
57 
58  nodeRegisterType(&ntype);
59 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4465
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
#define NODE_CLASS_OP_VECTOR
Definition: BKE_node.h:348
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
@ CD_TANGENT
#define SHD_SPACE_WORLD
#define SHD_SPACE_TANGENT
#define SHD_SPACE_OBJECT
GPUNodeLink * GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name)
bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color or the default fallback if none is specified Separate Split a vector into its and Z components Generates normals with round corners and may slow down renders SH_NODE_VECTOR_DISPLACEMENT
OperationNode * node
bNodeTree * ntree
static int gpu_shader_vector_displacement(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_init_vector_displacement(bNodeTree *UNUSED(ntree), bNode *node)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
void register_node_type_sh_vector_displacement()
Defines a node type.
Definition: BKE_node.h:226
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)