playcanvas
Version:
PlayCanvas WebGL game engine
76 lines (75 loc) • 3.45 kB
TypeScript
/**
* Helper functions to support prefiltering lighting data.
*
* @ignore
*/
export class EnvLighting {
/**
* Generate a skybox cubemap in the correct pixel format from the source texture.
*
* @param {Texture} source - The source texture. This is either a 2d texture in equirect format
* or a cubemap.
* @param {number} [size] - Size of the resulting texture. Otherwise use automatic sizing.
* @returns {Texture} The resulting cubemap.
*/
static generateSkyboxCubemap(source: Texture, size?: number): Texture;
/**
* Create a texture in the format needed to precalculate lighting data.
*
* @param {Texture} source - The source texture. This is either a 2d texture in equirect format
* or a cubemap.
* @param {object} [options] - Specify generation options.
* @param {Texture} [options.target] - The target texture. If one is not provided then a
* new texture will be created and returned.
* @param {number} [options.size] - Size of the lighting source cubemap texture. Only used
* if target isn't specified. Defaults to 128.
* @returns {Texture} The resulting cubemap.
*/
static generateLightingSource(source: Texture, options?: {
target?: Texture;
size?: number;
}): Texture;
/**
* Generate the environment lighting atlas containing prefiltered reflections and ambient.
*
* @param {Texture} source - The source lighting texture, generated by generateLightingSource.
* @param {object} [options] - Specify prefilter options.
* @param {Texture} [options.target] - The target texture. If one is not provided then a
* new texture will be created and returned.
* @param {number} [options.size] - Size of the target texture to create. Only used if
* target isn't specified. Defaults to 512.
* @param {number} [options.numReflectionSamples] - Number of samples to use when generating
* rough reflections. Defaults to 1024.
* @param {number} [options.numAmbientSamples] - Number of samples to use when generating ambient
* lighting. Defaults to 2048.
* @returns {Texture} The resulting atlas
*/
static generateAtlas(source: Texture, options?: {
target?: Texture;
size?: number;
numReflectionSamples?: number;
numAmbientSamples?: number;
}): Texture;
/**
* Generate the environment lighting atlas from prefiltered cubemap data.
*
* @param {Texture[]} sources - Array of 6 prefiltered textures.
* @param {object} [options] - The options object
* @param {Texture} [options.target] - The target texture. If one is not provided then a
* new texture will be created and returned.
* @param {number} [options.size] - Size of the target texture to create. Only used if
* target isn't specified. Defaults to 512.
* @param {boolean} [options.legacyAmbient] - Enable generating legacy ambient lighting.
* Default is false.
* @param {number} [options.numSamples] - Number of samples to use when generating ambient
* lighting. Default is 2048.
* @returns {Texture} The resulting atlas texture.
*/
static generatePrefilteredAtlas(sources: Texture[], options?: {
target?: Texture;
size?: number;
legacyAmbient?: boolean;
numSamples?: number;
}): Texture;
}
import { Texture } from '../../platform/graphics/texture.js';