diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2013-12-28 04:54:44 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2013-12-28 19:57:02 +0400 |
commit | a35db17cee5a9b47dc9624f7dfcb41f5fc185b33 (patch) | |
tree | ef23032da73b9b202490307f865e2afd4e2e7e76 /intern/cycles/render | |
parent | a06c9c277a8577f7ef473fffaf2258d2a3a6ab80 (diff) |
Cycles Volume Render: work on nodes and closures.
* Henyey-Greenstein scattering closure implementation.
* Rename transparent to absorption node and isotropic to scatter node.
* Volume density is folded into the closure weights.
* OSL support for volume closures and nodes.
* This commit has no user visible changes, there is no volume render code yet.
This is work by "storm", Stuart Broadfoot, Thomas Dinges and myself.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 37 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 8 | ||||
-rw-r--r-- | intern/cycles/render/osl.cpp | 19 |
3 files changed, 37 insertions, 27 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index c26ff7e7306..d7988656952 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1951,7 +1951,7 @@ void AmbientOcclusionNode::compile(OSLCompiler& compiler) VolumeNode::VolumeNode() : ShaderNode("volume") { - closure = CLOSURE_VOLUME_ISOTROPIC_ID; + closure = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID; add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); add_input("Density", SHADER_SOCKET_FLOAT, 1.0f); @@ -1995,38 +1995,40 @@ void VolumeNode::compile(OSLCompiler& compiler) assert(0); } -/* Transparent Volume Closure */ +/* Absorption Volume Closure */ -TransparentVolumeNode::TransparentVolumeNode() +AbsorptionVolumeNode::AbsorptionVolumeNode() { - closure = CLOSURE_VOLUME_TRANSPARENT_ID; + closure = CLOSURE_VOLUME_ABSORPTION_ID; } -void TransparentVolumeNode::compile(SVMCompiler& compiler) +void AbsorptionVolumeNode::compile(SVMCompiler& compiler) { VolumeNode::compile(compiler, input("Density"), NULL); } -void TransparentVolumeNode::compile(OSLCompiler& compiler) +void AbsorptionVolumeNode::compile(OSLCompiler& compiler) { - compiler.add(this, "node_transparent_volume"); + compiler.add(this, "node_absorption_volume"); } -/* Isotropic Volume Closure */ +/* Scatter Volume Closure */ -IsotropicVolumeNode::IsotropicVolumeNode() +ScatterVolumeNode::ScatterVolumeNode() { - closure = CLOSURE_VOLUME_ISOTROPIC_ID; + closure = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID; + + add_input("Anisotropy", SHADER_SOCKET_FLOAT, 0.0f); } -void IsotropicVolumeNode::compile(SVMCompiler& compiler) +void ScatterVolumeNode::compile(SVMCompiler& compiler) { - VolumeNode::compile(compiler, input("Density"), NULL); + VolumeNode::compile(compiler, input("Density"), input("Anisotropy")); } -void IsotropicVolumeNode::compile(OSLCompiler& compiler) +void ScatterVolumeNode::compile(OSLCompiler& compiler) { - compiler.add(this, "node_isotropic_volume"); + compiler.add(this, "node_scatter_volume"); } /* Hair BSDF Closure */ @@ -2304,6 +2306,7 @@ LightPathNode::LightPathNode() add_output("Is Singular Ray", SHADER_SOCKET_FLOAT); add_output("Is Reflection Ray", SHADER_SOCKET_FLOAT); add_output("Is Transmission Ray", SHADER_SOCKET_FLOAT); + add_output("Is Volume Scatter Ray", SHADER_SOCKET_FLOAT); add_output("Ray Length", SHADER_SOCKET_FLOAT); add_output("Ray Depth", SHADER_SOCKET_FLOAT); } @@ -2355,6 +2358,12 @@ void LightPathNode::compile(SVMCompiler& compiler) compiler.add_node(NODE_LIGHT_PATH, NODE_LP_transmission, out->stack_offset); } + out = output("Is Volume Scatter Ray"); + if(!out->links.empty()) { + compiler.stack_assign(out); + compiler.add_node(NODE_LIGHT_PATH, NODE_LP_volume_scatter, out->stack_offset); + } + out = output("Ray Length"); if(!out->links.empty()) { compiler.stack_assign(out); diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index d7a110af83b..36348044bbc 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -316,14 +316,14 @@ public: ClosureType closure; }; -class TransparentVolumeNode : public VolumeNode { +class AbsorptionVolumeNode : public VolumeNode { public: - SHADER_NODE_CLASS(TransparentVolumeNode) + SHADER_NODE_CLASS(AbsorptionVolumeNode) }; -class IsotropicVolumeNode : public VolumeNode { +class ScatterVolumeNode : public VolumeNode { public: - SHADER_NODE_CLASS(IsotropicVolumeNode) + SHADER_NODE_CLASS(ScatterVolumeNode) }; class HairBsdfNode : public BsdfNode { diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index 4ed8ece0556..043d8d138f6 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -195,15 +195,16 @@ void OSLShaderManager::shading_system_init() /* our own ray types */ static const char *raytypes[] = { - "camera", /* PATH_RAY_CAMERA */ - "reflection", /* PATH_RAY_REFLECT */ - "refraction", /* PATH_RAY_TRANSMIT */ - "diffuse", /* PATH_RAY_DIFFUSE */ - "glossy", /* PATH_RAY_GLOSSY */ - "singular", /* PATH_RAY_SINGULAR */ - "transparent", /* PATH_RAY_TRANSPARENT */ - "shadow", /* PATH_RAY_SHADOW_OPAQUE */ - "shadow", /* PATH_RAY_SHADOW_TRANSPARENT */ + "camera", /* PATH_RAY_CAMERA */ + "reflection", /* PATH_RAY_REFLECT */ + "refraction", /* PATH_RAY_TRANSMIT */ + "diffuse", /* PATH_RAY_DIFFUSE */ + "glossy", /* PATH_RAY_GLOSSY */ + "singular", /* PATH_RAY_SINGULAR */ + "transparent", /* PATH_RAY_TRANSPARENT */ + "volume_scatter", /* PATH_RAY_VOLUME_SCATTER */ + "shadow", /* PATH_RAY_SHADOW_OPAQUE */ + "shadow", /* PATH_RAY_SHADOW_TRANSPARENT */ "__unused__", "__unused__", |