From 10bfc58085c6ab7e62077a1a9b6a6d922fffb025 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sat, 26 Jul 2025 11:17:10 +0100 Subject: Rework multithreaded rendering Render worker tasks are now split into chunks rather than row blocks for better thread utilisation --- src/models/RaytraceContext.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/models/RaytraceContext.ts (limited to 'src/models/RaytraceContext.ts') diff --git a/src/models/RaytraceContext.ts b/src/models/RaytraceContext.ts new file mode 100644 index 0000000..acd4336 --- /dev/null +++ b/src/models/RaytraceContext.ts @@ -0,0 +1,43 @@ +import {Type} from 'class-transformer'; +import {Colour} from './Colour'; +import {Plane, Sphere} from './Geometry'; +import {Light} from './Light'; + +export class RaytraceContext { + @Type(() => Sphere) + readonly spheres: Sphere[]; + @Type(() => Plane) + readonly planes: Plane[]; + @Type(() => Light) + readonly lights: Light[]; + @Type(() => Colour) + readonly backgroundColour: Colour; + constructor( + readonly height: number, + readonly width: number, + readonly fov: number, + spheres: Sphere[], + planes: Plane[], + lights: Light[], + backgroundColour: Colour, + readonly options: RaytracerOptions + ) { + this.spheres = spheres; + this.planes = planes; + this.lights = lights; + this.backgroundColour = backgroundColour; + } +} + +export interface RaytracerOptions { + numThreads: number; + shadows: boolean; + diffuseLighting: boolean; + specularLighting: boolean; + reflections: boolean; + refractions: boolean; + maxRecurseDepth: number; + maxDrawDistance: number; + bufferDrawCalls: boolean; + directMemoryTransfer: boolean; +} -- cgit v1.2.3