diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2015-10-08 04:31:15 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2015-10-08 16:45:45 +0300 |
commit | e3abcd6723afe24eabf2a332112e4c7a74cceae3 (patch) | |
tree | 45fcb529a4e88011f7a380620293ac8df98f9e3e /intern | |
parent | 3ab5075cf9f0d3ab466e97691bfe6d84c2dffb80 (diff) |
Cycles: Add an interpolation option to environment textures
This commit exposes the interpolation parameter for environment textures (requested by DolpheenDream on IRC), just as it already is for image textures.
Reviewers: sergey
Differential Revision: https://developer.blender.org/D1544
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/kernel/shaders/node_environment_texture.osl | 3 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 42 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 1 |
4 files changed, 28 insertions, 21 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index fe6289018b2..30b14b87bd3 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -640,11 +640,12 @@ static ShaderNode *add_node(Scene *scene, if(b_image.is_updated()) { scene->image_manager->tag_reload_image(env->filename, env->builtin_data, - INTERPOLATION_LINEAR, + (InterpolationType)b_env_node.interpolation(), EXTENSION_REPEAT); } } env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()]; + env->interpolation = (InterpolationType)b_env_node.interpolation(); env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()]; get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping()); node = env; diff --git a/intern/cycles/kernel/shaders/node_environment_texture.osl b/intern/cycles/kernel/shaders/node_environment_texture.osl index 14f0226a0e5..3a0b782c98e 100644 --- a/intern/cycles/kernel/shaders/node_environment_texture.osl +++ b/intern/cycles/kernel/shaders/node_environment_texture.osl @@ -45,6 +45,7 @@ shader node_environment_texture( vector Vector = P, string filename = "", string projection = "Equirectangular", + string interpolation = "linear", string color_space = "sRGB", int is_float = 1, int use_alpha = 1, @@ -64,7 +65,7 @@ shader node_environment_texture( p = environment_texture_direction_to_mirrorball(p); /* todo: use environment for better texture filtering of equirectangular */ - Color = (color)texture(filename, p[0], 1.0 - p[1], "wrap", "periodic", "alpha", Alpha); + Color = (color)texture(filename, p[0], 1.0 - p[1], "wrap", "periodic", "interp", interpolation, "alpha", Alpha); if (use_alpha) { Color = color_unpremultiply(Color, Alpha); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 1c32644dc1f..fccb815f2fb 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -182,6 +182,21 @@ static ShaderEnum image_projection_init() return enm; } +static const char* get_osl_interpolation_parameter(InterpolationType interpolation) +{ + switch (interpolation) { + case INTERPOLATION_CLOSEST: + return "closest"; + case INTERPOLATION_CUBIC: + return "cubic"; + case INTERPOLATION_SMART: + return "smart"; + case INTERPOLATION_LINEAR: + default: + return "linear"; + } +} + ShaderEnum ImageTextureNode::color_space_enum = color_space_init(); ShaderEnum ImageTextureNode::projection_enum = image_projection_init(); @@ -362,22 +377,7 @@ void ImageTextureNode::compile(OSLCompiler& compiler) compiler.parameter("projection_blend", projection_blend); compiler.parameter("is_float", is_float); compiler.parameter("use_alpha", !alpha_out->links.empty()); - - switch (interpolation) { - case INTERPOLATION_CLOSEST: - compiler.parameter("interpolation", "closest"); - break; - case INTERPOLATION_CUBIC: - compiler.parameter("interpolation", "cubic"); - break; - case INTERPOLATION_SMART: - compiler.parameter("interpolation", "smart"); - break; - case INTERPOLATION_LINEAR: - default: - compiler.parameter("interpolation", "linear"); - break; - } + compiler.parameter("interpolation", get_osl_interpolation_parameter(interpolation)); switch(extension) { case EXTENSION_EXTEND: @@ -421,6 +421,7 @@ EnvironmentTextureNode::EnvironmentTextureNode() filename = ""; builtin_data = NULL; color_space = ustring("Color"); + interpolation = INTERPOLATION_LINEAR; projection = ustring("Equirectangular"); animated = false; @@ -434,7 +435,7 @@ EnvironmentTextureNode::~EnvironmentTextureNode() if(image_manager) { image_manager->remove_image(filename, builtin_data, - INTERPOLATION_LINEAR, + interpolation, EXTENSION_REPEAT); } } @@ -477,7 +478,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) 0, is_float_bool, is_linear, - INTERPOLATION_LINEAR, + interpolation, EXTENSION_REPEAT, use_alpha); is_float = (int)is_float_bool; @@ -546,7 +547,7 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler) 0, is_float_bool, is_linear, - INTERPOLATION_LINEAR, + interpolation, EXTENSION_REPEAT, use_alpha); is_float = (int)is_float_bool; @@ -564,6 +565,9 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler) compiler.parameter("color_space", "Linear"); else compiler.parameter("color_space", "sRGB"); + + compiler.parameter("interpolation", get_osl_interpolation_parameter(interpolation)); + compiler.parameter("is_float", is_float); compiler.parameter("use_alpha", !alpha_out->links.empty()); compiler.add(this, "node_environment_texture"); diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 5065e68345a..39709c26398 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -116,6 +116,7 @@ public: void *builtin_data; ustring color_space; ustring projection; + InterpolationType interpolation; bool animated; static ShaderEnum color_space_enum; |