import { Light } from "./lights"; import { LightMap } from "./LightMap"; import { LightShader } from "./shaders"; import { XY } from "./math"; import { BlendFunc, LightColor, RGBA } from "./utils"; /** * Handler that manages everything related to lights updating and rendering *
Implements {@link Disposable} * @author kalle_h */ export declare abstract class RayHandler { /** * Blend function for lights rendering with both shadows and diffusion *
Default: (gl.DST_COLOR, gl.ZERO) */ readonly diffuseBlendFunc: BlendFunc; /** * Blend function for lights rendering with shadows but without diffusion *
Default: (gl.ONE, gl.ONE_MINUS_SRC_ALPHA) */ readonly shadowBlendFunc: BlendFunc; /** * Blend function for lights rendering without shadows and diffusion *
Default: (gl.SRC_ALPHA, gl.ONE) */ readonly simpleBlendFunc: BlendFunc; readonly combined: Float32Array; readonly ambientLight: LightColor; /** * This Array contain all the lights. * *
NOTE: DO NOT MODIFY THIS LIST */ readonly lightList: Light[]; /** * This Array contain all the disabled lights. * *
NOTE: DO NOT MODIFY THIS LIST */ readonly disabledLights: Light[]; lightMap: LightMap; lightShader: LightShader; customLightShader: LightShader | null; culling: boolean; shadows: boolean; blur: boolean; blurNum: number; customViewport: boolean; viewportX: number; viewportY: number; viewportWidth: number; viewportHeight: number; /** How many lights passed culling and rendered to scene last time */ lightRenderedLastFrame: number; /** camera matrix corners */ x1: number; x2: number; y1: number; y2: number; gl: WebGLRenderingContext; /** * Class constructor specifying the physics world from where collision * geometry is taken, and size of FBO used for intermediate rendering. * * @see #RayHandler(b2World) */ constructor(gl: WebGLRenderingContext, fboWidth: number, fboHeight: number, viewportWidth: number, viewportHeight: number); /** * Resize the FBO used for intermediate rendering. */ resizeFBO(fboWidth: number, fboHeight: number): void; /** * Sets combined camera matrix. * *
Matrix must be set to work in box2d coordinates, it will be copied * and used for culling and rendering. Remember to update it if camera * changes. This will work with rotated cameras. * * @param combined * matrix that include projection and translation matrices * @param x * combined matrix position * @param y * combined matrix position * @param viewPortWidth * NOTE!! use actual size, remember to multiple with zoom value * if pulled from OrthoCamera * @param viewPortHeight * NOTE!! use actual size, remember to multiple with zoom value * if pulled from OrthoCamera * * @see #setCombinedMatrix(OrthographicCamera) */ setCombinedMatrix(combined: Float32Array | number[], x: number, y: number, viewPortWidth: number, viewPortHeight: number): void; /** * Utility method to check if light is on the screen * @param x - light center x-coord * @param y - light center y-coord * @param radius - maximal light distance * * @returns true if camera screen intersects or contains provided * light, represented by circle/box area */ intersect(x: number, y: number, radius: number): boolean; /** * Updates and renders all active lights. * *
NOTE! Remember to set combined matrix before this method. * *
Don't call this inside of any begin/end statements. * Call this method after you have rendered background but before UI. * Box2d bodies can be rendered before or after depending how you want * the x-ray lights to interact with them. * * @see #update() * @see #render() */ updateAndRender(): void; /** * Manual update method for all active lights. * *
Use this if you have less physics steps than rendering steps. * * @see #updateAndRender() * @see #render() */ update(): void; /** * Prepare all lights for rendering. * *
You should need to use this method only if you want to render lights * on a frame buffer object. Use {@link #render()} otherwise. * *
NOTE! Don't call this inside of any begin/end statements. * * @see #renderOnly() * @see #render() */ prepareRender(): void; /** * Manual rendering method for all lights. * *
NOTE! Remember to set combined matrix and update lights * before using this method manually. * *
Don't call this inside of any begin/end statements. * Call this method after you have rendered background but before UI. * Box2d bodies can be rendered before or after depending how you want * the x-ray lights to interact with them. * * @see #updateAndRender() * @see #update() * @see #setCombinedMatrix(Matrix4) * @see #setCombinedMatrix(Matrix4, float, float, float, float) */ render(): void; /** * Manual rendering method for all lights tha can be used inside of * begin/end statements * *
Use this method if you want to render lights in a frame buffer * object. You must call {@link #prepareRender()} before calling this * method. Also, {@link #prepareRender()} must not be inside of any * begin/end statements * * @see #prepareRender() */ renderOnly(): void; /** * Called before light rendering start * * Override this if you are using custom light shader */ protected updateLightShader(): void; /** * Called for custom light shader before each light is rendered * * Override this if you are using custom light shader */ protected updateLightShaderPerLight(_light: Light): void; /** * Checks whether the given point inside of any light volume * * @returns true if point inside of any light volume */ pointAtLight(x: number, y: number): boolean; /** * Checks whether the given point outside of all light volumes * * @returns true if point NOT inside of any light volume */ pointAtShadow(x: number, y: number): boolean; /** * Disposes all this rayHandler lights and resources */ dispose(): void; /** * Removes and disposes both all active and disabled lights */ removeAll(): void; removeLight(light: Light): void; /** * Set custom light shader, null to reset to default * * Changes will take effect next time #render() is called */ setLightShader(customLightShader: LightShader): void; /** * Enables/disables culling. * *
This save CPU and GPU time when the world is bigger than the screen. * *
Default = true */ setCulling(culling: boolean): void; /** * Enables/disables Gaussian blur. * *
This make lights much more softer and realistic look but cost some * precious shader time. With default FBO size on android cost around 1ms. * *
Default = true * * @see #setBlurNum(int) */ setBlur(blur: boolean): void; /** * Sets number of Gaussian blur passes. * *
Blurring can be pretty heavy weight operation, 1-3 should be safe. * Setting this to 0 is the same as disabling it. * *
Default = 1 * * @see #setBlur(boolean) */ setBlurNum(blurNum: number): void; /** * Enables/disables shadows */ setShadows(shadows: boolean): void; /** * Sets ambient light brightness. Specifies shadows brightness. *
Default = 0 * * @param ambientLight * shadows brightness value, clamped to [0f; 1f] * * @see #setAmbientLightC(RGBA) * @see #setAmbientLight(float, float, float, float) */ setAmbientLightBrightness(ambientLight: number): void; /** * Sets ambient light color. * Specifies how shadows colored and their brightness. * *
Default = LightColor(0, 0, 0, 0) * * @param r * shadows color red component * @param g * shadows color green component * @param b * shadows color blue component * @param a * shadows brightness component * * @see #setAmbientLight(float) * @see #setAmbientLightC(RGBA) */ setAmbientLight(r: number, g: number, b: number, a: number): void; /** * Sets ambient light color. * Specifies how shadows colored and their brightness. * *
Default = LightColor(0, 0, 0, 0) * * @param ambientLightColor * color whose RGB components specify the shadows coloring and * alpha specify shadows brightness * * @see #setAmbientLight(float) * @see #setAmbientLight(float, float, float, float) */ setAmbientLightC(ambientLightColor: RGBA): void; abstract createRayCastCallback(light: Light): (point1: XY, point2: XY) => void; /** * Sets rendering to custom viewport with specified position and size *
Note: you will be responsible for update of viewport via this method * in case of any changes (on resize) */ useCustomViewport(x: number, y: number, width: number, height: number): void; /** * Sets rendering to default viewport * *
0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() */ useDefaultViewport(): void; /** * Enables/disables lightMap automatic rendering. * *
If set to false user needs to use the {@link #getLightMapTexture()} * and render that or use it as a light map when rendering. Example shader * for spriteBatch is given. This is faster way to do if there is not that * much overdrawing or if just couple object need light/shadows. * *
Default = true */ setLightMapRendering(isAutomatic: boolean): void; /** * Expert functionality, no support given * * @returns FrameBuffer that contains lightMap */ getLightMapBuffer(): import("./utils").FrameBuffer; abstract getBodyPosition(body: any): XY; abstract getBodyAngle(body: any): number; } //# sourceMappingURL=RayHandler.d.ts.map