Revision: 57637
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57637
Author:   blendix
Date:     2013-06-21 13:05:10 +0000 (Fri, 21 Jun 2013)
Log Message:
-----------
Fix #35812: cycles image texture node not doing proper alpha handling of PNG
images with open shading language enabled.

Modified Paths:
--------------
    trunk/blender/intern/cycles/kernel/shaders/node_environment_texture.osl
    trunk/blender/intern/cycles/kernel/shaders/node_image_texture.osl
    trunk/blender/intern/cycles/render/nodes.cpp

Modified: 
trunk/blender/intern/cycles/kernel/shaders/node_environment_texture.osl
===================================================================
--- trunk/blender/intern/cycles/kernel/shaders/node_environment_texture.osl     
2013-06-21 13:05:08 UTC (rev 57636)
+++ trunk/blender/intern/cycles/kernel/shaders/node_environment_texture.osl     
2013-06-21 13:05:10 UTC (rev 57637)
@@ -49,6 +49,7 @@
        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 @@
        /* 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)

Modified: trunk/blender/intern/cycles/kernel/shaders/node_image_texture.osl
===================================================================
--- trunk/blender/intern/cycles/kernel/shaders/node_image_texture.osl   
2013-06-21 13:05:08 UTC (rev 57636)
+++ trunk/blender/intern/cycles/kernel/shaders/node_image_texture.osl   
2013-06-21 13:05:10 UTC (rev 57637)
@@ -30,8 +30,9 @@
                        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 @@
        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 @@
        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);
        }

Modified: trunk/blender/intern/cycles/render/nodes.cpp
===================================================================
--- trunk/blender/intern/cycles/render/nodes.cpp        2013-06-21 13:05:08 UTC 
(rev 57636)
+++ trunk/blender/intern/cycles/render/nodes.cpp        2013-06-21 13:05:10 UTC 
(rev 57637)
@@ -237,6 +237,8 @@
 
 void ImageTextureNode::compile(OSLCompiler& compiler)
 {
+       ShaderOutput *alpha_out = output("Alpha");
+
        tex_mapping.compile(compiler);
 
        if(is_float == -1)
@@ -250,6 +252,7 @@
        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(OSLCompiler& compiler)
 {
+       ShaderOutput *alpha_out = output("Alpha");
+
        tex_mapping.compile(compiler);
 
        if(is_float == -1)
@@ -370,6 +375,7 @@
        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");
 }
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to