Cycles: Fix filter glossy being broken after recent changes
Basically we can not use sharp closure as a substitude when filter glossy is used. This is because we can not blur sharp reflection/refraction. This is quite quick and not really clean implementation. Not really happy with manual handling of original settings, but this is as good as we can do in the quick patch. It's a good acknowledgment and we now can re-consider some aspects of graph simplification to make such cases more natively supported. P.S. This failure would have been shown by our regression tests, so please, bother a bit to run Cycles's test sweep before doing such optimizations.
This commit is contained in:
@@ -266,7 +266,10 @@ void ShaderGraph::relink(vector<ShaderInput*> inputs, vector<ShaderInput*> outpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderGraph::finalize(bool do_bump, bool do_osl)
|
void ShaderGraph::finalize(Scene *scene,
|
||||||
|
bool do_bump,
|
||||||
|
bool do_osl,
|
||||||
|
bool do_simplify)
|
||||||
{
|
{
|
||||||
/* before compiling, the shader graph may undergo a number of modifications.
|
/* before compiling, the shader graph may undergo a number of modifications.
|
||||||
* currently we set default geometry shader inputs, and create automatic bump
|
* currently we set default geometry shader inputs, and create automatic bump
|
||||||
@@ -274,7 +277,7 @@ void ShaderGraph::finalize(bool do_bump, bool do_osl)
|
|||||||
* modified afterwards. */
|
* modified afterwards. */
|
||||||
|
|
||||||
if(!finalized) {
|
if(!finalized) {
|
||||||
clean();
|
clean(scene);
|
||||||
default_inputs(do_osl);
|
default_inputs(do_osl);
|
||||||
refine_bump_nodes();
|
refine_bump_nodes();
|
||||||
|
|
||||||
@@ -293,6 +296,9 @@ void ShaderGraph::finalize(bool do_bump, bool do_osl)
|
|||||||
|
|
||||||
finalized = true;
|
finalized = true;
|
||||||
}
|
}
|
||||||
|
else if(do_simplify) {
|
||||||
|
simplify_nodes(scene);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderGraph::find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input)
|
void ShaderGraph::find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input)
|
||||||
@@ -557,10 +563,10 @@ void ShaderGraph::remove_unneeded_nodes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Step 3: Simplification.*/
|
/* Step 3: Simplification.*/
|
||||||
void ShaderGraph::simplify_nodes()
|
void ShaderGraph::simplify_nodes(Scene *scene)
|
||||||
{
|
{
|
||||||
foreach(ShaderNode *node, nodes) {
|
foreach(ShaderNode *node, nodes) {
|
||||||
node->optimize();
|
node->optimize(scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,7 +594,7 @@ void ShaderGraph::break_cycles(ShaderNode *node, vector<bool>& visited, vector<b
|
|||||||
on_stack[node->id] = false;
|
on_stack[node->id] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderGraph::clean()
|
void ShaderGraph::clean(Scene *scene)
|
||||||
{
|
{
|
||||||
/* Graph simplification:
|
/* Graph simplification:
|
||||||
* 1: Remove unnecesarry nodes
|
* 1: Remove unnecesarry nodes
|
||||||
@@ -604,7 +610,7 @@ void ShaderGraph::clean()
|
|||||||
/* TODO(dingto): Implement */
|
/* TODO(dingto): Implement */
|
||||||
|
|
||||||
/* 3: Simplification. */
|
/* 3: Simplification. */
|
||||||
simplify_nodes();
|
simplify_nodes(scene);
|
||||||
|
|
||||||
/* 4: De-duplication. */
|
/* 4: De-duplication. */
|
||||||
/* TODO(dingto): Implement */
|
/* TODO(dingto): Implement */
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class AttributeRequestSet;
|
class AttributeRequestSet;
|
||||||
|
class Scene;
|
||||||
class Shader;
|
class Shader;
|
||||||
class ShaderInput;
|
class ShaderInput;
|
||||||
class ShaderOutput;
|
class ShaderOutput;
|
||||||
@@ -196,7 +197,7 @@ public:
|
|||||||
virtual void attributes(Shader *shader, AttributeRequestSet *attributes);
|
virtual void attributes(Shader *shader, AttributeRequestSet *attributes);
|
||||||
virtual void compile(SVMCompiler& compiler) = 0;
|
virtual void compile(SVMCompiler& compiler) = 0;
|
||||||
virtual void compile(OSLCompiler& compiler) = 0;
|
virtual void compile(OSLCompiler& compiler) = 0;
|
||||||
virtual void optimize() {};
|
virtual void optimize(Scene * /*scene*/) {};
|
||||||
|
|
||||||
virtual bool has_surface_emission() { return false; }
|
virtual bool has_surface_emission() { return false; }
|
||||||
virtual bool has_surface_transparent() { return false; }
|
virtual bool has_surface_transparent() { return false; }
|
||||||
@@ -204,6 +205,7 @@ public:
|
|||||||
virtual bool has_bssrdf_bump() { return false; }
|
virtual bool has_bssrdf_bump() { return false; }
|
||||||
virtual bool has_spatial_varying() { return false; }
|
virtual bool has_spatial_varying() { return false; }
|
||||||
virtual bool has_object_dependency() { return false; }
|
virtual bool has_object_dependency() { return false; }
|
||||||
|
virtual bool has_integrator_dependency() { return false; }
|
||||||
|
|
||||||
vector<ShaderInput*> inputs;
|
vector<ShaderInput*> inputs;
|
||||||
vector<ShaderOutput*> outputs;
|
vector<ShaderOutput*> outputs;
|
||||||
@@ -276,8 +278,10 @@ public:
|
|||||||
void relink(vector<ShaderInput*> inputs, vector<ShaderInput*> outputs, ShaderOutput *output);
|
void relink(vector<ShaderInput*> inputs, vector<ShaderInput*> outputs, ShaderOutput *output);
|
||||||
|
|
||||||
void remove_unneeded_nodes();
|
void remove_unneeded_nodes();
|
||||||
void simplify_nodes();
|
void finalize(Scene *scene,
|
||||||
void finalize(bool do_bump = false, bool do_osl = false);
|
bool do_bump = false,
|
||||||
|
bool do_osl = false,
|
||||||
|
bool do_simplify = false);
|
||||||
|
|
||||||
int get_num_closures();
|
int get_num_closures();
|
||||||
|
|
||||||
@@ -290,7 +294,8 @@ protected:
|
|||||||
void copy_nodes(set<ShaderNode*>& nodes, map<ShaderNode*, ShaderNode*>& nnodemap);
|
void copy_nodes(set<ShaderNode*>& nodes, map<ShaderNode*, ShaderNode*>& nnodemap);
|
||||||
|
|
||||||
void break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack);
|
void break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack);
|
||||||
void clean();
|
void clean(Scene *scene);
|
||||||
|
void simplify_nodes(Scene *scene);
|
||||||
void bump_from_displacement();
|
void bump_from_displacement();
|
||||||
void refine_bump_nodes();
|
void refine_bump_nodes();
|
||||||
void default_inputs(bool do_osl);
|
void default_inputs(bool do_osl);
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "integrator.h"
|
#include "integrator.h"
|
||||||
#include "light.h"
|
#include "light.h"
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
|
#include "shader.h"
|
||||||
#include "sobol.h"
|
#include "sobol.h"
|
||||||
|
|
||||||
#include "util_foreach.h"
|
#include "util_foreach.h"
|
||||||
@@ -217,8 +218,14 @@ bool Integrator::modified(const Integrator& integrator)
|
|||||||
sample_all_lights_indirect == integrator.sample_all_lights_indirect);
|
sample_all_lights_indirect == integrator.sample_all_lights_indirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Integrator::tag_update(Scene * /*scene*/)
|
void Integrator::tag_update(Scene *scene)
|
||||||
{
|
{
|
||||||
|
foreach(Shader *shader, scene->shaders) {
|
||||||
|
if(shader->has_integrator_dependency) {
|
||||||
|
scene->shader_manager->need_update = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "integrator.h"
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
|
#include "scene.h"
|
||||||
#include "svm.h"
|
#include "svm.h"
|
||||||
#include "svm_math_util.h"
|
#include "svm_math_util.h"
|
||||||
#include "osl.h"
|
#include "osl.h"
|
||||||
@@ -1874,20 +1876,37 @@ GlossyBsdfNode::GlossyBsdfNode()
|
|||||||
{
|
{
|
||||||
closure = CLOSURE_BSDF_MICROFACET_GGX_ID;
|
closure = CLOSURE_BSDF_MICROFACET_GGX_ID;
|
||||||
distribution = ustring("GGX");
|
distribution = ustring("GGX");
|
||||||
|
distribution_orig = ustring("");
|
||||||
|
|
||||||
add_input("Roughness", SHADER_SOCKET_FLOAT, 0.2f);
|
add_input("Roughness", SHADER_SOCKET_FLOAT, 0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlossyBsdfNode::optimize()
|
void GlossyBsdfNode::optimize(Scene *scene)
|
||||||
{
|
{
|
||||||
/* Fallback to Sharp closure for Roughness close to 0.
|
if(distribution_orig == "") {
|
||||||
* Note: Keep the epsilon in sync with kernel!
|
distribution_orig = distribution;
|
||||||
*/
|
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
|
||||||
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
|
||||||
closure = CLOSURE_BSDF_REFLECTION_ID;
|
|
||||||
distribution = ustring("Sharp");
|
|
||||||
}
|
}
|
||||||
|
Integrator *integrator = scene->integrator;
|
||||||
|
if(integrator->filter_glossy == 0.0f) {
|
||||||
|
/* Fallback to Sharp closure for Roughness close to 0.
|
||||||
|
* Note: Keep the epsilon in sync with kernel!
|
||||||
|
*/
|
||||||
|
ShaderInput *roughness_input = get_input("Roughness");
|
||||||
|
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
||||||
|
distribution = ustring("Sharp");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Rollback to original distribution when filter glossy is used. */
|
||||||
|
distribution = distribution_orig;
|
||||||
|
}
|
||||||
|
closure = (ClosureType)distribution_enum[distribution];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GlossyBsdfNode::has_integrator_dependency()
|
||||||
|
{
|
||||||
|
ShaderInput *roughness_input = get_input("Roughness");
|
||||||
|
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlossyBsdfNode::compile(SVMCompiler& compiler)
|
void GlossyBsdfNode::compile(SVMCompiler& compiler)
|
||||||
@@ -1925,21 +1944,38 @@ GlassBsdfNode::GlassBsdfNode()
|
|||||||
{
|
{
|
||||||
closure = CLOSURE_BSDF_SHARP_GLASS_ID;
|
closure = CLOSURE_BSDF_SHARP_GLASS_ID;
|
||||||
distribution = ustring("Sharp");
|
distribution = ustring("Sharp");
|
||||||
|
distribution_orig = ustring("");
|
||||||
|
|
||||||
add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f);
|
add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f);
|
||||||
add_input("IOR", SHADER_SOCKET_FLOAT, 0.3f);
|
add_input("IOR", SHADER_SOCKET_FLOAT, 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlassBsdfNode::optimize()
|
void GlassBsdfNode::optimize(Scene *scene)
|
||||||
{
|
{
|
||||||
/* Fallback to Sharp closure for Roughness close to 0.
|
if(distribution_orig == "") {
|
||||||
* Note: Keep the epsilon in sync with kernel!
|
distribution_orig = distribution;
|
||||||
*/
|
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
|
||||||
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
|
||||||
closure = CLOSURE_BSDF_SHARP_GLASS_ID;
|
|
||||||
distribution = ustring("Sharp");
|
|
||||||
}
|
}
|
||||||
|
Integrator *integrator = scene->integrator;
|
||||||
|
if(integrator->filter_glossy == 0.0f) {
|
||||||
|
/* Fallback to Sharp closure for Roughness close to 0.
|
||||||
|
* Note: Keep the epsilon in sync with kernel!
|
||||||
|
*/
|
||||||
|
ShaderInput *roughness_input = get_input("Roughness");
|
||||||
|
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
||||||
|
distribution = ustring("Sharp");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Rollback to original distribution when filter glossy is used. */
|
||||||
|
distribution = distribution_orig;
|
||||||
|
}
|
||||||
|
closure = (ClosureType)distribution_enum[distribution];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GlassBsdfNode::has_integrator_dependency()
|
||||||
|
{
|
||||||
|
ShaderInput *roughness_input = get_input("Roughness");
|
||||||
|
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlassBsdfNode::compile(SVMCompiler& compiler)
|
void GlassBsdfNode::compile(SVMCompiler& compiler)
|
||||||
@@ -1977,21 +2013,38 @@ RefractionBsdfNode::RefractionBsdfNode()
|
|||||||
{
|
{
|
||||||
closure = CLOSURE_BSDF_REFRACTION_ID;
|
closure = CLOSURE_BSDF_REFRACTION_ID;
|
||||||
distribution = ustring("Sharp");
|
distribution = ustring("Sharp");
|
||||||
|
distribution_orig = ustring("");
|
||||||
|
|
||||||
add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f);
|
add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f);
|
||||||
add_input("IOR", SHADER_SOCKET_FLOAT, 0.3f);
|
add_input("IOR", SHADER_SOCKET_FLOAT, 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefractionBsdfNode::optimize()
|
void RefractionBsdfNode::optimize(Scene *scene)
|
||||||
{
|
{
|
||||||
/* Fallback to Sharp closure for Roughness close to 0.
|
if(distribution_orig == "") {
|
||||||
* Note: Keep the epsilon in sync with kernel!
|
distribution_orig = distribution;
|
||||||
*/
|
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
|
||||||
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
|
||||||
closure = CLOSURE_BSDF_REFRACTION_ID;
|
|
||||||
distribution = ustring("Sharp");
|
|
||||||
}
|
}
|
||||||
|
Integrator *integrator = scene->integrator;
|
||||||
|
if(integrator->filter_glossy == 0.0f) {
|
||||||
|
/* Fallback to Sharp closure for Roughness close to 0.
|
||||||
|
* Note: Keep the epsilon in sync with kernel!
|
||||||
|
*/
|
||||||
|
ShaderInput *roughness_input = get_input("Roughness");
|
||||||
|
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
||||||
|
distribution = ustring("Sharp");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Rollback to original distribution when filter glossy is used. */
|
||||||
|
distribution = distribution_orig;
|
||||||
|
}
|
||||||
|
closure = (ClosureType)distribution_enum[distribution];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RefractionBsdfNode::has_integrator_dependency()
|
||||||
|
{
|
||||||
|
ShaderInput *roughness_input = get_input("Roughness");
|
||||||
|
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefractionBsdfNode::compile(SVMCompiler& compiler)
|
void RefractionBsdfNode::compile(SVMCompiler& compiler)
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class ImageManager;
|
class ImageManager;
|
||||||
|
class Scene;
|
||||||
class Shader;
|
class Shader;
|
||||||
|
|
||||||
/* Texture Mapping */
|
/* Texture Mapping */
|
||||||
@@ -310,9 +311,10 @@ class GlossyBsdfNode : public BsdfNode {
|
|||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(GlossyBsdfNode)
|
SHADER_NODE_CLASS(GlossyBsdfNode)
|
||||||
|
|
||||||
void optimize();
|
void optimize(Scene *scene);
|
||||||
|
bool has_integrator_dependency();
|
||||||
|
|
||||||
ustring distribution;
|
ustring distribution, distribution_orig;
|
||||||
static ShaderEnum distribution_enum;
|
static ShaderEnum distribution_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -320,9 +322,10 @@ class GlassBsdfNode : public BsdfNode {
|
|||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(GlassBsdfNode)
|
SHADER_NODE_CLASS(GlassBsdfNode)
|
||||||
|
|
||||||
void optimize();
|
void optimize(Scene *scene);
|
||||||
|
bool has_integrator_dependency();
|
||||||
|
|
||||||
ustring distribution;
|
ustring distribution, distribution_orig;
|
||||||
static ShaderEnum distribution_enum;
|
static ShaderEnum distribution_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -330,9 +333,10 @@ class RefractionBsdfNode : public BsdfNode {
|
|||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(RefractionBsdfNode)
|
SHADER_NODE_CLASS(RefractionBsdfNode)
|
||||||
|
|
||||||
void optimize();
|
void optimize(Scene *scene);
|
||||||
|
bool has_integrator_dependency();
|
||||||
|
|
||||||
ustring distribution;
|
ustring distribution, distribution_orig;
|
||||||
static ShaderEnum distribution_enum;
|
static ShaderEnum distribution_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
|
|||||||
|
|
||||||
OSLCompiler compiler((void*)this, (void*)ss, scene->image_manager);
|
OSLCompiler compiler((void*)this, (void*)ss, scene->image_manager);
|
||||||
compiler.background = (shader == scene->shaders[scene->default_background]);
|
compiler.background = (shader == scene->shaders[scene->default_background]);
|
||||||
compiler.compile(og, shader);
|
compiler.compile(scene, og, shader);
|
||||||
|
|
||||||
if(shader->use_mis && shader->has_surface_emission)
|
if(shader->use_mis && shader->has_surface_emission)
|
||||||
scene->light_manager->need_update = true;
|
scene->light_manager->need_update = true;
|
||||||
@@ -573,6 +573,10 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
|
|||||||
if(node->has_object_dependency()) {
|
if(node->has_object_dependency()) {
|
||||||
current_shader->has_object_dependency = true;
|
current_shader->has_object_dependency = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(node->has_integrator_dependency()) {
|
||||||
|
current_shader->has_integrator_dependency = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSLCompiler::parameter(const char *name, float f)
|
void OSLCompiler::parameter(const char *name, float f)
|
||||||
@@ -788,7 +792,7 @@ OSL::ShadingAttribStateRef OSLCompiler::compile_type(Shader *shader, ShaderGraph
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
|
void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
|
||||||
{
|
{
|
||||||
if(shader->need_update) {
|
if(shader->need_update) {
|
||||||
ShaderGraph *graph = shader->graph;
|
ShaderGraph *graph = shader->graph;
|
||||||
@@ -800,9 +804,16 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
|
|||||||
shader->graph_bump = shader->graph->copy();
|
shader->graph_bump = shader->graph->copy();
|
||||||
|
|
||||||
/* finalize */
|
/* finalize */
|
||||||
shader->graph->finalize(false, true);
|
shader->graph->finalize(scene,
|
||||||
if(shader->graph_bump)
|
false,
|
||||||
shader->graph_bump->finalize(true, true);
|
true,
|
||||||
|
shader->has_integrator_dependency);
|
||||||
|
if(shader->graph_bump) {
|
||||||
|
shader->graph_bump->finalize(scene,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
shader->has_integrator_dependency);
|
||||||
|
}
|
||||||
|
|
||||||
current_shader = shader;
|
current_shader = shader;
|
||||||
|
|
||||||
@@ -815,6 +826,7 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
|
|||||||
shader->has_displacement = false;
|
shader->has_displacement = false;
|
||||||
shader->has_heterogeneous_volume = false;
|
shader->has_heterogeneous_volume = false;
|
||||||
shader->has_object_dependency = false;
|
shader->has_object_dependency = false;
|
||||||
|
shader->has_integrator_dependency = false;
|
||||||
|
|
||||||
/* generate surface shader */
|
/* generate surface shader */
|
||||||
if(shader->used && graph && output->input("Surface")->link) {
|
if(shader->used && graph && output->input("Surface")->link) {
|
||||||
|
@@ -113,7 +113,7 @@ protected:
|
|||||||
class OSLCompiler {
|
class OSLCompiler {
|
||||||
public:
|
public:
|
||||||
OSLCompiler(void *manager, void *shadingsys, ImageManager *image_manager);
|
OSLCompiler(void *manager, void *shadingsys, ImageManager *image_manager);
|
||||||
void compile(OSLGlobals *og, Shader *shader);
|
void compile(Scene *scene, OSLGlobals *og, Shader *shader);
|
||||||
|
|
||||||
void add(ShaderNode *node, const char *name, bool isfilepath = false);
|
void add(ShaderNode *node, const char *name, bool isfilepath = false);
|
||||||
|
|
||||||
|
@@ -154,6 +154,7 @@ Shader::Shader()
|
|||||||
has_bssrdf_bump = false;
|
has_bssrdf_bump = false;
|
||||||
has_heterogeneous_volume = false;
|
has_heterogeneous_volume = false;
|
||||||
has_object_dependency = false;
|
has_object_dependency = false;
|
||||||
|
has_integrator_dependency = false;
|
||||||
|
|
||||||
used = false;
|
used = false;
|
||||||
|
|
||||||
|
@@ -107,6 +107,7 @@ public:
|
|||||||
bool has_bssrdf_bump;
|
bool has_bssrdf_bump;
|
||||||
bool has_heterogeneous_volume;
|
bool has_heterogeneous_volume;
|
||||||
bool has_object_dependency;
|
bool has_object_dependency;
|
||||||
|
bool has_integrator_dependency;
|
||||||
|
|
||||||
/* requested mesh attributes */
|
/* requested mesh attributes */
|
||||||
AttributeRequestSet attributes;
|
AttributeRequestSet attributes;
|
||||||
|
@@ -78,7 +78,7 @@ void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
|
|||||||
|
|
||||||
SVMCompiler compiler(scene->shader_manager, scene->image_manager);
|
SVMCompiler compiler(scene->shader_manager, scene->image_manager);
|
||||||
compiler.background = ((int)i == scene->default_background);
|
compiler.background = ((int)i == scene->default_background);
|
||||||
compiler.compile(shader, svm_nodes, i);
|
compiler.compile(scene, shader, svm_nodes, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
dscene->svm_nodes.copy((uint4*)&svm_nodes[0], svm_nodes.size());
|
dscene->svm_nodes.copy((uint4*)&svm_nodes[0], svm_nodes.size());
|
||||||
@@ -396,6 +396,10 @@ void SVMCompiler::generate_node(ShaderNode *node, set<ShaderNode*>& done)
|
|||||||
if(node->has_object_dependency()) {
|
if(node->has_object_dependency()) {
|
||||||
current_shader->has_object_dependency = true;
|
current_shader->has_object_dependency = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(node->has_integrator_dependency()) {
|
||||||
|
current_shader->has_integrator_dependency = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVMCompiler::generate_svm_nodes(const set<ShaderNode*>& nodes, set<ShaderNode*>& done)
|
void SVMCompiler::generate_svm_nodes(const set<ShaderNode*>& nodes, set<ShaderNode*>& done)
|
||||||
@@ -691,7 +695,10 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
|
|||||||
add_node(NODE_END, 0, 0, 0);
|
add_node(NODE_END, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int index)
|
void SVMCompiler::compile(Scene *scene,
|
||||||
|
Shader *shader,
|
||||||
|
vector<int4>& global_svm_nodes,
|
||||||
|
int index)
|
||||||
{
|
{
|
||||||
/* copy graph for shader with bump mapping */
|
/* copy graph for shader with bump mapping */
|
||||||
ShaderNode *node = shader->graph->output();
|
ShaderNode *node = shader->graph->output();
|
||||||
@@ -701,9 +708,16 @@ void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int in
|
|||||||
shader->graph_bump = shader->graph->copy();
|
shader->graph_bump = shader->graph->copy();
|
||||||
|
|
||||||
/* finalize */
|
/* finalize */
|
||||||
shader->graph->finalize(false, false);
|
shader->graph->finalize(scene,
|
||||||
if(shader->graph_bump)
|
false,
|
||||||
shader->graph_bump->finalize(true, false);
|
false,
|
||||||
|
shader->has_integrator_dependency);
|
||||||
|
if(shader->graph_bump) {
|
||||||
|
shader->graph_bump->finalize(scene,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
shader->has_integrator_dependency);
|
||||||
|
}
|
||||||
|
|
||||||
current_shader = shader;
|
current_shader = shader;
|
||||||
|
|
||||||
@@ -716,6 +730,7 @@ void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int in
|
|||||||
shader->has_displacement = false;
|
shader->has_displacement = false;
|
||||||
shader->has_heterogeneous_volume = false;
|
shader->has_heterogeneous_volume = false;
|
||||||
shader->has_object_dependency = false;
|
shader->has_object_dependency = false;
|
||||||
|
shader->has_integrator_dependency = false;
|
||||||
|
|
||||||
/* generate surface shader */
|
/* generate surface shader */
|
||||||
compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
|
compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
|
||||||
|
@@ -53,7 +53,10 @@ public:
|
|||||||
class SVMCompiler {
|
class SVMCompiler {
|
||||||
public:
|
public:
|
||||||
SVMCompiler(ShaderManager *shader_manager, ImageManager *image_manager);
|
SVMCompiler(ShaderManager *shader_manager, ImageManager *image_manager);
|
||||||
void compile(Shader *shader, vector<int4>& svm_nodes, int index);
|
void compile(Scene *scene,
|
||||||
|
Shader *shader,
|
||||||
|
vector<int4>& svm_nodes,
|
||||||
|
int index);
|
||||||
|
|
||||||
void stack_assign(ShaderOutput *output);
|
void stack_assign(ShaderOutput *output);
|
||||||
void stack_assign(ShaderInput *input);
|
void stack_assign(ShaderInput *input);
|
||||||
|
Reference in New Issue
Block a user