Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/shaders/node_image_texture.osl
| Show All 11 Lines | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License | * limitations under the License | ||||
| */ | */ | ||||
| #include "stdosl.h" | #include "stdosl.h" | ||||
| #include "node_color.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) { | if (use_alpha) { | ||||
| rgb = color_unpremultiply(rgb, Alpha); | rgb = color_unpremultiply(rgb, Alpha); | ||||
| if (!is_float) | if (!is_float) | ||||
| rgb = min(rgb, 1.0); | rgb = min(rgb, 1.0); | ||||
| } | } | ||||
| if (color_space == "sRGB") { | if (color_space == "sRGB") { | ||||
| rgb = color_srgb_to_scene_linear(rgb); | rgb = color_srgb_to_scene_linear(rgb); | ||||
| } | } | ||||
| return rgb; | return rgb; | ||||
| } | } | ||||
| shader node_image_texture( | shader node_image_texture( | ||||
| int use_mapping = 0, | int use_mapping = 0, | ||||
| matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), | matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), | ||||
| point Vector = P, | point Vector = P, | ||||
| string filename = "", | string filename = "", | ||||
| string color_space = "sRGB", | string color_space = "sRGB", | ||||
| string projection = "Flat", | string projection = "Flat", | ||||
| string interpolation = "smartcubic", | |||||
| float projection_blend = 0.0, | float projection_blend = 0.0, | ||||
| int is_float = 1, | int is_float = 1, | ||||
| int use_alpha = 1, | int use_alpha = 1, | ||||
| output color Color = 0.0, | output color Color = 0.0, | ||||
| output float Alpha = 1.0) | output float Alpha = 1.0) | ||||
| { | { | ||||
| point p = Vector; | point p = Vector; | ||||
| if (use_mapping) | if (use_mapping) | ||||
| p = transform(mapping, p); | p = transform(mapping, p); | ||||
| if (projection == "Flat") { | 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") { | else if (projection == "Box") { | ||||
| /* object space normal */ | /* object space normal */ | ||||
| vector Nob = transform("world", "object", N); | vector Nob = transform("world", "object", N); | ||||
| /* project from direction vector to barycentric coordinates in triangles */ | /* project from direction vector to barycentric coordinates in triangles */ | ||||
| Nob = vector(fabs(Nob[0]), fabs(Nob[1]), fabs(Nob[2])); | Nob = vector(fabs(Nob[0]), fabs(Nob[1]), fabs(Nob[2])); | ||||
| Nob /= (Nob[0] + Nob[1] + Nob[2]); | Nob /= (Nob[0] + Nob[1] + Nob[2]); | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | else if (projection == "Box") { | ||||
| } | } | ||||
| Color = color(0.0, 0.0, 0.0); | Color = color(0.0, 0.0, 0.0); | ||||
| Alpha = 0.0; | Alpha = 0.0; | ||||
| float tmp_alpha; | float tmp_alpha; | ||||
| if (weight[0] > 0.0) { | 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; | Alpha += weight[0] * tmp_alpha; | ||||
| } | } | ||||
| if (weight[1] > 0.0) { | 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; | Alpha += weight[1] * tmp_alpha; | ||||
| } | } | ||||
| if (weight[2] > 0.0) { | 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; | Alpha += weight[2] * tmp_alpha; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||