You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
733 B

2 years ago
import Node from '../core/Node.js';
import { add, sub, div, mul, clamp } from '../shadernode/ShaderNodeBaseElements.js';
class RemapNode extends Node {
constructor( node, inLowNode, inHighNode, outLowNode, outHighNode ) {
super();
this.node = node;
this.inLowNode = inLowNode;
this.inHighNode = inHighNode;
this.outLowNode = outLowNode;
this.outHighNode = outHighNode;
this.doClamp = true;
}
construct() {
const { node, inLowNode, inHighNode, outLowNode, outHighNode, doClamp } = this;
let t = div( sub( node, inLowNode ), sub( inHighNode, inLowNode ) );
if ( doClamp === true ) t = clamp( t );
return add( mul( sub( outHighNode, outLowNode ), t ), outLowNode );
}
}
export default RemapNode;