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.

31 lines
783 B

import TempNode from '../core/TempNode.js';
import { transformedNormalView } from '../accessors/NormalNode.js';
import { positionViewDirection } from '../accessors/PositionNode.js';
import { nodeImmutable, vec2, vec3 } from '../shadernode/ShaderNode.js';
import { addNodeClass } from '../core/Node.js';
class MatcapUVNode extends TempNode {
constructor() {
super( 'vec2' );
}
setup() {
const x = vec3( positionViewDirection.z, 0, positionViewDirection.x.negate() ).normalize();
const y = positionViewDirection.cross( x );
return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 );
}
}
export default MatcapUVNode;
export const matcapUV = nodeImmutable( MatcapUVNode );
addNodeClass( 'MatcapUVNode', MatcapUVNode );