UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

46 lines 1.64 kB
import type { TgdContext } from "../../context"; import { TgdTexture2D } from "../../texture"; import { TgdPainter } from "../painter"; export interface TgdPainterBackgroundWithDepthOptions { background: TgdTexture2D; children: TgdPainter[]; } /** * Complex backgrounds can be long to render. If we use a fixed camera, * we just need to render it once, store the image and the depth buffer and re-use them. * * Assuming you already have an image of the complex background (maybe you rendered it * in Ray tracing in Blender), this painter will help you cache the depth buffer. * * The children must output a special color that will encode a 24 bits depth for each fragment. * Here is the formula you can use (GLSL code): * * ```glsl * int z = int(float(0xFFFFFF) * gl_FragCoord.z); * float r = float(z & 0xFF) / 255.0; * z >>= 8; * float g = float(z & 0xFF) / 255.0; * z >>= 8; * float b = float(z & 0xFF) / 255.0; * return vec4(r, g, b, 1); * ``` * * The material [TgdMaterialDepth](./TgdMaterialDepth.html) does just that. * * @see TgdMaterialDepth */ export declare class TgdPainterBackgroundWithDepth extends TgdPainter { readonly context: TgdContext; private readonly textureDepth; private readonly textureColor; private readonly program; private readonly vao; private readonly framebuffer; private lastWidth; private lastHeight; constructor(context: TgdContext, { background, children }: TgdPainterBackgroundWithDepthOptions); delete(): void; paint(time: number, delta: number): void; private getScale; } //# sourceMappingURL=background-with-depth.d.ts.map