Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/shader.cpp
| Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | void Shader::set_graph(ShaderGraph *graph_) | ||||
| /* assign graph */ | /* assign graph */ | ||||
| delete graph; | delete graph; | ||||
| delete graph_bump; | delete graph_bump; | ||||
| graph = graph_; | graph = graph_; | ||||
| graph_bump = NULL; | graph_bump = NULL; | ||||
| } | } | ||||
| void Shader::update_attributes(Scene *scene) | |||||
| { | |||||
| AttributeRequestSet prev_attributes = attributes; | |||||
| attributes.clear(); | |||||
| foreach(ShaderNode *node, graph->nodes) | |||||
| node->attributes(this, &attributes); | |||||
| if(has_displacement && displacement_method == DISPLACE_BOTH) { | |||||
| attributes.add(ATTR_STD_POSITION_UNDISPLACED); | |||||
| } | |||||
| /* compare if the attributes changed, mesh manager will check | |||||
| * need_update_attributes, update the relevant meshes and clear it. */ | |||||
| if(attributes.modified(prev_attributes)) { | |||||
| need_update_attributes = true; | |||||
| scene->mesh_manager->need_update = true; | |||||
| } | |||||
| } | |||||
| void Shader::tag_update(Scene *scene) | void Shader::tag_update(Scene *scene) | ||||
| { | { | ||||
| /* update tag */ | /* update tag */ | ||||
| need_update = true; | need_update = true; | ||||
| scene->shader_manager->need_update = true; | scene->shader_manager->need_update = true; | ||||
| /* if the shader previously was emissive, update light distribution, | /* if the shader previously was emissive, update light distribution, | ||||
| * if the new shader is emissive, a light manager update tag will be | * if the new shader is emissive, a light manager update tag will be | ||||
| Show All 15 Lines | void Shader::tag_update(Scene *scene) | ||||
| * e.g. surface attributes when there is only a volume shader. this could | * e.g. surface attributes when there is only a volume shader. this could | ||||
| * be more fine grained but it's better than nothing */ | * be more fine grained but it's better than nothing */ | ||||
| OutputNode *output = graph->output(); | OutputNode *output = graph->output(); | ||||
| bool prev_has_volume = has_volume; | bool prev_has_volume = has_volume; | ||||
| has_surface = has_surface || output->input("Surface")->link; | has_surface = has_surface || output->input("Surface")->link; | ||||
| has_volume = has_volume || output->input("Volume")->link; | has_volume = has_volume || output->input("Volume")->link; | ||||
| has_displacement = has_displacement || output->input("Displacement")->link; | has_displacement = has_displacement || output->input("Displacement")->link; | ||||
| /* get requested attributes. this could be optimized by pruning unused | update_attributes(scene); | ||||
| * nodes here already, but that's the job of the shader manager currently, | |||||
| * and may not be so great for interactive rendering where you temporarily | |||||
| * disconnect a node */ | |||||
| AttributeRequestSet prev_attributes = attributes; | |||||
| attributes.clear(); | |||||
| foreach(ShaderNode *node, graph->nodes) | |||||
| node->attributes(this, &attributes); | |||||
| if(has_displacement && displacement_method == DISPLACE_BOTH) { | |||||
| attributes.add(ATTR_STD_POSITION_UNDISPLACED); | |||||
| } | |||||
| /* compare if the attributes changed, mesh manager will check | |||||
| * need_update_attributes, update the relevant meshes and clear it. */ | |||||
| if(attributes.modified(prev_attributes)) { | |||||
| need_update_attributes = true; | |||||
| scene->mesh_manager->need_update = true; | |||||
| } | |||||
| if(has_volume != prev_has_volume) { | if(has_volume != prev_has_volume) { | ||||
| scene->mesh_manager->need_flags_update = true; | scene->mesh_manager->need_flags_update = true; | ||||
| scene->object_manager->need_flags_update = true; | scene->object_manager->need_flags_update = true; | ||||
| } | } | ||||
| } | } | ||||
| void Shader::tag_used(Scene *scene) | void Shader::tag_used(Scene *scene) | ||||
| ▲ Show 20 Lines • Show All 318 Lines • Show Last 20 Lines | |||||