Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/nodes.cpp
| Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | : TextureNode("image_texture") | ||||
| image_manager = NULL; | image_manager = NULL; | ||||
| slot = -1; | slot = -1; | ||||
| is_float = -1; | is_float = -1; | ||||
| is_linear = false; | is_linear = false; | ||||
| filename = ""; | filename = ""; | ||||
| builtin_data = NULL; | builtin_data = NULL; | ||||
| color_space = ustring("Color"); | color_space = ustring("Color"); | ||||
| projection = ustring("Flat"); | projection = ustring("Flat"); | ||||
| interpolation = INTERPOLATION_LINEAR; | |||||
| projection_blend = 0.0f; | projection_blend = 0.0f; | ||||
| animated = false; | animated = false; | ||||
| add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_UV); | add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_UV); | ||||
| add_output("Color", SHADER_SOCKET_COLOR); | add_output("Color", SHADER_SOCKET_COLOR); | ||||
| add_output("Alpha", SHADER_SOCKET_FLOAT); | add_output("Alpha", SHADER_SOCKET_FLOAT); | ||||
| } | } | ||||
| ImageTextureNode::~ImageTextureNode() | ImageTextureNode::~ImageTextureNode() | ||||
| { | { | ||||
| if(image_manager) | if(image_manager) | ||||
| image_manager->remove_image(filename, builtin_data); | image_manager->remove_image(filename, builtin_data, interpolation); | ||||
| } | } | ||||
| ShaderNode *ImageTextureNode::clone() const | ShaderNode *ImageTextureNode::clone() const | ||||
| { | { | ||||
| ImageTextureNode *node = new ImageTextureNode(*this); | ImageTextureNode *node = new ImageTextureNode(*this); | ||||
| node->image_manager = NULL; | node->image_manager = NULL; | ||||
| node->slot = -1; | node->slot = -1; | ||||
| node->is_float = -1; | node->is_float = -1; | ||||
| Show All 20 Lines | |||||
| { | { | ||||
| ShaderInput *vector_in = input("Vector"); | ShaderInput *vector_in = input("Vector"); | ||||
| ShaderOutput *color_out = output("Color"); | ShaderOutput *color_out = output("Color"); | ||||
| ShaderOutput *alpha_out = output("Alpha"); | ShaderOutput *alpha_out = output("Alpha"); | ||||
| image_manager = compiler.image_manager; | image_manager = compiler.image_manager; | ||||
| if(is_float == -1) { | if(is_float == -1) { | ||||
| bool is_float_bool; | bool is_float_bool; | ||||
| slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear); | slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, interpolation); | ||||
| is_float = (int)is_float_bool; | is_float = (int)is_float_bool; | ||||
| } | } | ||||
| if(!color_out->links.empty()) | if(!color_out->links.empty()) | ||||
| compiler.stack_assign(color_out); | compiler.stack_assign(color_out); | ||||
| if(!alpha_out->links.empty()) | if(!alpha_out->links.empty()) | ||||
| compiler.stack_assign(alpha_out); | compiler.stack_assign(alpha_out); | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | void ImageTextureNode::compile(OSLCompiler& compiler) | ||||
| if(is_linear || color_space != "Color") | if(is_linear || color_space != "Color") | ||||
| compiler.parameter("color_space", "Linear"); | compiler.parameter("color_space", "Linear"); | ||||
| else | else | ||||
| compiler.parameter("color_space", "sRGB"); | compiler.parameter("color_space", "sRGB"); | ||||
| compiler.parameter("projection", projection); | compiler.parameter("projection", projection); | ||||
| compiler.parameter("projection_blend", projection_blend); | compiler.parameter("projection_blend", projection_blend); | ||||
| compiler.parameter("is_float", is_float); | compiler.parameter("is_float", is_float); | ||||
| compiler.parameter("use_alpha", !alpha_out->links.empty()); | compiler.parameter("use_alpha", !alpha_out->links.empty()); | ||||
| switch (interpolation){ | |||||
| case INTERPOLATION_LINEAR: | |||||
| compiler.parameter("interpolation", "linear"); | |||||
| break; | |||||
| case INTERPOLATION_CLOSEST: | |||||
| compiler.parameter("interpolation", "closest"); | |||||
| break; | |||||
| case INTERPOLATION_CUBIC: | |||||
| compiler.parameter("interpolation", "cubic"); | |||||
| break; | |||||
| case INTERPOLATION_SMART: | |||||
| compiler.parameter("interpolation", "smart"); | |||||
| break; | |||||
| default: | |||||
| compiler.parameter("interpolation", "linear"); | |||||
| break; | |||||
| } | |||||
| compiler.add(this, "node_image_texture"); | compiler.add(this, "node_image_texture"); | ||||
| } | } | ||||
| /* Environment Texture */ | /* Environment Texture */ | ||||
| static ShaderEnum env_projection_init() | static ShaderEnum env_projection_init() | ||||
| { | { | ||||
| ShaderEnum enm; | ShaderEnum enm; | ||||
| Show All 22 Lines | : TextureNode("environment_texture") | ||||
| add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION); | add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION); | ||||
| add_output("Color", SHADER_SOCKET_COLOR); | add_output("Color", SHADER_SOCKET_COLOR); | ||||
| add_output("Alpha", SHADER_SOCKET_FLOAT); | add_output("Alpha", SHADER_SOCKET_FLOAT); | ||||
| } | } | ||||
| EnvironmentTextureNode::~EnvironmentTextureNode() | EnvironmentTextureNode::~EnvironmentTextureNode() | ||||
| { | { | ||||
| if(image_manager) | if(image_manager) | ||||
brecht: This should not be static. Can be const if you want, but no reason to have it static. If… | |||||
| image_manager->remove_image(filename, builtin_data); | image_manager->remove_image(filename, builtin_data, INTERPOLATION_LINEAR); | ||||
| } | } | ||||
| ShaderNode *EnvironmentTextureNode::clone() const | ShaderNode *EnvironmentTextureNode::clone() const | ||||
| { | { | ||||
| EnvironmentTextureNode *node = new EnvironmentTextureNode(*this); | EnvironmentTextureNode *node = new EnvironmentTextureNode(*this); | ||||
| node->image_manager = NULL; | node->image_manager = NULL; | ||||
| node->slot = -1; | node->slot = -1; | ||||
| node->is_float = -1; | node->is_float = -1; | ||||
| Show All 15 Lines | |||||
| } | } | ||||
| void EnvironmentTextureNode::compile(SVMCompiler& compiler) | void EnvironmentTextureNode::compile(SVMCompiler& compiler) | ||||
| { | { | ||||
| ShaderInput *vector_in = input("Vector"); | ShaderInput *vector_in = input("Vector"); | ||||
| ShaderOutput *color_out = output("Color"); | ShaderOutput *color_out = output("Color"); | ||||
| ShaderOutput *alpha_out = output("Alpha"); | ShaderOutput *alpha_out = output("Alpha"); | ||||
| image_manager = compiler.image_manager; | image_manager = compiler.image_manager; | ||||
Not Done Inline ActionsSame comment as above. brecht: Same comment as above. | |||||
| if(slot == -1) { | if(slot == -1) { | ||||
| bool is_float_bool; | bool is_float_bool; | ||||
| slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear); | slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, INTERPOLATION_LINEAR); | ||||
| is_float = (int)is_float_bool; | is_float = (int)is_float_bool; | ||||
| } | } | ||||
| if(!color_out->links.empty()) | if(!color_out->links.empty()) | ||||
| compiler.stack_assign(color_out); | compiler.stack_assign(color_out); | ||||
| if(!alpha_out->links.empty()) | if(!alpha_out->links.empty()) | ||||
| compiler.stack_assign(alpha_out); | compiler.stack_assign(alpha_out); | ||||
| ▲ Show 20 Lines • Show All 3,612 Lines • Show Last 20 Lines | |||||
This should not be static. Can be const if you want, but no reason to have it static. If remove_image accepts InterpolationType it can just pass INTERPOLATION_NONE directly though.