Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/nodes.cpp
| Show First 20 Lines • Show All 5,274 Lines • ▼ Show 20 Lines | NODE_DEFINE(MapRangeNode) | ||||
| return type; | return type; | ||||
| } | } | ||||
| MapRangeNode::MapRangeNode() : ShaderNode(node_type) | MapRangeNode::MapRangeNode() : ShaderNode(node_type) | ||||
| { | { | ||||
| } | } | ||||
| void MapRangeNode::expand(ShaderGraph *graph) | |||||
| { | |||||
| if (clamp) { | |||||
| ShaderOutput *result_out = output("Result"); | |||||
| if (!result_out->links.empty()) { | |||||
| ClampNode *clamp_node = new ClampNode(); | |||||
| clamp_node->min = to_min; | |||||
| clamp_node->max = to_max; | |||||
| graph->add(clamp_node); | |||||
| graph->relink(result_out, clamp_node->output("Result")); | |||||
| graph->connect(result_out, clamp_node->input("Value")); | |||||
| } | |||||
| } | |||||
| } | |||||
| void MapRangeNode::constant_fold(const ConstantFolder &folder) | void MapRangeNode::constant_fold(const ConstantFolder &folder) | ||||
| { | { | ||||
| if (folder.all_inputs_constant()) { | if (folder.all_inputs_constant()) { | ||||
| float result; | float result; | ||||
| if (from_max != from_min) { | if (from_max != from_min) { | ||||
| result = to_min + ((value - from_min) / (from_max - from_min)) * (to_max - to_min); | result = to_min + ((value - from_min) / (from_max - from_min)) * (to_max - to_min); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 1,078 Lines • Show Last 20 Lines | |||||