Fix #105803: Cycles slow light tree build when previewing shader nodes
When linking a texture directly to the material output, it's likely being done for the purpose of previewing. In that case, bias the heuristic towards not building a light tree, as it's likely not needed and slow on dense meshes.
This commit is contained in:
parent
7bdd82eca0
commit
4fba59c55d
|
@ -153,6 +153,16 @@ static float3 output_estimate_emission(ShaderOutput *output, bool &is_constant)
|
|||
estimate *= node->get_float(strength_in->socket_type);
|
||||
}
|
||||
|
||||
/* Lower importance of emission nodes from automatic value/color to shader
|
||||
* conversion, as these are likely used for previewing and can be slow to
|
||||
* build a light tree for on dense meshes. */
|
||||
if (node->type == EmissionNode::get_node_type()) {
|
||||
EmissionNode *emission_node = static_cast<EmissionNode *>(node);
|
||||
if (emission_node->from_auto_conversion) {
|
||||
estimate *= 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
return estimate;
|
||||
}
|
||||
else if (node->type == LightFalloffNode::get_node_type() ||
|
||||
|
|
|
@ -260,6 +260,7 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
|
|||
|
||||
if (to->type() == SocketType::CLOSURE) {
|
||||
EmissionNode *emission = create_node<EmissionNode>();
|
||||
emission->from_auto_conversion = true;
|
||||
emission->set_color(one_float3());
|
||||
emission->set_strength(1.0f);
|
||||
convert = add(emission);
|
||||
|
|
|
@ -723,6 +723,8 @@ class EmissionNode : public ShaderNode {
|
|||
NODE_SOCKET_API(float3, color)
|
||||
NODE_SOCKET_API(float, strength)
|
||||
NODE_SOCKET_API(float, surface_mix_weight)
|
||||
|
||||
bool from_auto_conversion = false;
|
||||
};
|
||||
|
||||
class BackgroundNode : public ShaderNode {
|
||||
|
|
Loading…
Reference in New Issue