Fix #35812: cycles image texture node not doing proper alpha handling of PNG

images with open shading language enabled.
This commit is contained in:
Brecht Van Lommel
2013-06-21 13:05:10 +00:00
parent 2e3035dd80
commit 86c7bf7331
3 changed files with 11 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ shader node_environment_texture(
string projection = "Equirectangular",
string color_space = "sRGB",
int is_float = 1,
int use_alpha = 1,
output color Color = 0.0,
output float Alpha = 1.0)
{
@@ -67,7 +68,7 @@ shader node_environment_texture(
/* todo: use environment for better texture filtering of equirectangular */
Color = (color)texture(filename, p[0], 1.0 - p[1], "wrap", "periodic", "alpha", Alpha);
if (isconnected(Alpha)) {
if (use_alpha) {
Color = color_unpremultiply(Color, Alpha);
if (!is_float)

View File

@@ -30,8 +30,9 @@ color image_texture_lookup(string filename, string color_space, float u, float v
rgb = min(rgb, 1.0);
}
if (color_space == "sRGB")
if (color_space == "sRGB") {
rgb = color_srgb_to_scene_linear(rgb);
}
return rgb;
}
@@ -45,6 +46,7 @@ shader node_image_texture(
string projection = "Flat",
float projection_blend = 0.0,
int is_float = 1,
int use_alpha = 1,
output color Color = 0.0,
output float Alpha = 1.0)
{
@@ -53,8 +55,6 @@ shader node_image_texture(
if (use_mapping)
p = transform(mapping, p);
int use_alpha = isconnected(Alpha);
if (projection == "Flat") {
Color = image_texture_lookup(filename, color_space, p[0], p[1], Alpha, use_alpha, is_float);
}

View File

@@ -237,6 +237,8 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
void ImageTextureNode::compile(OSLCompiler& compiler)
{
ShaderOutput *alpha_out = output("Alpha");
tex_mapping.compile(compiler);
if(is_float == -1)
@@ -250,6 +252,7 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
compiler.parameter("projection", projection);
compiler.parameter("projection_blend", projection_blend);
compiler.parameter("is_float", is_float);
compiler.parameter("use_alpha", !alpha_out->links.empty());
compiler.add(this, "node_image_texture");
}
@@ -358,6 +361,8 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
void EnvironmentTextureNode::compile(OSLCompiler& compiler)
{
ShaderOutput *alpha_out = output("Alpha");
tex_mapping.compile(compiler);
if(is_float == -1)
@@ -370,6 +375,7 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler)
else
compiler.parameter("color_space", "sRGB");
compiler.parameter("is_float", is_float);
compiler.parameter("use_alpha", !alpha_out->links.empty());
compiler.add(this, "node_environment_texture");
}