Add support for multiple interpolation modes on cycles image textures
All textures are sampled bi-linear currently with the exception of OSL there texture sampling is fixed and set to smart bi-cubic. This patch adds user control to this setting. Added: - bits to DNA / RNA in the form of an enum for supporting multiple interpolations types - changes to the image texture node drawing code ( add enum) - to ImageManager (this needs to know to allocate second texture when interpolation type is different) - to node compiler (pass on interpolation type) - to device tex_alloc this also needs to get the concept of multiple interpolation types - implementation for doing non interpolated lookup for cuda and cpu - implementation where we pass this along to osl ( this makes OSL also do linear untill I add smartcubic to the interface / DNA/ RNA) Reviewers: brecht, dingto Reviewed By: brecht CC: dingto, venomgfx Differential Revision: https://developer.blender.org/D317
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
#include "stdosl.h"
|
||||
#include "node_color.h"
|
||||
|
||||
color image_texture_lookup(string filename, string color_space, float u, float v, output float Alpha, int use_alpha, int is_float)
|
||||
color image_texture_lookup(string filename, string color_space, float u, float v, output float Alpha, int use_alpha, int is_float, string interpolation)
|
||||
{
|
||||
color rgb = (color)texture(filename, u, 1.0 - v, "wrap", "periodic", "alpha", Alpha);
|
||||
color rgb = (color)texture(filename, u, 1.0 - v, "wrap", "periodic", "interp", interpolation, "alpha", Alpha);
|
||||
|
||||
if (use_alpha) {
|
||||
rgb = color_unpremultiply(rgb, Alpha);
|
||||
@@ -42,6 +42,7 @@ shader node_image_texture(
|
||||
string filename = "",
|
||||
string color_space = "sRGB",
|
||||
string projection = "Flat",
|
||||
string interpolation = "smartcubic",
|
||||
float projection_blend = 0.0,
|
||||
int is_float = 1,
|
||||
int use_alpha = 1,
|
||||
@@ -54,7 +55,7 @@ shader node_image_texture(
|
||||
p = transform(mapping, p);
|
||||
|
||||
if (projection == "Flat") {
|
||||
Color = image_texture_lookup(filename, color_space, p[0], p[1], Alpha, use_alpha, is_float);
|
||||
Color = image_texture_lookup(filename, color_space, p[0], p[1], Alpha, use_alpha, is_float, interpolation);
|
||||
}
|
||||
else if (projection == "Box") {
|
||||
/* object space normal */
|
||||
@@ -119,15 +120,15 @@ shader node_image_texture(
|
||||
float tmp_alpha;
|
||||
|
||||
if (weight[0] > 0.0) {
|
||||
Color += weight[0] * image_texture_lookup(filename, color_space, p[1], p[2], tmp_alpha, use_alpha, is_float);
|
||||
Color += weight[0] * image_texture_lookup(filename, color_space, p[1], p[2], tmp_alpha, use_alpha, is_float, interpolation);
|
||||
Alpha += weight[0] * tmp_alpha;
|
||||
}
|
||||
if (weight[1] > 0.0) {
|
||||
Color += weight[1] * image_texture_lookup(filename, color_space, p[0], p[2], tmp_alpha, use_alpha, is_float);
|
||||
Color += weight[1] * image_texture_lookup(filename, color_space, p[0], p[2], tmp_alpha, use_alpha, is_float, interpolation);
|
||||
Alpha += weight[1] * tmp_alpha;
|
||||
}
|
||||
if (weight[2] > 0.0) {
|
||||
Color += weight[2] * image_texture_lookup(filename, color_space, p[1], p[0], tmp_alpha, use_alpha, is_float);
|
||||
Color += weight[2] * image_texture_lookup(filename, color_space, p[1], p[0], tmp_alpha, use_alpha, is_float, interpolation);
|
||||
Alpha += weight[2] * tmp_alpha;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user