UNPKG

threepipe

Version:

A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.

29 lines 1.14 kB
import { LinearSRGBColorSpace, NoColorSpace, RGBM16ColorSpace, SRGBColorSpace } from 'three'; // three.js WebGLProgram.js export function getTexelDecodingFunction(functionName, colorSpace) { let fn; switch (colorSpace) { case NoColorSpace: case LinearSRGBColorSpace: fn = ''; break; case SRGBColorSpace: // fn = 'sRGBToLinear' // todo required? fn = ''; break; case RGBM16ColorSpace: fn = 'RGBM16ToLinear'; break; default: console.warn('THREE.WebGLProgram: Unsupported color space:', colorSpace); fn = ''; break; } // return `vec4 ${functionName}( vec4 value ) { return ${components[ 0 ]}ToLinear${components[ 1 ]}; }`; // return `vec4 ${functionName}( vec4 value ) { return ${fn} ( value ); }` return `#define ${functionName}( value ) ${fn} ( value )`; } export function getTexelDecoding(mapName, colorSpace) { return getTexelDecodingFunction(mapName + 'TexelToLinear', colorSpace ?? LinearSRGBColorSpace) + '\n'; } //# sourceMappingURL=encoding.js.map