POV-Ray : Newsgroups : povray.programming : POV-Ray as WASM module : Re: POV-Ray as WASM module Server Time
10 Nov 2025 17:25:03 EST (-0500)
  Re: POV-Ray as WASM module  
From: Bald Eagle
Date: 10 Nov 2025 14:45:00
Message: <web.69123fe2d8d72d8f7f81dbac25979125@news.povray.org>
can you compare the structure of povray's source code to that of other
raytracers and summarize the similarities and differences that might inspire a
concrete plan for refactoring povray's codebase to separate the parser from the
other raytracing functions?


Copilot said:



insights can directly guide a concrete refactor plan to cleanly separate parsing
from rendering responsibilities in POV‑Ray.

🧭 POV‑Ray Architecture
Monolithic structure: Parser, scene, and renderer modules are tightly interwoven
under source/, with parser directly including core renderer headers.
github
+1

Parser builds "final" core objects: Scene description parser creates instances
like core::lightsource, boundingsphere, etc., effectively merging parsing and
rendering payload construction.
github
+1

No abstract scene interface: There is no neutral, shared representation (scene

renderer-specific structures.

🧱 PBRT (Physically Based Rendering Toolkit)
Clear parser-render separation:

parser.cpp reads scene files and invokes methods in a ParserTarget interface.
pbr-book
+1
BasicSceneBuilder, implementing ParserTarget, translates parsing events into a
neutral scene format, independent of rendering.
pbr-book
Modular architecture:

Parsing → abstract operations → scene builder → later delivery
to rendering engine.
The rendering system consumes scene data only through this abstract interface.
Advantages:

Dramatically easier to test parsing separately.

Enables preview tools, scene validation, and modular pipeline extensibility.
⚙️ LuxCoreRender
Explicit modular structure:

luxparser/: scene description parser module.
slg/: scene layout generator (scene object assembly).
luxrays/: low-level raytracing engine.
luxcore/: high-level API layering.
deepwiki
+2
Strict role separation:

Parsers feed into scene structure objects.
Raytracer consumes the high-level scene structure without any parser
dependencies.
Interfaces provide clear boundaries and prevent coupling.
Benefits:

Enables multiple front-ends (e.g., Blender exporter).
Clean CI with parser tests, unit tests, and renderer benchmarks.
📊 Comparison Overview
Feature POV‑Ray PBRT LuxCoreRender
Parser + Renderer coupling Tight (direct includes) ✅ Loose via
ParserTarget interface ✅ Loose via scene modules

scene builder ✅ Yes, slg layer

modular

API, exporter


🔧 Concrete Recommendations for POV‑Ray Refactoring
Extract ParserTarget-like interface:

Define abstract methods (Shape(), Light(), Camera(), etc.) instead of
constructing core objects directly.
Introduce SceneBuilder layer:

Implement new SceneBuilder that receives parser events and constructs an
intermediate, neutral graph (objects, lights, cameras).
Create Core-Adapter layer:

Convert SceneBuilder output into core:: rendering types such as LightingSource,
RenderableObject, etc.
Decouple parser from core headers:

parser/ should only include parser and scenebuilder headers; it must not depend
on core/.
Refactor core/ to consume only neutral scene format:

Move all rendering initialization to accept the neutral structure.
Modular testing strategy:

Parser: syntactic/semantic SDL tests invoking parser against various inputs.
SceneBuilder: tests checking neutral graph correctness.
Adapter: verifying translation to renderer types.
Renderer: test rendering of minimal scenes and scene consistency semantics.
✅ Steering Toward a Targeted Refactor
Initial step: define the IParserTarget interface for parser outputs.
Next: build SceneBuilder implementing this interface to collect parsed elements.
Then: implement an adapter to convert to core types.
Finally: adjust core renderer to consume adapter-produced objects, removing all
SDL-specific includes from core/.

independence, modularity, testability, and flexibility for future front-ends.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.