Tomato Cycles:
* Added a Brick Texture Node to Cycles. * Based on the Blender Internal Brick Texture with some modifications. * Tested on CPU and GPU (CUDA & OpenCL) Documentation: http://wiki.blender.org/index.php/User:DingTo/CyclesBrickTexture ToDo: Only works correct on flat surfaces, like a Plane. If you attach the shader to 3D objects like a cube, the mapping is not correct on the Y/Z vector. Thanks to Lukas Toenne for fixing a issue I had with the Node code! :)
This commit is contained in:
@@ -379,6 +379,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
else if(string_iequals(node.name(), "checker_texture")) {
|
||||
snode = new CheckerTextureNode();
|
||||
}
|
||||
else if(string_iequals(node.name(), "brick_texture")) {
|
||||
snode = new BrickTextureNode();
|
||||
}
|
||||
else if(string_iequals(node.name(), "gradient_texture")) {
|
||||
GradientTextureNode *blend = new GradientTextureNode();
|
||||
xml_read_enum(&blend->type, GradientTextureNode::type_enum, node, "type");
|
||||
|
||||
@@ -461,6 +461,17 @@ static ShaderNode *add_node(BL::BlendData b_data, BL::Scene b_scene, ShaderGraph
|
||||
node = checker;
|
||||
break;
|
||||
}
|
||||
case BL::ShaderNode::type_TEX_BRICK: {
|
||||
BL::ShaderNodeTexBrick b_brick_node(b_node);
|
||||
BrickTextureNode *brick = new BrickTextureNode();
|
||||
brick->offset = b_brick_node.offset();
|
||||
brick->offset_frequency = b_brick_node.offset_frequency();
|
||||
brick->squash = b_brick_node.squash();
|
||||
brick->squash_frequency = b_brick_node.squash_frequency();
|
||||
get_tex_mapping(&brick->tex_mapping, b_brick_node.texture_mapping());
|
||||
node = brick;
|
||||
break;
|
||||
}
|
||||
case BL::ShaderNode::type_TEX_NOISE: {
|
||||
BL::ShaderNodeTexNoise b_noise_node(b_node);
|
||||
NoiseTextureNode *noise = new NoiseTextureNode();
|
||||
|
||||
@@ -61,6 +61,7 @@ set(SRC_SVM_HEADERS
|
||||
svm/svm_closure.h
|
||||
svm/svm_convert.h
|
||||
svm/svm_checker.h
|
||||
svm/svm_brick.h
|
||||
svm/svm_displace.h
|
||||
svm/svm_fresnel.h
|
||||
svm/svm_gamma.h
|
||||
|
||||
@@ -154,6 +154,7 @@ CCL_NAMESPACE_END
|
||||
#include "svm_value.h"
|
||||
#include "svm_voronoi.h"
|
||||
#include "svm_checker.h"
|
||||
#include "svm_brick.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
@@ -252,6 +253,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
|
||||
case NODE_TEX_CHECKER:
|
||||
svm_node_tex_checker(kg, sd, stack, node, &offset);
|
||||
break;
|
||||
case NODE_TEX_BRICK:
|
||||
svm_node_tex_brick(kg, sd, stack, node, &offset);
|
||||
break;
|
||||
#endif
|
||||
case NODE_CAMERA:
|
||||
svm_node_camera(kg, sd, stack, node.y, node.z, node.w);
|
||||
|
||||
114
intern/cycles/kernel/svm/svm_brick.h
Normal file
114
intern/cycles/kernel/svm/svm_brick.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright 2012, 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.
|
||||
*/
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Brick */
|
||||
|
||||
__device_noinline float brick_noise(int n) /* fast integer noise */
|
||||
{
|
||||
int nn;
|
||||
n = (n >> 13) ^ n;
|
||||
nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
|
||||
return 0.5f * ((float)nn / 1073741824.0f);
|
||||
}
|
||||
|
||||
__device_noinline float svm_brick(float3 p, float scale, float mortar_size, float bias,
|
||||
float brick_width, float row_height, float offset_amount, int offset_frequency,
|
||||
float squash_amount, int squash_frequency, float *tint)
|
||||
{
|
||||
p *= scale;
|
||||
|
||||
int bricknum, rownum;
|
||||
float offset = 0.0f;
|
||||
float x, y;
|
||||
|
||||
rownum = (int)floor(p.y / row_height);
|
||||
|
||||
if(offset_frequency && squash_frequency) {
|
||||
brick_width *= ((int)(rownum) % squash_frequency ) ? 1.0f : squash_amount; /* squash */
|
||||
offset = ((int)(rownum) % offset_frequency ) ? 0 : (brick_width*offset_amount); /* offset */
|
||||
}
|
||||
|
||||
bricknum = (int)floor((p.x+offset) / brick_width);
|
||||
|
||||
x = (p.x+offset) - brick_width*bricknum;
|
||||
y = p.y - row_height*rownum;
|
||||
|
||||
*tint = clamp((brick_noise((rownum << 16) + (bricknum & 0xFFFF)) + bias), 0.0f, 1.0f);
|
||||
|
||||
return (x < mortar_size || y < mortar_size ||
|
||||
x > (brick_width - mortar_size) ||
|
||||
y > (row_height - mortar_size)) ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
__device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
|
||||
{
|
||||
uint4 node2 = read_node(kg, offset);
|
||||
uint4 node3 = read_node(kg, offset);
|
||||
|
||||
/* Input and Output Sockets */
|
||||
uint co_offset, color1_offset, color2_offset, mortar_offset, scale_offset;
|
||||
uint mortar_size_offset, bias_offset, brick_width_offset, row_height_offset;
|
||||
uint color_offset, fac_offset;
|
||||
|
||||
/* RNA properties */
|
||||
uint offset_frequency, squash_frequency;
|
||||
|
||||
float tint = 0;
|
||||
|
||||
decode_node_uchar4(node.y, &co_offset, &color1_offset, &color2_offset, &mortar_offset);
|
||||
decode_node_uchar4(node.z, &scale_offset, &mortar_size_offset, &bias_offset, &brick_width_offset);
|
||||
decode_node_uchar4(node.w, &row_height_offset, &color_offset, &fac_offset, NULL);
|
||||
|
||||
decode_node_uchar4(node2.x, &offset_frequency, &squash_frequency, NULL, NULL);
|
||||
|
||||
float3 co = stack_load_float3(stack, co_offset);
|
||||
|
||||
float3 color1 = stack_load_float3(stack, color1_offset);
|
||||
float3 color2 = stack_load_float3(stack, color2_offset);
|
||||
float3 mortar = stack_load_float3(stack, mortar_offset);
|
||||
|
||||
float scale = stack_load_float_default(stack, scale_offset, node2.y);
|
||||
float mortar_size = stack_load_float_default(stack, mortar_size_offset, node2.z);
|
||||
float bias = stack_load_float_default(stack, bias_offset, node2.w);
|
||||
float brick_width = stack_load_float_default(stack, brick_width_offset, node3.x);
|
||||
float row_height = stack_load_float_default(stack, row_height_offset, node3.y);
|
||||
float offset_amount = __int_as_float(node3.z);
|
||||
float squash_amount = __int_as_float(node3.w);
|
||||
|
||||
float f = svm_brick(co, scale, mortar_size, bias, brick_width, row_height,
|
||||
offset_amount, offset_frequency, squash_amount, squash_frequency,
|
||||
&tint);
|
||||
|
||||
if(f != 1.0f) {
|
||||
float facm = 1.0f - tint;
|
||||
|
||||
color1.x = facm * (color1.x) + tint * color2.x;
|
||||
color1.y = facm * (color1.y) + tint * color2.y;
|
||||
color1.z = facm * (color1.z) + tint * color2.z;
|
||||
}
|
||||
|
||||
if(stack_valid(color_offset))
|
||||
stack_store_float3(stack, color_offset, (f == 1.0f)? mortar: color1);
|
||||
if(stack_valid(fac_offset))
|
||||
stack_store_float(stack, fac_offset, f);
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
@@ -90,7 +90,8 @@ typedef enum NodeType {
|
||||
NODE_MIN_MAX,
|
||||
NODE_LIGHT_FALLOFF,
|
||||
NODE_OBJECT_INFO,
|
||||
NODE_PARTICLE_INFO
|
||||
NODE_PARTICLE_INFO,
|
||||
NODE_TEX_BRICK
|
||||
} NodeType;
|
||||
|
||||
typedef enum NodeAttributeType {
|
||||
|
||||
@@ -898,6 +898,98 @@ void CheckerTextureNode::compile(OSLCompiler& compiler)
|
||||
compiler.add(this, "node_checker_texture");
|
||||
}
|
||||
|
||||
/* Brick Texture */
|
||||
|
||||
BrickTextureNode::BrickTextureNode()
|
||||
: TextureNode("brick_texture")
|
||||
{
|
||||
offset = 0.5f;
|
||||
offset_frequency = 2;
|
||||
squash = 1.0f;
|
||||
squash_frequency = 2;
|
||||
|
||||
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
|
||||
add_input("Color1", SHADER_SOCKET_COLOR);
|
||||
add_input("Color2", SHADER_SOCKET_COLOR);
|
||||
add_input("Mortar", SHADER_SOCKET_COLOR);
|
||||
add_input("Scale", SHADER_SOCKET_FLOAT, 5.0f);
|
||||
add_input("Mortar Size", SHADER_SOCKET_FLOAT, 0.02f);
|
||||
add_input("Bias", SHADER_SOCKET_FLOAT, 0.0f);
|
||||
add_input("Brick Width", SHADER_SOCKET_FLOAT, 0.5f);
|
||||
add_input("Row Height", SHADER_SOCKET_FLOAT, 0.25f);
|
||||
|
||||
add_output("Color", SHADER_SOCKET_COLOR);
|
||||
add_output("Fac", SHADER_SOCKET_FLOAT);
|
||||
}
|
||||
|
||||
void BrickTextureNode::compile(SVMCompiler& compiler)
|
||||
{
|
||||
ShaderInput *vector_in = input("Vector");
|
||||
ShaderInput *color1_in = input("Color1");
|
||||
ShaderInput *color2_in = input("Color2");
|
||||
ShaderInput *mortar_in = input("Mortar");
|
||||
ShaderInput *scale_in = input("Scale");
|
||||
ShaderInput *mortar_size_in = input("Mortar Size");
|
||||
ShaderInput *bias_in = input("Bias");
|
||||
ShaderInput *brick_width_in = input("Brick Width");
|
||||
ShaderInput *row_height_in = input("Row Height");
|
||||
|
||||
ShaderOutput *color_out = output("Color");
|
||||
ShaderOutput *fac_out = output("Fac");
|
||||
|
||||
compiler.stack_assign(vector_in);
|
||||
compiler.stack_assign(color1_in);
|
||||
compiler.stack_assign(color2_in);
|
||||
compiler.stack_assign(mortar_in);
|
||||
if(scale_in->link) compiler.stack_assign(scale_in);
|
||||
if(mortar_size_in->link) compiler.stack_assign(mortar_size_in);
|
||||
if(bias_in->link) compiler.stack_assign(bias_in);
|
||||
if(brick_width_in->link) compiler.stack_assign(brick_width_in);
|
||||
if(row_height_in->link) compiler.stack_assign(row_height_in);
|
||||
|
||||
int vector_offset = vector_in->stack_offset;
|
||||
|
||||
if(!tex_mapping.skip()) {
|
||||
vector_offset = compiler.stack_find_offset(SHADER_SOCKET_VECTOR);
|
||||
tex_mapping.compile(compiler, vector_in->stack_offset, vector_offset);
|
||||
}
|
||||
|
||||
if(!color_out->links.empty())
|
||||
compiler.stack_assign(color_out);
|
||||
if(!fac_out->links.empty())
|
||||
compiler.stack_assign(fac_out);
|
||||
|
||||
compiler.add_node(NODE_TEX_BRICK,
|
||||
compiler.encode_uchar4(vector_offset,
|
||||
color1_in->stack_offset, color2_in->stack_offset, mortar_in->stack_offset),
|
||||
compiler.encode_uchar4(scale_in->stack_offset,
|
||||
mortar_size_in->stack_offset, bias_in->stack_offset, brick_width_in->stack_offset),
|
||||
compiler.encode_uchar4(row_height_in->stack_offset,
|
||||
color_out->stack_offset, fac_out->stack_offset));
|
||||
|
||||
compiler.add_node(compiler.encode_uchar4(offset_frequency, squash_frequency),
|
||||
__float_as_int(scale_in->value.x),
|
||||
__float_as_int(mortar_size_in->value.x),
|
||||
__float_as_int(bias_in->value.x));
|
||||
|
||||
compiler.add_node(__float_as_int(brick_width_in->value.x),
|
||||
__float_as_int(row_height_in->value.x),
|
||||
__float_as_int(offset),
|
||||
__float_as_int(squash));
|
||||
|
||||
if(vector_offset != vector_in->stack_offset)
|
||||
compiler.stack_clear_offset(vector_in->type, vector_offset);
|
||||
}
|
||||
|
||||
void BrickTextureNode::compile(OSLCompiler& compiler)
|
||||
{
|
||||
compiler.parameter("Offset", offset);
|
||||
compiler.parameter("Offset Frequency", offset_frequency);
|
||||
compiler.parameter("Squash", squash);
|
||||
compiler.parameter("Squash Frequency", squash_frequency);
|
||||
compiler.add(this, "node_brick_texture");
|
||||
}
|
||||
|
||||
/* Normal */
|
||||
|
||||
NormalNode::NormalNode()
|
||||
|
||||
@@ -158,6 +158,14 @@ 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)
|
||||
|
||||
@@ -546,6 +546,7 @@ struct ShadeResult;
|
||||
#define SH_NODE_LIGHT_FALLOFF 166
|
||||
#define SH_NODE_OBJECT_INFO 167
|
||||
#define SH_NODE_PARTICLE_INFO 168
|
||||
#define SH_NODE_TEX_BRICK 169
|
||||
|
||||
/* custom defines options for Material node */
|
||||
#define SH_NODE_MAT_DIFF 1
|
||||
|
||||
@@ -2265,6 +2265,7 @@ static void registerShaderNodes(bNodeTreeType *ttype)
|
||||
register_node_type_sh_tex_gradient(ttype);
|
||||
register_node_type_sh_tex_magic(ttype);
|
||||
register_node_type_sh_tex_checker(ttype);
|
||||
register_node_type_sh_tex_brick(ttype);
|
||||
}
|
||||
|
||||
static void registerTextureNodes(bNodeTreeType *ttype)
|
||||
|
||||
@@ -1364,6 +1364,19 @@ static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), Po
|
||||
uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
{
|
||||
uiLayout *col;
|
||||
|
||||
col = uiLayoutColumn(layout, TRUE);
|
||||
uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
|
||||
uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, TRUE);
|
||||
uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
|
||||
uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
{
|
||||
uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
|
||||
@@ -1448,6 +1461,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
|
||||
case SH_NODE_TEX_MAGIC:
|
||||
ntype->uifunc = node_shader_buts_tex_magic;
|
||||
break;
|
||||
case SH_NODE_TEX_BRICK:
|
||||
ntype->uifunc = node_shader_buts_tex_brick;
|
||||
break;
|
||||
case SH_NODE_TEX_WAVE:
|
||||
ntype->uifunc = node_shader_buts_tex_wave;
|
||||
break;
|
||||
|
||||
@@ -624,6 +624,12 @@ typedef struct NodeTexChecker {
|
||||
NodeTexBase base;
|
||||
} NodeTexChecker;
|
||||
|
||||
typedef struct NodeTexBrick {
|
||||
NodeTexBase base;
|
||||
int offset_freq, squash_freq;
|
||||
float offset, squash;
|
||||
} NodeTexBrick;
|
||||
|
||||
typedef struct NodeTexEnvironment {
|
||||
NodeTexBase base;
|
||||
ImageUser iuser;
|
||||
|
||||
@@ -1598,6 +1598,43 @@ static void def_sh_tex_checker(StructRNA *srna)
|
||||
def_sh_tex(srna);
|
||||
}
|
||||
|
||||
static void def_sh_tex_brick(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "NodeTexBrick", "storage");
|
||||
def_sh_tex(srna);
|
||||
|
||||
prop = RNA_def_property(srna, "offset_frequency", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "offset_freq");
|
||||
RNA_def_property_int_default(prop, 2);
|
||||
RNA_def_property_range(prop, 1, 99);
|
||||
RNA_def_property_ui_text(prop, "Offset Frequency", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "squash_frequency", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "squash_freq");
|
||||
RNA_def_property_int_default(prop, 2);
|
||||
RNA_def_property_range(prop, 1, 99);
|
||||
RNA_def_property_ui_text(prop, "Squash Frequency", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "offset");
|
||||
RNA_def_property_float_default(prop, 0.5f);
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Offset Amount", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "squash", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "squash");
|
||||
RNA_def_property_float_default(prop, 1.0f);
|
||||
RNA_def_property_range(prop, 0.0f, 99.0f);
|
||||
RNA_def_property_ui_text(prop, "Squash Amount", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Node_update");
|
||||
|
||||
}
|
||||
|
||||
static void def_sh_tex_magic(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
@@ -91,6 +91,7 @@ DefNode( ShaderNode, SH_NODE_TEX_WAVE, def_sh_tex_wave, "TE
|
||||
DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TEX_MUSGRAVE", TexMusgrave, "Musgrave Texture", "" )
|
||||
DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "" )
|
||||
DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" )
|
||||
DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" )
|
||||
DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate","" )
|
||||
|
||||
DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" )
|
||||
|
||||
@@ -180,6 +180,7 @@ set(SRC
|
||||
shader/nodes/node_shader_tex_voronoi.c
|
||||
shader/nodes/node_shader_tex_wave.c
|
||||
shader/nodes/node_shader_tex_checker.c
|
||||
shader/nodes/node_shader_tex_brick.c
|
||||
shader/node_shader_tree.c
|
||||
shader/node_shader_util.c
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ void register_node_type_sh_tex_wave(struct bNodeTreeType *ttype);
|
||||
void register_node_type_sh_tex_musgrave(struct bNodeTreeType *ttype);
|
||||
void register_node_type_sh_tex_noise(struct bNodeTreeType *ttype);
|
||||
void register_node_type_sh_tex_checker(struct bNodeTreeType *ttype);
|
||||
void register_node_type_sh_tex_brick(struct bNodeTreeType *ttype);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
90
source/blender/nodes/shader/nodes/node_shader_tex_brick.c
Normal file
90
source/blender/nodes/shader/nodes/node_shader_tex_brick.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "../node_shader_util.h"
|
||||
|
||||
/* **************** OUTPUT ******************** */
|
||||
|
||||
static bNodeSocketTemplate sh_node_tex_brick_in[]= {
|
||||
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
|
||||
{ SOCK_RGBA, 1, N_("Color1"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
|
||||
{ SOCK_RGBA, 1, N_("Color2"), 0.2f, 0.2f, 0.2f, 1.0f, 0.0f, 1.0f},
|
||||
{ SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
||||
{ SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
|
||||
{ SOCK_FLOAT, 1, N_("Mortar Size"), 0.02f, 0.0f, 0.0f, 0.0f, 0.0f, 0.125f},
|
||||
{ SOCK_FLOAT, 1, N_("Bias"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f},
|
||||
{ SOCK_FLOAT, 1, N_("Brick Width"), 0.5f, 0.0f, 0.0f, 0.0f, 0.01f, 100.0f},
|
||||
{ SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.01f, 100.0f},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static bNodeSocketTemplate sh_node_tex_brick_out[]= {
|
||||
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{ SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
|
||||
{
|
||||
NodeTexBrick *tex = MEM_callocN(sizeof(NodeTexBrick), "NodeTexBrick");
|
||||
default_tex_mapping(&tex->base.tex_mapping);
|
||||
default_color_mapping(&tex->base.color_mapping);
|
||||
|
||||
tex->offset = 0.5f;
|
||||
tex->squash = 1.0f;
|
||||
tex->offset_freq = 2;
|
||||
tex->squash_freq = 2;
|
||||
|
||||
node->storage = tex;
|
||||
}
|
||||
|
||||
static int node_shader_gpu_tex_brick(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
|
||||
{
|
||||
if (!in[0].link)
|
||||
in[0].link = GPU_attribute(CD_ORCO, "");
|
||||
|
||||
node_shader_gpu_tex_mapping(mat, node, in, out);
|
||||
|
||||
return GPU_stack_link(mat, "node_tex_brick", in, out);
|
||||
}
|
||||
|
||||
/* node type definition */
|
||||
void register_node_type_sh_tex_brick(bNodeTreeType *ttype)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
node_type_base(ttype, &ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE, NODE_OPTIONS);
|
||||
node_type_compatibility(&ntype, NODE_NEW_SHADING);
|
||||
node_type_socket_templates(&ntype, sh_node_tex_brick_in, sh_node_tex_brick_out);
|
||||
node_type_size(&ntype, 150, 60, 200);
|
||||
node_type_init(&ntype, node_shader_init_tex_brick);
|
||||
node_type_storage(&ntype, "NodeTexBrick", node_free_standard_storage, node_copy_standard_storage);
|
||||
node_type_exec(&ntype, NULL);
|
||||
node_type_gpu(&ntype, node_shader_gpu_tex_brick);
|
||||
|
||||
nodeRegisterType(ttype, &ntype);
|
||||
}
|
||||
Reference in New Issue
Block a user