[Bf-blender-cvs] [83988b6] master: Fix new Cycles UV Map node not working correct for bump mapping.

Kevin Dietrich noreply at git.blender.org
Mon Apr 21 14:45:30 CEST 2014


Commit: 83988b6cdd181fb572b2f4dd078c165a583497fd
Author: Kevin Dietrich
Date:   Mon Apr 21 13:15:45 2014 +0200
https://developer.blender.org/rB83988b6cdd181fb572b2f4dd078c165a583497fd

Fix new Cycles UV Map node not working correct for bump mapping.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D475

===================================================================

M	intern/cycles/kernel/shaders/node_uv_map.osl
M	intern/cycles/render/nodes.cpp

===================================================================

diff --git a/intern/cycles/kernel/shaders/node_uv_map.osl b/intern/cycles/kernel/shaders/node_uv_map.osl
index fd039be..01c984a 100644
--- a/intern/cycles/kernel/shaders/node_uv_map.osl
+++ b/intern/cycles/kernel/shaders/node_uv_map.osl
@@ -17,18 +17,29 @@
 #include "stdosl.h"
 
 shader node_uv_map(
-	string name = "",
 	int from_dupli = 0,
+	string name = "",
+	string bump_offset = "center",
 	output point UV = point(0.0, 0.0, 0.0))
-
 {
 	if (from_dupli) {
 		getattribute("geom:dupli_uv", UV);
 	}
 	else {
-        if (name == "") 
-		    getattribute("geom:uv", UV);        
-        else 
-            getattribute(name, UV);        
+		if (name == "")
+			getattribute("geom:uv", UV);
+		else
+			getattribute(name, UV);
+	}
+
+	if (bump_offset == "dx") {
+		if (!from_dupli) {
+			UV += Dx(UV);
+		}
+	}
+	else if (bump_offset == "dy") {
+		if (!from_dupli) {
+			UV += Dy(UV);
+		}
 	}
 }
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 908acb3..576dcec 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -2360,6 +2360,15 @@ void UVMapNode::compile(SVMCompiler& compiler)
 	NodeType attr_node = NODE_ATTR;
 	int attr;
 
+	if(bump == SHADER_BUMP_DX) {
+		texco_node = NODE_TEX_COORD_BUMP_DX;
+		attr_node = NODE_ATTR_BUMP_DX;
+	}
+	else if(bump == SHADER_BUMP_DY) {
+		texco_node = NODE_TEX_COORD_BUMP_DY;
+		attr_node = NODE_ATTR_BUMP_DY;
+	}
+
 	if(!out->links.empty()) {
 		if(from_dupli) {
 			compiler.stack_assign(out);
@@ -2379,6 +2388,13 @@ void UVMapNode::compile(SVMCompiler& compiler)
 
 void UVMapNode::compile(OSLCompiler& compiler)
 {
+	if(bump == SHADER_BUMP_DX)
+		compiler.parameter("bump_offset", "dx");
+	else if(bump == SHADER_BUMP_DY)
+		compiler.parameter("bump_offset", "dy");
+	else
+		compiler.parameter("bump_offset", "center");
+
 	compiler.parameter("from_dupli", from_dupli);
 	compiler.parameter("name", attribute.c_str());
 	compiler.add(this, "node_uv_map");




More information about the Bf-blender-cvs mailing list