Cycles: code refactoring to split out code from mapping node.
This commit is contained in:
@@ -162,9 +162,12 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
|
|||||||
case BL::ShaderNode::type_MAPPING: {
|
case BL::ShaderNode::type_MAPPING: {
|
||||||
BL::ShaderNodeMapping b_mapping_node(b_node);
|
BL::ShaderNodeMapping b_mapping_node(b_node);
|
||||||
MappingNode *mapping = new MappingNode();
|
MappingNode *mapping = new MappingNode();
|
||||||
mapping->translation = get_float3(b_mapping_node.location());
|
|
||||||
mapping->rotation = get_float3(b_mapping_node.rotation());
|
TextureMapping *tex_mapping = &mapping->tex_mapping;
|
||||||
mapping->scale = get_float3(b_mapping_node.scale());
|
tex_mapping->translation = get_float3(b_mapping_node.location());
|
||||||
|
tex_mapping->rotation = get_float3(b_mapping_node.rotation());
|
||||||
|
tex_mapping->scale = get_float3(b_mapping_node.scale());
|
||||||
|
|
||||||
node = mapping;
|
node = mapping;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,68 @@
|
|||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/* Texture Mapping */
|
||||||
|
|
||||||
|
TextureMapping::TextureMapping()
|
||||||
|
{
|
||||||
|
translation = make_float3(0.0f, 0.0f, 0.0f);
|
||||||
|
rotation = make_float3(0.0f, 0.0f, 0.0f);
|
||||||
|
scale = make_float3(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
x_mapping = X;
|
||||||
|
y_mapping = Y;
|
||||||
|
z_mapping = Z;
|
||||||
|
|
||||||
|
projection = FLAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform TextureMapping::compute_transform()
|
||||||
|
{
|
||||||
|
Transform mmat = transform_scale(make_float3(0.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
|
if(x_mapping != NONE)
|
||||||
|
mmat[0][x_mapping] = 1.0f;
|
||||||
|
if(y_mapping != NONE)
|
||||||
|
mmat[1][y_mapping] = 1.0f;
|
||||||
|
if(z_mapping != NONE)
|
||||||
|
mmat[2][z_mapping] = 1.0f;
|
||||||
|
|
||||||
|
Transform smat = transform_scale(scale);
|
||||||
|
Transform rmat = transform_euler(rotation);
|
||||||
|
Transform tmat = transform_translate(translation);
|
||||||
|
|
||||||
|
return tmat*rmat*smat*mmat;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextureMapping::skip()
|
||||||
|
{
|
||||||
|
if(translation != make_float3(0.0f, 0.0f, 0.0f))
|
||||||
|
return false;
|
||||||
|
if(rotation != make_float3(0.0f, 0.0f, 0.0f))
|
||||||
|
return false;
|
||||||
|
if(scale != make_float3(1.0f, 1.0f, 1.0f))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(x_mapping != X || y_mapping != Y || z_mapping != Z)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextureMapping::compile(SVMCompiler& compiler, int offset_in, int offset_out)
|
||||||
|
{
|
||||||
|
if(offset_in == SVM_STACK_INVALID || offset_out == SVM_STACK_INVALID)
|
||||||
|
return;
|
||||||
|
|
||||||
|
compiler.add_node(NODE_MAPPING, offset_in, offset_out);
|
||||||
|
|
||||||
|
Transform tfm = compute_transform();
|
||||||
|
compiler.add_node(tfm.x);
|
||||||
|
compiler.add_node(tfm.y);
|
||||||
|
compiler.add_node(tfm.z);
|
||||||
|
compiler.add_node(tfm.w);
|
||||||
|
}
|
||||||
|
|
||||||
/* Image Texture */
|
/* Image Texture */
|
||||||
|
|
||||||
static ShaderEnum color_space_init()
|
static ShaderEnum color_space_init()
|
||||||
@@ -40,7 +102,7 @@ static ShaderEnum color_space_init()
|
|||||||
ShaderEnum ImageTextureNode::color_space_enum = color_space_init();
|
ShaderEnum ImageTextureNode::color_space_enum = color_space_init();
|
||||||
|
|
||||||
ImageTextureNode::ImageTextureNode()
|
ImageTextureNode::ImageTextureNode()
|
||||||
: ShaderNode("image_texture")
|
: TextureNode("image_texture")
|
||||||
{
|
{
|
||||||
image_manager = NULL;
|
image_manager = NULL;
|
||||||
slot = -1;
|
slot = -1;
|
||||||
@@ -83,6 +145,10 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
|
|||||||
|
|
||||||
if(slot != -1) {
|
if(slot != -1) {
|
||||||
compiler.stack_assign(vector_in);
|
compiler.stack_assign(vector_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.add_node(NODE_TEX_IMAGE,
|
compiler.add_node(NODE_TEX_IMAGE,
|
||||||
slot,
|
slot,
|
||||||
compiler.encode_uchar4(
|
compiler.encode_uchar4(
|
||||||
@@ -114,7 +180,7 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
|
|||||||
ShaderEnum EnvironmentTextureNode::color_space_enum = color_space_init();
|
ShaderEnum EnvironmentTextureNode::color_space_enum = color_space_init();
|
||||||
|
|
||||||
EnvironmentTextureNode::EnvironmentTextureNode()
|
EnvironmentTextureNode::EnvironmentTextureNode()
|
||||||
: ShaderNode("environment_texture")
|
: TextureNode("environment_texture")
|
||||||
{
|
{
|
||||||
image_manager = NULL;
|
image_manager = NULL;
|
||||||
slot = -1;
|
slot = -1;
|
||||||
@@ -157,6 +223,10 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
|
|||||||
|
|
||||||
if(slot != -1) {
|
if(slot != -1) {
|
||||||
compiler.stack_assign(vector_in);
|
compiler.stack_assign(vector_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.add_node(NODE_TEX_ENVIRONMENT,
|
compiler.add_node(NODE_TEX_ENVIRONMENT,
|
||||||
slot,
|
slot,
|
||||||
compiler.encode_uchar4(
|
compiler.encode_uchar4(
|
||||||
@@ -248,7 +318,7 @@ static void sky_texture_precompute(KernelSunSky *ksunsky, float3 dir, float turb
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkyTextureNode::SkyTextureNode()
|
SkyTextureNode::SkyTextureNode()
|
||||||
: ShaderNode("sky_texture")
|
: TextureNode("sky_texture")
|
||||||
{
|
{
|
||||||
sun_direction = make_float3(0.0f, 0.0f, 1.0f);
|
sun_direction = make_float3(0.0f, 0.0f, 1.0f);
|
||||||
turbidity = 2.2f;
|
turbidity = 2.2f;
|
||||||
@@ -269,6 +339,9 @@ void SkyTextureNode::compile(SVMCompiler& compiler)
|
|||||||
|
|
||||||
if(vector_in->link)
|
if(vector_in->link)
|
||||||
compiler.stack_assign(vector_in);
|
compiler.stack_assign(vector_in);
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(color_out);
|
compiler.stack_assign(color_out);
|
||||||
compiler.add_node(NODE_TEX_SKY, vector_in->stack_offset, color_out->stack_offset);
|
compiler.add_node(NODE_TEX_SKY, vector_in->stack_offset, color_out->stack_offset);
|
||||||
}
|
}
|
||||||
@@ -283,7 +356,7 @@ void SkyTextureNode::compile(OSLCompiler& compiler)
|
|||||||
/* Noise Texture */
|
/* Noise Texture */
|
||||||
|
|
||||||
NoiseTextureNode::NoiseTextureNode()
|
NoiseTextureNode::NoiseTextureNode()
|
||||||
: ShaderNode("noise_texture")
|
: TextureNode("noise_texture")
|
||||||
{
|
{
|
||||||
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
|
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
|
||||||
add_output("Color", SHADER_SOCKET_COLOR);
|
add_output("Color", SHADER_SOCKET_COLOR);
|
||||||
@@ -296,14 +369,16 @@ void NoiseTextureNode::compile(SVMCompiler& compiler)
|
|||||||
ShaderOutput *color_out = output("Color");
|
ShaderOutput *color_out = output("Color");
|
||||||
ShaderOutput *fac_out = output("Fac");
|
ShaderOutput *fac_out = output("Fac");
|
||||||
|
|
||||||
|
if(!color_out->links.empty() || !fac_out->links.empty())
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
if(!color_out->links.empty()) {
|
if(!color_out->links.empty()) {
|
||||||
compiler.stack_assign(vector_in);
|
|
||||||
compiler.stack_assign(color_out);
|
compiler.stack_assign(color_out);
|
||||||
compiler.add_node(NODE_TEX_NOISE_V, vector_in->stack_offset, color_out->stack_offset);
|
compiler.add_node(NODE_TEX_NOISE_V, vector_in->stack_offset, color_out->stack_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fac_out->links.empty()) {
|
if(!fac_out->links.empty()) {
|
||||||
compiler.stack_assign(vector_in);
|
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
compiler.add_node(NODE_TEX_NOISE_F, vector_in->stack_offset, fac_out->stack_offset);
|
compiler.add_node(NODE_TEX_NOISE_F, vector_in->stack_offset, fac_out->stack_offset);
|
||||||
}
|
}
|
||||||
@@ -345,7 +420,7 @@ ShaderEnum BlendTextureNode::progression_enum = blend_progression_init();
|
|||||||
ShaderEnum BlendTextureNode::axis_enum = blend_axis_init();
|
ShaderEnum BlendTextureNode::axis_enum = blend_axis_init();
|
||||||
|
|
||||||
BlendTextureNode::BlendTextureNode()
|
BlendTextureNode::BlendTextureNode()
|
||||||
: ShaderNode("blend_texture")
|
: TextureNode("blend_texture")
|
||||||
{
|
{
|
||||||
progression = ustring("Linear");
|
progression = ustring("Linear");
|
||||||
axis = ustring("Horizontal");
|
axis = ustring("Horizontal");
|
||||||
@@ -361,6 +436,9 @@ void BlendTextureNode::compile(SVMCompiler& compiler)
|
|||||||
|
|
||||||
if(vector_in->link) compiler.stack_assign(vector_in);
|
if(vector_in->link) compiler.stack_assign(vector_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
compiler.add_node(NODE_TEX_BLEND,
|
compiler.add_node(NODE_TEX_BLEND,
|
||||||
compiler.encode_uchar4(progression_enum[progression], axis_enum[axis]),
|
compiler.encode_uchar4(progression_enum[progression], axis_enum[axis]),
|
||||||
@@ -395,7 +473,7 @@ static ShaderEnum noise_basis_init()
|
|||||||
ShaderEnum CloudsTextureNode::basis_enum = noise_basis_init();
|
ShaderEnum CloudsTextureNode::basis_enum = noise_basis_init();
|
||||||
|
|
||||||
CloudsTextureNode::CloudsTextureNode()
|
CloudsTextureNode::CloudsTextureNode()
|
||||||
: ShaderNode("clouds_texture")
|
: TextureNode("clouds_texture")
|
||||||
{
|
{
|
||||||
basis = ustring("Perlin");
|
basis = ustring("Perlin");
|
||||||
hard = false;
|
hard = false;
|
||||||
@@ -418,6 +496,9 @@ void CloudsTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(vector_in->link) compiler.stack_assign(vector_in);
|
if(vector_in->link) compiler.stack_assign(vector_in);
|
||||||
if(size_in->link) compiler.stack_assign(size_in);
|
if(size_in->link) compiler.stack_assign(size_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(color_out);
|
compiler.stack_assign(color_out);
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
|
|
||||||
@@ -468,7 +549,7 @@ ShaderEnum VoronoiTextureNode::distance_metric_enum = distance_metric_init();
|
|||||||
ShaderEnum VoronoiTextureNode::coloring_enum = voronoi_coloring_init();
|
ShaderEnum VoronoiTextureNode::coloring_enum = voronoi_coloring_init();
|
||||||
|
|
||||||
VoronoiTextureNode::VoronoiTextureNode()
|
VoronoiTextureNode::VoronoiTextureNode()
|
||||||
: ShaderNode("voronoi_texture")
|
: TextureNode("voronoi_texture")
|
||||||
{
|
{
|
||||||
distance_metric = ustring("Actual Distance");
|
distance_metric = ustring("Actual Distance");
|
||||||
coloring = ustring("Intensity");
|
coloring = ustring("Intensity");
|
||||||
@@ -505,6 +586,9 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(vector_in->link) compiler.stack_assign(vector_in);
|
if(vector_in->link) compiler.stack_assign(vector_in);
|
||||||
if(size_in->link) compiler.stack_assign(size_in);
|
if(size_in->link) compiler.stack_assign(size_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(color_out);
|
compiler.stack_assign(color_out);
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
|
|
||||||
@@ -546,7 +630,7 @@ ShaderEnum MusgraveTextureNode::type_enum = musgrave_type_init();
|
|||||||
ShaderEnum MusgraveTextureNode::basis_enum = noise_basis_init();
|
ShaderEnum MusgraveTextureNode::basis_enum = noise_basis_init();
|
||||||
|
|
||||||
MusgraveTextureNode::MusgraveTextureNode()
|
MusgraveTextureNode::MusgraveTextureNode()
|
||||||
: ShaderNode("musgrave_texture")
|
: TextureNode("musgrave_texture")
|
||||||
{
|
{
|
||||||
type = ustring("fBM");
|
type = ustring("fBM");
|
||||||
basis = ustring("Perlin");
|
basis = ustring("Perlin");
|
||||||
@@ -581,6 +665,9 @@ void MusgraveTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(gain_in->link) compiler.stack_assign(gain_in);
|
if(gain_in->link) compiler.stack_assign(gain_in);
|
||||||
if(size_in->link) compiler.stack_assign(size_in);
|
if(size_in->link) compiler.stack_assign(size_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
compiler.add_node(NODE_TEX_MUSGRAVE,
|
compiler.add_node(NODE_TEX_MUSGRAVE,
|
||||||
compiler.encode_uchar4(type_enum[type], basis_enum[basis], vector_in->stack_offset, fac_out->stack_offset),
|
compiler.encode_uchar4(type_enum[type], basis_enum[basis], vector_in->stack_offset, fac_out->stack_offset),
|
||||||
@@ -631,7 +718,7 @@ ShaderEnum MarbleTextureNode::wave_enum = noise_wave_init();
|
|||||||
ShaderEnum MarbleTextureNode::basis_enum = noise_basis_init();
|
ShaderEnum MarbleTextureNode::basis_enum = noise_basis_init();
|
||||||
|
|
||||||
MarbleTextureNode::MarbleTextureNode()
|
MarbleTextureNode::MarbleTextureNode()
|
||||||
: ShaderNode("marble_texture")
|
: TextureNode("marble_texture")
|
||||||
{
|
{
|
||||||
type = ustring("Soft");
|
type = ustring("Soft");
|
||||||
wave = ustring("Sine");
|
wave = ustring("Sine");
|
||||||
@@ -657,6 +744,9 @@ void MarbleTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
||||||
if(vector_in->link) compiler.stack_assign(vector_in);
|
if(vector_in->link) compiler.stack_assign(vector_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
compiler.add_node(NODE_TEX_MARBLE,
|
compiler.add_node(NODE_TEX_MARBLE,
|
||||||
compiler.encode_uchar4(type_enum[type], wave_enum[wave], basis_enum[basis], hard),
|
compiler.encode_uchar4(type_enum[type], wave_enum[wave], basis_enum[basis], hard),
|
||||||
@@ -679,7 +769,7 @@ void MarbleTextureNode::compile(OSLCompiler& compiler)
|
|||||||
/* Magic Texture */
|
/* Magic Texture */
|
||||||
|
|
||||||
MagicTextureNode::MagicTextureNode()
|
MagicTextureNode::MagicTextureNode()
|
||||||
: ShaderNode("magic_texture")
|
: TextureNode("magic_texture")
|
||||||
{
|
{
|
||||||
depth = 2;
|
depth = 2;
|
||||||
|
|
||||||
@@ -697,6 +787,9 @@ void MagicTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(vector_in->link) compiler.stack_assign(vector_in);
|
if(vector_in->link) compiler.stack_assign(vector_in);
|
||||||
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(color_out);
|
compiler.stack_assign(color_out);
|
||||||
compiler.add_node(NODE_TEX_MAGIC,
|
compiler.add_node(NODE_TEX_MAGIC,
|
||||||
compiler.encode_uchar4(depth, turbulence_in->stack_offset, vector_in->stack_offset, color_out->stack_offset),
|
compiler.encode_uchar4(depth, turbulence_in->stack_offset, vector_in->stack_offset, color_out->stack_offset),
|
||||||
@@ -726,7 +819,7 @@ ShaderEnum StucciTextureNode::type_enum = stucci_type_init();
|
|||||||
ShaderEnum StucciTextureNode::basis_enum = noise_basis_init();
|
ShaderEnum StucciTextureNode::basis_enum = noise_basis_init();
|
||||||
|
|
||||||
StucciTextureNode::StucciTextureNode()
|
StucciTextureNode::StucciTextureNode()
|
||||||
: ShaderNode("stucci_texture")
|
: TextureNode("stucci_texture")
|
||||||
{
|
{
|
||||||
type = ustring("Plastic");
|
type = ustring("Plastic");
|
||||||
basis = ustring("Perlin");
|
basis = ustring("Perlin");
|
||||||
@@ -750,6 +843,9 @@ void StucciTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
||||||
if(vector_in->link) compiler.stack_assign(vector_in);
|
if(vector_in->link) compiler.stack_assign(vector_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
|
|
||||||
compiler.add_node(NODE_TEX_STUCCI,
|
compiler.add_node(NODE_TEX_STUCCI,
|
||||||
@@ -773,7 +869,7 @@ void StucciTextureNode::compile(OSLCompiler& compiler)
|
|||||||
ShaderEnum DistortedNoiseTextureNode::basis_enum = noise_basis_init();
|
ShaderEnum DistortedNoiseTextureNode::basis_enum = noise_basis_init();
|
||||||
|
|
||||||
DistortedNoiseTextureNode::DistortedNoiseTextureNode()
|
DistortedNoiseTextureNode::DistortedNoiseTextureNode()
|
||||||
: ShaderNode("distorted_noise_texture")
|
: TextureNode("distorted_noise_texture")
|
||||||
{
|
{
|
||||||
basis = ustring("Perlin");
|
basis = ustring("Perlin");
|
||||||
distortion_basis = ustring("Perlin");
|
distortion_basis = ustring("Perlin");
|
||||||
@@ -796,6 +892,9 @@ void DistortedNoiseTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(distortion_in->link) compiler.stack_assign(distortion_in);
|
if(distortion_in->link) compiler.stack_assign(distortion_in);
|
||||||
if(vector_in->link) compiler.stack_assign(vector_in);
|
if(vector_in->link) compiler.stack_assign(vector_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
|
|
||||||
compiler.add_node(NODE_TEX_DISTORTED_NOISE,
|
compiler.add_node(NODE_TEX_DISTORTED_NOISE,
|
||||||
@@ -831,7 +930,7 @@ ShaderEnum WoodTextureNode::wave_enum = noise_wave_init();
|
|||||||
ShaderEnum WoodTextureNode::basis_enum = noise_basis_init();
|
ShaderEnum WoodTextureNode::basis_enum = noise_basis_init();
|
||||||
|
|
||||||
WoodTextureNode::WoodTextureNode()
|
WoodTextureNode::WoodTextureNode()
|
||||||
: ShaderNode("wood_texture")
|
: TextureNode("wood_texture")
|
||||||
{
|
{
|
||||||
type = ustring("Bands");
|
type = ustring("Bands");
|
||||||
wave = ustring("Sine");
|
wave = ustring("Sine");
|
||||||
@@ -856,6 +955,9 @@ void WoodTextureNode::compile(SVMCompiler& compiler)
|
|||||||
if(size_in->link) compiler.stack_assign(size_in);
|
if(size_in->link) compiler.stack_assign(size_in);
|
||||||
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
|
||||||
|
|
||||||
|
if(!tex_mapping.skip())
|
||||||
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
|
||||||
|
|
||||||
compiler.stack_assign(fac_out);
|
compiler.stack_assign(fac_out);
|
||||||
compiler.add_node(NODE_TEX_WOOD,
|
compiler.add_node(NODE_TEX_WOOD,
|
||||||
compiler.encode_uchar4(type_enum[type], wave_enum[wave], basis_enum[basis], hard),
|
compiler.encode_uchar4(type_enum[type], wave_enum[wave], basis_enum[basis], hard),
|
||||||
@@ -879,19 +981,6 @@ MappingNode::MappingNode()
|
|||||||
{
|
{
|
||||||
add_input("Vector", SHADER_SOCKET_POINT);
|
add_input("Vector", SHADER_SOCKET_POINT);
|
||||||
add_output("Vector", SHADER_SOCKET_POINT);
|
add_output("Vector", SHADER_SOCKET_POINT);
|
||||||
|
|
||||||
translation = make_float3(0.0f, 0.0f, 0.0f);
|
|
||||||
rotation = make_float3(0.0f, 0.0f, 0.0f);
|
|
||||||
scale = make_float3(1.0f, 1.0f, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform MappingNode::compute_transform()
|
|
||||||
{
|
|
||||||
Transform smat = transform_scale(scale);
|
|
||||||
Transform rmat = transform_euler(rotation);
|
|
||||||
Transform tmat = transform_translate(translation);
|
|
||||||
|
|
||||||
return tmat*rmat*smat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingNode::compile(SVMCompiler& compiler)
|
void MappingNode::compile(SVMCompiler& compiler)
|
||||||
@@ -902,18 +991,12 @@ void MappingNode::compile(SVMCompiler& compiler)
|
|||||||
compiler.stack_assign(vector_in);
|
compiler.stack_assign(vector_in);
|
||||||
compiler.stack_assign(vector_out);
|
compiler.stack_assign(vector_out);
|
||||||
|
|
||||||
compiler.add_node(NODE_MAPPING, vector_in->stack_offset, vector_out->stack_offset);
|
tex_mapping.compile(compiler, vector_in->stack_offset, vector_out->stack_offset);
|
||||||
|
|
||||||
Transform tfm = compute_transform();
|
|
||||||
compiler.add_node(tfm.x);
|
|
||||||
compiler.add_node(tfm.y);
|
|
||||||
compiler.add_node(tfm.z);
|
|
||||||
compiler.add_node(tfm.w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingNode::compile(OSLCompiler& compiler)
|
void MappingNode::compile(OSLCompiler& compiler)
|
||||||
{
|
{
|
||||||
Transform tfm = transform_transpose(compute_transform());
|
Transform tfm = transform_transpose(tex_mapping.compute_transform());
|
||||||
compiler.parameter("Matrix", tfm);
|
compiler.parameter("Matrix", tfm);
|
||||||
|
|
||||||
compiler.add(this, "node_mapping");
|
compiler.add(this, "node_mapping");
|
||||||
|
@@ -28,9 +28,35 @@ CCL_NAMESPACE_BEGIN
|
|||||||
class ImageManager;
|
class ImageManager;
|
||||||
class Shadr;
|
class Shadr;
|
||||||
|
|
||||||
|
/* Texture Mapping */
|
||||||
|
|
||||||
|
class TextureMapping {
|
||||||
|
public:
|
||||||
|
TextureMapping();
|
||||||
|
Transform compute_transform();
|
||||||
|
bool skip();
|
||||||
|
void compile(SVMCompiler& compiler, int offset_in, int offset_out);
|
||||||
|
|
||||||
|
float3 translation;
|
||||||
|
float3 rotation;
|
||||||
|
float3 scale;
|
||||||
|
|
||||||
|
enum Mapping { X=0, Y=1, Z=2, NONE };
|
||||||
|
Mapping x_mapping, y_mapping, z_mapping;
|
||||||
|
|
||||||
|
enum Projection { FLAT, CUBE, TUBE, SPHERE };
|
||||||
|
Projection projection;
|
||||||
|
};
|
||||||
|
|
||||||
/* Nodes */
|
/* Nodes */
|
||||||
|
|
||||||
class ImageTextureNode : public ShaderNode {
|
class TextureNode : public ShaderNode {
|
||||||
|
public:
|
||||||
|
TextureNode(const char *name) : ShaderNode(name) {}
|
||||||
|
TextureMapping tex_mapping;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ImageTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_NO_CLONE_CLASS(ImageTextureNode)
|
SHADER_NODE_NO_CLONE_CLASS(ImageTextureNode)
|
||||||
~ImageTextureNode();
|
~ImageTextureNode();
|
||||||
@@ -44,7 +70,7 @@ public:
|
|||||||
static ShaderEnum color_space_enum;
|
static ShaderEnum color_space_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EnvironmentTextureNode : public ShaderNode {
|
class EnvironmentTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_NO_CLONE_CLASS(EnvironmentTextureNode)
|
SHADER_NODE_NO_CLONE_CLASS(EnvironmentTextureNode)
|
||||||
~EnvironmentTextureNode();
|
~EnvironmentTextureNode();
|
||||||
@@ -58,7 +84,7 @@ public:
|
|||||||
static ShaderEnum color_space_enum;
|
static ShaderEnum color_space_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkyTextureNode : public ShaderNode {
|
class SkyTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(SkyTextureNode)
|
SHADER_NODE_CLASS(SkyTextureNode)
|
||||||
|
|
||||||
@@ -71,12 +97,12 @@ public:
|
|||||||
SHADER_NODE_CLASS(OutputNode)
|
SHADER_NODE_CLASS(OutputNode)
|
||||||
};
|
};
|
||||||
|
|
||||||
class NoiseTextureNode : public ShaderNode {
|
class NoiseTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(NoiseTextureNode)
|
SHADER_NODE_CLASS(NoiseTextureNode)
|
||||||
};
|
};
|
||||||
|
|
||||||
class BlendTextureNode : public ShaderNode {
|
class BlendTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(BlendTextureNode)
|
SHADER_NODE_CLASS(BlendTextureNode)
|
||||||
|
|
||||||
@@ -87,7 +113,7 @@ public:
|
|||||||
static ShaderEnum axis_enum;
|
static ShaderEnum axis_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CloudsTextureNode : public ShaderNode {
|
class CloudsTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(CloudsTextureNode)
|
SHADER_NODE_CLASS(CloudsTextureNode)
|
||||||
|
|
||||||
@@ -98,7 +124,7 @@ public:
|
|||||||
static ShaderEnum basis_enum;
|
static ShaderEnum basis_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VoronoiTextureNode : public ShaderNode {
|
class VoronoiTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(VoronoiTextureNode)
|
SHADER_NODE_CLASS(VoronoiTextureNode)
|
||||||
|
|
||||||
@@ -109,7 +135,7 @@ public:
|
|||||||
static ShaderEnum coloring_enum;
|
static ShaderEnum coloring_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MusgraveTextureNode : public ShaderNode {
|
class MusgraveTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(MusgraveTextureNode)
|
SHADER_NODE_CLASS(MusgraveTextureNode)
|
||||||
|
|
||||||
@@ -120,7 +146,7 @@ public:
|
|||||||
static ShaderEnum basis_enum;
|
static ShaderEnum basis_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MarbleTextureNode : public ShaderNode {
|
class MarbleTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(MarbleTextureNode)
|
SHADER_NODE_CLASS(MarbleTextureNode)
|
||||||
|
|
||||||
@@ -135,14 +161,14 @@ public:
|
|||||||
static ShaderEnum basis_enum;
|
static ShaderEnum basis_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MagicTextureNode : public ShaderNode {
|
class MagicTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(MagicTextureNode)
|
SHADER_NODE_CLASS(MagicTextureNode)
|
||||||
|
|
||||||
int depth;
|
int depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StucciTextureNode : public ShaderNode {
|
class StucciTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(StucciTextureNode)
|
SHADER_NODE_CLASS(StucciTextureNode)
|
||||||
|
|
||||||
@@ -154,7 +180,7 @@ public:
|
|||||||
static ShaderEnum basis_enum;
|
static ShaderEnum basis_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DistortedNoiseTextureNode : public ShaderNode {
|
class DistortedNoiseTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(DistortedNoiseTextureNode)
|
SHADER_NODE_CLASS(DistortedNoiseTextureNode)
|
||||||
|
|
||||||
@@ -163,7 +189,7 @@ public:
|
|||||||
static ShaderEnum basis_enum;
|
static ShaderEnum basis_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WoodTextureNode : public ShaderNode {
|
class WoodTextureNode : public TextureNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(WoodTextureNode)
|
SHADER_NODE_CLASS(WoodTextureNode)
|
||||||
|
|
||||||
@@ -181,10 +207,7 @@ class MappingNode : public ShaderNode {
|
|||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(MappingNode)
|
SHADER_NODE_CLASS(MappingNode)
|
||||||
|
|
||||||
Transform compute_transform();
|
TextureMapping tex_mapping;
|
||||||
float3 translation;
|
|
||||||
float3 rotation;
|
|
||||||
float3 scale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConvertNode : public ShaderNode {
|
class ConvertNode : public ShaderNode {
|
||||||
|
Reference in New Issue
Block a user