[Bf-blender-cvs] [6b03f92] master: Cycles Volume Render: optimization to avoid exporting surface attributes when only a volume shader is used.
Brecht Van Lommel
noreply at git.blender.org
Tue Dec 31 17:31:45 CET 2013
Commit: 6b03f92aa7bdb10cfde99bc30a7337c843bda57c
Author: Brecht Van Lommel
Date: Tue Dec 31 17:30:34 2013 +0100
https://developer.blender.org/rB6b03f92aa7bdb10cfde99bc30a7337c843bda57c
Cycles Volume Render: optimization to avoid exporting surface attributes when
only a volume shader is used.
===================================================================
M intern/cycles/render/graph.cpp
M intern/cycles/render/graph.h
M intern/cycles/render/nodes.cpp
M intern/cycles/render/nodes.h
M intern/cycles/render/osl.cpp
M intern/cycles/render/shader.cpp
M intern/cycles/render/svm.cpp
===================================================================
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 023b5db..af57470 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -116,7 +116,7 @@ ShaderOutput *ShaderNode::add_output(const char *name, ShaderSocketType type)
return output;
}
-void ShaderNode::attributes(AttributeRequestSet *attributes)
+void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
foreach(ShaderInput *input, inputs) {
if(!input->link) {
@@ -151,9 +151,9 @@ ShaderNode *ShaderGraph::add(ShaderNode *node)
return node;
}
-ShaderNode *ShaderGraph::output()
+OutputNode *ShaderGraph::output()
{
- return nodes.front();
+ return (OutputNode*)nodes.front();
}
ShaderGraph *ShaderGraph::copy()
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index dfa7371..f31e210 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -29,12 +29,14 @@
CCL_NAMESPACE_BEGIN
class AttributeRequestSet;
+class Shader;
class ShaderInput;
class ShaderOutput;
class ShaderNode;
class ShaderGraph;
class SVMCompiler;
class OSLCompiler;
+class OutputNode;
/* Socket Type
*
@@ -182,7 +184,7 @@ public:
ShaderOutput *add_output(const char *name, ShaderSocketType type);
virtual ShaderNode *clone() const = 0;
- virtual void attributes(AttributeRequestSet *attributes);
+ virtual void attributes(Shader *shader, AttributeRequestSet *attributes);
virtual void compile(SVMCompiler& compiler) = 0;
virtual void compile(OSLCompiler& compiler) = 0;
@@ -238,7 +240,7 @@ public:
ShaderGraph *copy();
ShaderNode *add(ShaderNode *node);
- ShaderNode *output();
+ OutputNode *output();
void connect(ShaderOutput *from, ShaderInput *to);
void disconnect(ShaderInput *to);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index d798865..c6c050c 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -217,19 +217,19 @@ ShaderNode *ImageTextureNode::clone() const
return node;
}
-void ImageTextureNode::attributes(AttributeRequestSet *attributes)
+void ImageTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
#ifdef WITH_PTEX
/* todo: avoid loading other texture coordinates when using ptex,
* and hide texture coordinate socket in the UI */
- if (string_endswith(filename, ".ptx")) {
+ if (shader->has_surface && string_endswith(filename, ".ptx")) {
/* ptex */
attributes->add(ATTR_STD_PTEX_FACE_ID);
attributes->add(ATTR_STD_PTEX_UV);
}
#endif
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void ImageTextureNode::compile(SVMCompiler& compiler)
@@ -367,17 +367,17 @@ ShaderNode *EnvironmentTextureNode::clone() const
return node;
}
-void EnvironmentTextureNode::attributes(AttributeRequestSet *attributes)
+void EnvironmentTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
#ifdef WITH_PTEX
- if (string_endswith(filename, ".ptx")) {
+ if (shader->has_surface && string_endswith(filename, ".ptx")) {
/* ptex */
attributes->add(ATTR_STD_PTEX_FACE_ID);
attributes->add(ATTR_STD_PTEX_UV);
}
#endif
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void EnvironmentTextureNode::compile(SVMCompiler& compiler)
@@ -1533,14 +1533,16 @@ WardBsdfNode::WardBsdfNode()
add_input("Rotation", SHADER_SOCKET_FLOAT, 0.0f);
}
-void WardBsdfNode::attributes(AttributeRequestSet *attributes)
+void WardBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
- ShaderInput *tangent_in = input("Tangent");
+ if(shader->has_surface) {
+ ShaderInput *tangent_in = input("Tangent");
- if(!tangent_in->link)
- attributes->add(ATTR_STD_GENERATED);
+ if(!tangent_in->link)
+ attributes->add(ATTR_STD_GENERATED);
+ }
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void WardBsdfNode::compile(SVMCompiler& compiler)
@@ -2088,12 +2090,14 @@ GeometryNode::GeometryNode()
add_output("Backfacing", SHADER_SOCKET_FLOAT);
}
-void GeometryNode::attributes(AttributeRequestSet *attributes)
+void GeometryNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
- if(!output("Tangent")->links.empty())
- attributes->add(ATTR_STD_GENERATED);
+ if(shader->has_surface) {
+ if(!output("Tangent")->links.empty())
+ attributes->add(ATTR_STD_GENERATED);
+ }
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void GeometryNode::compile(SVMCompiler& compiler)
@@ -2178,16 +2182,18 @@ TextureCoordinateNode::TextureCoordinateNode()
from_dupli = false;
}
-void TextureCoordinateNode::attributes(AttributeRequestSet *attributes)
+void TextureCoordinateNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
- if(!from_dupli) {
- if(!output("Generated")->links.empty())
- attributes->add(ATTR_STD_GENERATED);
- if(!output("UV")->links.empty())
- attributes->add(ATTR_STD_UV);
+ if(shader->has_surface) {
+ if(!from_dupli) {
+ if(!output("Generated")->links.empty())
+ attributes->add(ATTR_STD_GENERATED);
+ if(!output("UV")->links.empty())
+ attributes->add(ATTR_STD_UV);
+ }
}
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void TextureCoordinateNode::compile(SVMCompiler& compiler)
@@ -2490,7 +2496,7 @@ ParticleInfoNode::ParticleInfoNode()
add_output("Angular Velocity", SHADER_SOCKET_VECTOR);
}
-void ParticleInfoNode::attributes(AttributeRequestSet *attributes)
+void ParticleInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if(!output("Index")->links.empty())
attributes->add(ATTR_STD_PARTICLE);
@@ -2511,7 +2517,7 @@ void ParticleInfoNode::attributes(AttributeRequestSet *attributes)
if(!output("Angular Velocity")->links.empty())
attributes->add(ATTR_STD_PARTICLE);
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void ParticleInfoNode::compile(SVMCompiler& compiler)
@@ -2588,14 +2594,16 @@ HairInfoNode::HairInfoNode()
/*add_output("Fade", SHADER_SOCKET_FLOAT);*/
}
-void HairInfoNode::attributes(AttributeRequestSet *attributes)
+void HairInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
- ShaderOutput *intercept_out = output("Intercept");
+ if(shader->has_surface) {
+ ShaderOutput *intercept_out = output("Intercept");
- if(!intercept_out->links.empty())
- attributes->add(ATTR_STD_CURVE_INTERCEPT);
+ if(!intercept_out->links.empty())
+ attributes->add(ATTR_STD_CURVE_INTERCEPT);
+ }
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void HairInfoNode::compile(SVMCompiler& compiler)
@@ -3106,16 +3114,18 @@ AttributeNode::AttributeNode()
add_output("Fac", SHADER_SOCKET_FLOAT);
}
-void AttributeNode::attributes(AttributeRequestSet *attributes)
+void AttributeNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
- ShaderOutput *color_out = output("Color");
- ShaderOutput *vector_out = output("Vector");
- ShaderOutput *fac_out = output("Fac");
+ if(shader->has_surface) {
+ ShaderOutput *color_out = output("Color");
+ ShaderOutput *vector_out = output("Vector");
+ ShaderOutput *fac_out = output("Fac");
- if(!color_out->links.empty() || !vector_out->links.empty() || !fac_out->links.empty())
- attributes->add(attribute);
+ if(!color_out->links.empty() || !vector_out->links.empty() || !fac_out->links.empty())
+ attributes->add(attribute);
+ }
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void AttributeNode::compile(SVMCompiler& compiler)
@@ -3831,9 +3841,9 @@ NormalMapNode::NormalMapNode()
add_output("Normal", SHADER_SOCKET_NORMAL);
}
-void NormalMapNode::attributes(AttributeRequestSet *attributes)
+void NormalMapNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
- if(space == ustring("Tangent")) {
+ if(shader->has_surface && space == ustring("Tangent")) {
if(attribute == ustring("")) {
attributes->add(ATTR_STD_UV_TANGENT);
attributes->add(ATTR_STD_UV_TANGENT_SIGN);
@@ -3846,7 +3856,7 @@ void NormalMapNode::attributes(AttributeRequestSet *attributes)
attributes->add(ATTR_STD_VERTEX_NORMAL);
}
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void NormalMapNode::compile(SVMCompiler& compiler)
@@ -3935,18 +3945,20 @@ TangentNode::TangentNode()
add_output("Tangent", SHADER_SOCKET_NORMAL);
}
-void TangentNode::attributes(AttributeRequestSet *attributes)
+void TangentNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
- if(direction_type == ustring("UV Map")) {
- if(attribute == ustring(""))
- attributes->add(ATTR_STD_UV_TANGENT);
+ if(shader->has_surface) {
+ if(direction_type == ustring("UV Map")) {
+ if(attribute == ustring(""))
+ attributes->add(ATTR_STD_UV_TANGENT);
+ else
+ attributes->add(ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ }
else
- attributes->add(ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ attributes->add(ATTR_STD_GENERATED);
}
- else
- attributes->add(ATTR_STD_GENERATED);
- ShaderNode::attributes(attributes);
+ ShaderNode::attributes(shader, attributes);
}
void TangentNode::compile(SVMCompiler& compiler)
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 3634804..86c4f49 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -66,7 +66,7 @@ public:
SHADER_NODE_NO_CLONE_CLASS(ImageTextureNode)
~ImageTextureNode();
ShaderNode *clone() const;
- void attributes(AttributeRequestSet *attributes);
+ void attributes(Shader *shader, AttributeRequestSet *attributes);
ImageManager *image_manager;
int slot;
@@ -88,7 +88,7 @@ public:
SHADER_NODE_NO_CLONE_CLASS(EnvironmentTextureNode)
~EnvironmentTextureNode();
ShaderNode *clone() const;
- void attributes(AttributeRequestSet *attributes);
+ void attributes(Shader *shader, AttributeRequestSet *attributes);
ImageManager *image_manager;
int slot;
@@ -217,7 +217,7 @@ public:
class WardBsdfNode : public BsdfNo
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list