import { Bounds3 as SceneBounds3, Light, Scene, type SceneNode } from "@aura3d/scene";
import type { Ray } from "@aura3d/math";
import { type RenderBackendOptions } from "./RenderBackend";
import { type RenderDevice, type RenderDeviceDiagnostics, type RenderTarget } from "./RenderDevice";
import { type EnvironmentBackgroundOptions } from "./EnvironmentBackgroundPass";
import { type EnvironmentLightingOptions, type ForwardEnvironmentFogOptions, type ForwardShadowMapOptions, type RenderItem, type RenderMaterial } from "./ForwardPass";
import { type CollectedLight } from "./LightCollector";
import { Geometry } from "./Geometry";
import { type MorphTargetDelta } from "./MorphTarget";
import { type RendererPostprocessPlanOptions, type RendererPostprocessTargetFormat } from "./RendererPostprocessPlan";
import { type ShaderLibrary } from "./ShaderLibrary";
import { type ShadowFilterKernel, type ShadowMapOptions } from "./ShadowMap";
import { type PerspectiveCameraFrameOptions } from "./CameraFraming";
import { type RendererFeature, type RendererFeatureReport } from "./RendererFeatureGates";
import { type StaticBatchOptions } from "./SceneOptimization";
export interface RendererOptions extends RenderBackendOptions {
    readonly width?: number;
    readonly height?: number;
    readonly clearColor?: readonly [number, number, number, number];
    readonly shaderLibrary?: ShaderLibrary;
    readonly requiredFeatures?: readonly RendererFeature[];
}
export interface ResizeToDisplayOptions {
    readonly cssWidth?: number;
    readonly cssHeight?: number;
    readonly devicePixelRatio?: number;
}
export interface ResizeToDisplayResult {
    readonly resized: boolean;
    readonly cssWidth: number;
    readonly cssHeight: number;
    readonly devicePixelRatio: number;
    readonly width: number;
    readonly height: number;
}
export interface RendererAnimationLoop {
    readonly running: boolean;
    stop(): void;
}
export interface RendererFrameCapture {
    readonly width: number;
    readonly height: number;
    readonly pixels: Uint8Array;
    readonly diagnostics: RenderDeviceDiagnostics;
    readonly capturedAt?: string;
    readonly renderSize?: RendererFrameCaptureRenderSize;
    readonly pixelHash?: string;
    readonly pixelDigest?: RendererFrameCapturePixelDigest;
    readonly pixelStats?: RendererFrameCapturePixelStats;
    readonly diagnosticsSummary?: RendererFrameCaptureDiagnosticsSummary;
    readonly metadata?: RendererFrameCaptureMetadata;
}
export interface RendererFrameCaptureWithMetadata extends RendererFrameCapture {
    readonly capturedAt: string;
    readonly renderSize: RendererFrameCaptureRenderSize;
    readonly pixelHash: string;
    readonly pixelDigest: RendererFrameCapturePixelDigest;
    readonly pixelStats: RendererFrameCapturePixelStats;
    readonly diagnosticsSummary: RendererFrameCaptureDiagnosticsSummary;
    readonly metadata: RendererFrameCaptureMetadata;
}
export interface RendererFrameCaptureRenderSize {
    readonly width: number;
    readonly height: number;
    readonly pixelCount: number;
    readonly byteLength: number;
    readonly aspectRatio: number;
}
export interface RendererFrameCapturePixelDigest {
    readonly algorithm: "sha256";
    readonly encoding: "hex";
    readonly source: "rgba8";
    readonly value: string;
    readonly byteLength: number;
}
export interface RendererFrameCapturePixelStats {
    readonly totalPixels: number;
    readonly opaquePixels: number;
    readonly opaqueRatio: number;
    readonly transparentPixels: number;
    readonly transparentRatio: number;
    readonly nonBlankPixels: number;
    readonly nonBlankRatio: number;
    readonly underexposedPixels: number;
    readonly underexposedRatio: number;
    readonly overexposedPixels: number;
    readonly overexposedRatio: number;
    readonly clippedChannelPixels: number;
    readonly clippedChannelRatio: number;
    readonly averageLuminance: number;
    readonly minLuminance: number;
    readonly maxLuminance: number;
    readonly averageAlpha: number;
    readonly averageRgb: readonly [number, number, number];
    readonly thresholds: {
        readonly nonBlankLuminance: number;
        readonly underexposedLuminance: number;
        readonly overexposedLuminance: number;
        readonly clippedChannel: number;
    };
}
export interface RendererFrameCaptureDiagnosticsSummary {
    readonly backend: RenderDevice["kind"];
    readonly renderer: string;
    readonly vendor: string;
    readonly capabilities: readonly string[];
    readonly limitations: readonly string[];
    readonly drawCalls: number;
    readonly resources: {
        readonly buffers: number;
        readonly shaders: number;
        readonly renderTargets?: number;
        readonly textures?: number;
    };
    readonly memoryBytes?: {
        readonly buffers?: number;
        readonly textures?: number;
        readonly approximateGpu?: number;
    };
    readonly scene?: {
        readonly submittedObjects?: number;
        readonly visibleObjects?: number;
        readonly culledObjects?: number;
        readonly frustumTestedObjects?: number;
    };
    readonly postprocess?: {
        readonly passes?: number;
        readonly passNames?: readonly string[];
        readonly targetFormat?: "rgba8" | "rgba16f" | "rgba32f";
        readonly renderTargets?: number;
        readonly textures?: number;
        readonly targetWidth?: number;
        readonly targetHeight?: number;
    };
    readonly contextLost: boolean;
    readonly lastError: string | null;
}
export interface RendererFrameCaptureMetadata {
    readonly capturedAt: string;
    readonly renderSize: RendererFrameCaptureRenderSize;
    readonly pixelHash: string;
    readonly pixelDigest: RendererFrameCapturePixelDigest;
    readonly pixelStats: RendererFrameCapturePixelStats;
    readonly diagnosticsSummary: RendererFrameCaptureDiagnosticsSummary;
}
export interface RenderSource {
    collectRenderItems?(): Iterable<RenderItem>;
    readonly renderItems?: Iterable<RenderItem>;
    readonly scene?: Scene;
    readonly renderTarget?: RenderTarget;
    readonly cameraPolicy?: RendererCameraPolicy;
    readonly cameraFrameBounds?: SceneBounds3 | {
        readonly min: readonly [number, number, number];
        readonly max: readonly [number, number, number];
    };
    readonly cameraFrameOptions?: PerspectiveCameraFrameOptions;
    readonly collectedLights?: Iterable<CollectedLight>;
    readonly environmentBackground?: EnvironmentBackgroundOptions | false;
    readonly environmentLighting?: EnvironmentLightingOptions | false;
    readonly environmentFog?: ForwardEnvironmentFogOptions | false;
    readonly shadowMap?: ForwardShadowMapOptions;
    readonly shadow?: RendererShadowOptions | boolean;
    readonly postprocess?: RendererPostProcessOptions | boolean;
    readonly cameraPosition?: readonly [number, number, number];
    readonly geometryLibrary?: RenderResourceLookup<Geometry>;
    readonly materialLibrary?: RenderResourceLookup<RenderMaterial>;
    readonly morphTargetLibrary?: RenderResourceLookup<readonly MorphTargetDelta[]>;
    readonly frustumCulling?: boolean;
    readonly staticBatching?: boolean | StaticBatchOptions;
}
export interface RendererInput {
    readonly source: RenderSource | Iterable<RenderItem> | Scene;
    readonly camera?: CameraLike;
}
export type RendererCameraPolicy = "identity" | "auto-frame" | "require";
export declare const DEFAULT_RENDERER_AUTO_FRAME_OPTIONS: PerspectiveCameraFrameOptions;
export declare const DEFAULT_RENDERER_ENVIRONMENT_LIGHTING: EnvironmentLightingOptions;
export declare const DEFAULT_RENDERER_DIRECT_LIGHTING: {
    readonly key: {
        readonly color: readonly [1, 0.92, 0.78];
        readonly intensity: 2.25;
        readonly direction: readonly [0.42, -0.58, -0.7];
    };
    readonly fill: {
        readonly color: readonly [0.48, 0.62, 0.9];
        readonly intensity: 0.55;
        readonly direction: readonly [-0.35, -0.22, -0.91];
    };
};
export interface RendererShadowOptions extends ShadowMapOptions {
    readonly enabled?: boolean;
    readonly light?: Light;
    readonly lightMatrix?: Float32Array | readonly number[];
    readonly strength?: number;
    readonly slopeBias?: number;
    readonly texelSize?: readonly [number, number];
    readonly filterKernel?: ShadowFilterKernel;
}
export interface RendererPostProcessOptions extends RendererPostprocessPlanOptions {
    readonly targetFormat?: RendererPostprocessTargetFormat;
}
export type RenderResourceLookup<T> = ReadonlyMap<string, T> | Readonly<Record<string, T>>;
export interface CameraLike {
    readonly projectionMatrix?: Float32Array | readonly number[];
    readonly viewMatrix?: Float32Array | readonly number[];
    readonly viewProjectionMatrix?: Float32Array | readonly number[];
    resize?(width: number, height: number): void;
    updateCameraMatrices?(): void;
}
export interface ScenePickHit {
    readonly node: SceneNode;
    readonly geometry: Geometry;
    readonly distance: number;
    readonly bounds: SceneBounds3;
    readonly hitPoint?: readonly [number, number, number];
    readonly pointIndex?: number;
    readonly instanceIndex?: number;
}
export interface ScenePickOptions {
    readonly pointRadius?: number;
    readonly lineRadius?: number;
}
export declare class Renderer {
    readonly device: RenderDevice;
    private readonly graph;
    private readonly shaderLibrary;
    private readonly canvas?;
    private width;
    private height;
    private clearColor;
    private disposed;
    private animationLoop;
    private readonly fusedLdrPostprocessScratch;
    private constructor();
    static create(options?: RendererOptions): Promise<Renderer>;
    getFeatureReport(): RendererFeatureReport;
    resize(width: number, height: number): void;
    resizeToDisplay(options?: ResizeToDisplayOptions): ResizeToDisplayResult;
    startAnimationLoop(callback: (timeMs: number, renderer: Renderer) => void): RendererAnimationLoop;
    render(input: RendererInput): RenderDeviceDiagnostics;
    render(source: RenderSource | Iterable<RenderItem> | Scene, camera?: CameraLike): RenderDeviceDiagnostics;
    renderAsync(input: RendererInput): Promise<RenderDeviceDiagnostics>;
    renderAsync(source: RenderSource | Iterable<RenderItem> | Scene, camera?: CameraLike): Promise<RenderDeviceDiagnostics>;
    renderScene(scene: RenderSource | Scene, camera?: CameraLike): RenderDeviceDiagnostics;
    renderItems(items: Iterable<RenderItem>, camera?: CameraLike, options?: Omit<RenderSource, "renderItems">): RenderDeviceDiagnostics;
    captureFrame(source?: RenderSource | Iterable<RenderItem> | Scene, camera?: CameraLike): RendererFrameCaptureWithMetadata;
    getDiagnostics(): RenderDeviceDiagnostics;
    dispose(): void;
    private assertAlive;
    private resizeCanvas;
    private executePostprocess;
    private executeFusedLdrPostprocess;
    private executePostprocessAsync;
    private executeFusedLdrPostprocessAsync;
    private executePixelPostprocessPass;
    private executePixelPostprocessPassAsync;
    private readRenderTargetPixelsAsync;
    private readRenderTargetFloatPixelsAsync;
    private readRendererOwnedDepthTexture;
    private executeRendererShadowMap;
    private executeRendererPointShadowMap;
}
export declare function pickSceneRenderables(source: Pick<RenderSource, "geometryLibrary" | "morphTargetLibrary" | "scene">, ray: Ray, options?: ScenePickOptions): ScenePickHit | undefined;
export declare function pickSceneRenderableHits(source: Pick<RenderSource, "geometryLibrary" | "morphTargetLibrary" | "scene">, ray: Ray, options?: ScenePickOptions): readonly ScenePickHit[];
//# sourceMappingURL=Renderer.d.ts.map