Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMai Lavelle <mai.lavelle@gmail.com>2016-09-02 07:41:04 +0300
committerMai Lavelle <mai.lavelle@gmail.com>2016-09-11 18:20:21 +0300
commit92a2c49aab55a2c459a8f6d50e730bdcda966eb5 (patch)
tree8524d21897c5c2b4da74f08ef7b27046c8682eed /intern/cycles/render/graph.cpp
parentac2fe8312bd2a609eb884ad95dd27bcbbf7f1b0e (diff)
Cycles: Fix bump mapping to use object space when used with true displacement
Bump mapping was happening in world space while displacement happens in object space, causing shading errors when displacement type was used with bump mapping. To fix this the proper transforms are added to bump nodes. This is only done for automatic bump mapping however, to avoid visual changes from other uses of bump mapping. It would be nice to do this for all bump mapping to be consistent but that will have to wait till we can break compatibility. Reviewed By: brecht Differential Revision: https://developer.blender.org/D2191
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r--intern/cycles/render/graph.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 57256ceecd3..9ee8b674412 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -312,7 +312,8 @@ void ShaderGraph::relink(ShaderNode *node, ShaderOutput *from, ShaderOutput *to)
void ShaderGraph::finalize(Scene *scene,
bool do_bump,
bool do_osl,
- bool do_simplify)
+ bool do_simplify,
+ bool bump_in_object_space)
{
/* before compiling, the shader graph may undergo a number of modifications.
* currently we set default geometry shader inputs, and create automatic bump
@@ -325,7 +326,7 @@ void ShaderGraph::finalize(Scene *scene,
refine_bump_nodes();
if(do_bump)
- bump_from_displacement();
+ bump_from_displacement(bump_in_object_space);
ShaderInput *surface_in = output()->input("Surface");
ShaderInput *volume_in = output()->input("Volume");
@@ -793,7 +794,7 @@ void ShaderGraph::refine_bump_nodes()
}
}
-void ShaderGraph::bump_from_displacement()
+void ShaderGraph::bump_from_displacement(bool use_object_space)
{
/* generate bump mapping automatically from displacement. bump mapping is
* done using a 3-tap filter, computing the displacement at the center,
@@ -842,7 +843,8 @@ void ShaderGraph::bump_from_displacement()
ShaderNode *set_normal = add(new SetNormalNode());
/* add bump node and connect copied graphs to it */
- ShaderNode *bump = add(new BumpNode());
+ BumpNode *bump = (BumpNode*)add(new BumpNode());
+ bump->use_object_space = use_object_space;
ShaderOutput *out = displacement_in->link;
ShaderOutput *out_center = nodes_center[out->parent]->output(out->name());