UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

41 lines (38 loc) 1.48 kB
import { shaderChunks } from './chunks/chunks.js'; /** * @import { CameraShaderParams } from '../camera-shader-params.js' * @import { GraphicsDevice } from '../../platform/graphics/graphics-device.js' */ var decodeTable = { 'linear': 'decodeLinear', 'srgb': 'decodeGamma', 'rgbm': 'decodeRGBM', 'rgbe': 'decodeRGBE', 'rgbp': 'decodeRGBP' }; var encodeTable = { 'linear': 'encodeLinear', 'srgb': 'encodeGamma', 'rgbm': 'encodeRGBM', 'rgbe': 'encodeRGBE', 'rgbp': 'encodeRGBP' }; class ChunkUtils { // returns the name of the decode function for the texture encoding static decodeFunc(encoding) { return decodeTable[encoding] || 'decodeGamma'; } static encodeFunc(encoding) { return encodeTable[encoding] || 'encodeGamma'; } /** * Returns a screenDepth chunk configured for the given camera shader parameters. * * @param {GraphicsDevice} device - The graphics device. * @param {CameraShaderParams} cameraShaderParams - The camera shader parameters. * @returns {string} The screenDepth chunk. * @ignore */ static getScreenDepthChunk(device, cameraShaderParams) { return "\n " + (cameraShaderParams.sceneDepthMapLinear ? '#define SCENE_DEPTHMAP_LINEAR' : '') + "\n " + (device.textureFloatRenderable ? '#define SCENE_DEPTHMAP_FLOAT' : '') + "\n " + shaderChunks.screenDepthPS + "\n "; } } export { ChunkUtils };