Class TPathTracer

Unit

Declaration

type TPathTracer = class(TRayTracer)

Description

Path tracer. See [https://castle-engine.io/vrml_engine_doc/output/xsl/html/section.path_tracer.html] for documentation.

Source: scene/castleraytracer.pas (line 170).

Hierarchy

Show Additional Members:

Overview

Fields

Public Octree: TBaseTrianglesOctree;
Public Image: TCastleImage;
Public CamPosition: TVector3;
Public CamDirection: TVector3;
Public CamUp: TVector3;
Public Projection: TProjection;
Public SceneBGColor: TVector3;
Public Background: TAbstractBackgroundNode;
Public PixelsMadeNotifier: TPixelsMadeNotifierFunc;
Public PixelsMadeNotifierData: Pointer;
Public FirstPixel: Cardinal;
Public MinDepth: Integer;
Public RRoulContinue: Single;
Public PrimarySamplesCount: Cardinal;
Public NonPrimarySamplesCount: Cardinal;
Public DirectIllumSamplesCount: Cardinal;
Public SFCurveClass: TSpaceFillingCurveClass;

Methods

Public procedure Execute; virtual; abstract;
Public procedure ExecuteStats(const Stats: TStrings);
Protected procedure AppendStats(const Stats: TStrings; const RenderingTime: Single); override;
Public constructor Create;
Public procedure Execute; override;

Description

Fields

Public Octree: TBaseTrianglesOctree;

Spatial structure (that contains geometry with materials) to render. You can create it using e.g. CreateOctreeVisibleTrianglesForScene for TCastleScene. Must be set before calling Execute.

Source: scene/castleraytracer.pas (line 58).

Public Image: TCastleImage;

Image where the ray-tracer result will be stored. Must be set before calling Execute.

We will not resize given here Image. Instead we will use it's current size — so you just have to set Image size as appropriate before calling this method.

For every pixel, we calculate it's color and store it by TCastleImage.Color[X, Y, 0] := xxx method. We don't modify alpha channel of the image.

Using TRGBFloatImage class is advised if you want the full color information. Otherwise color precision is lost beyond 8 bits, and values above 1.0 are clamped.

Source: scene/castleraytracer.pas (line 74).

Public CamPosition: TVector3;

Camera view. CamDirection and CamUp do not have to be normalized — we will correct them here if needed. CamUp will be automatically corrected to be orthogonal to CamDirection if necessary, you only make sure it's not parallel to CamDirection.

Source: scene/castleraytracer.pas (line 82).

Public CamDirection: TVector3;

Camera view. CamDirection and CamUp do not have to be normalized — we will correct them here if needed. CamUp will be automatically corrected to be orthogonal to CamDirection if necessary, you only make sure it's not parallel to CamDirection.

Source: scene/castleraytracer.pas (line 82).

Public CamUp: TVector3;

Camera view. CamDirection and CamUp do not have to be normalized — we will correct them here if needed. CamUp will be automatically corrected to be orthogonal to CamDirection if necessary, you only make sure it's not parallel to CamDirection.

Source: scene/castleraytracer.pas (line 82).

Public Projection: TProjection;

Camera projection properties.

Source: scene/castleraytracer.pas (line 85).

Public SceneBGColor: TVector3;

Default background color, if scene doesn't have Background node with skyColor.

Source: scene/castleraytracer.pas (line 88).

Public Background: TAbstractBackgroundNode;

Scene Background node.

Source: scene/castleraytracer.pas (line 91).

Public PixelsMadeNotifier: TPixelsMadeNotifierFunc;

Callback notified (if assigned) about writing each image pixel. This way you can display somewhere, or store to file, partially generated image. This callback gets information (in PixelsMadeCount) about how many pixels were generated (this includes also pixels skipped in case FirstPixel > 0).

The pixels are written in the order of TSwapScanCurve for TClassicRayTracer, and in order dependent on TPathTracer.SFCurveClass for TPathTracer. When shadow cache will be implemented to TClassicRayTracer, then configurable SFCurveClass may be done also for TClassicRayTracer.

Remember that pixels not done yet have the same content as they had when you Execute method started. In other words, if you set PixelsMadeNotifier <> nil, then often it's desirable to initialize Image content with some color (e.g. black) before calling Execute. Otherwise at the time of Execute call, the pixels not done yet will have undefined colors.

Source: scene/castleraytracer.pas (line 110).

Public PixelsMadeNotifierData: Pointer;

This item has no description.

Source: scene/castleraytracer.pas (line 111).

Public FirstPixel: Cardinal;

Initial pixel to start rendering from. By setting this to something > 0, you can (re-)start rendering from the middle. Useful to finish the job of a previous terminated ray-tracer process.

Must be in [0 .. Image.Width * Image.Height] range. Setting to Image.Width * Image.Height makes the ray-tracer do nothing.

Source: scene/castleraytracer.pas (line 120).

Public MinDepth: Integer;

MinDepth and RRoulContinue together determine the path length. The path has at least MinDepth length, and then Russian roulette is used.

See [https://castle-engine.io/rayhunter.php] documentation about "<recursion-depth>" and --r-roul-continue for suggestions about how to use these parameters. See also [https://castle-engine.io/raytr_gallery.php] for some experiments with these values.

RRoulContinue must be in 0..1 range.

You can give RRoulContinue = 0 if you don't want to use Russian roulette at all (works OK because our comparison Random < RRoulContinue uses "<", not "<="). Note that this causes bias (result is darker than it should be). Only RRoulContinue > 0 removes bias (the expected result is the correct one).

Small RRoulContinue values cause a lot of noise. Large RRoulContinue values cause long rendering.

MinDepth must be >= 0. You can use MinDepth = 0 to disable "minimal path length", and use Russian roulette always (noisy).

Source: scene/castleraytracer.pas (line 205).

Public RRoulContinue: Single;

This item has no description.

Source: scene/castleraytracer.pas (line 206).

Public PrimarySamplesCount: Cardinal;

How many paths to use. Both must be > 0.

PrimarySamplesCount tells how many paths are used for primary ray, and is really useful only for anti-aliasing. You can set this to a few. Values above ~10 are useless, they cause much longer rendering without really improving the result. You can set this to 1 if you don't need anti-aliasing.

NonPrimarySamplesCount is the number of paths caused by each hit of a primary ray. This is the main quality control for the path-tracer, more paths mean that colors are gathered from more random samples, which means that final color is more accurate. In total you have pixels count * PrimarySamplesCount * NonPrimarySamplesCount, so beware when increasing this: you really have a lot paths.

Source: scene/castleraytracer.pas (line 223).

Public NonPrimarySamplesCount: Cardinal;

How many paths to use. Both must be > 0.

PrimarySamplesCount tells how many paths are used for primary ray, and is really useful only for anti-aliasing. You can set this to a few. Values above ~10 are useless, they cause much longer rendering without really improving the result. You can set this to 1 if you don't need anti-aliasing.

NonPrimarySamplesCount is the number of paths caused by each hit of a primary ray. This is the main quality control for the path-tracer, more paths mean that colors are gathered from more random samples, which means that final color is more accurate. In total you have pixels count * PrimarySamplesCount * NonPrimarySamplesCount, so beware when increasing this: you really have a lot paths.

Source: scene/castleraytracer.pas (line 223).

Public DirectIllumSamplesCount: Cardinal;

How many samples are used to calculate direct illumination at every path point. These are rays sent into random points of random light sources, to test if given light shines here.

Set this to 0 to have a really naive path-tracing, that wanders randomly hoping to hit light source by chance. This will usually need an enormous amount of PrimarySamplesCount * NonPrimarySamplesCount to given any sensible results.

Set this to 1 or more for a normal path-tracer.

Source: scene/castleraytracer.pas (line 236).

Public SFCurveClass: TSpaceFillingCurveClass;

Order of pixels filled. In theory, something like THilbertCurve or TPeanoCurve could speed up rendering (because shadow cache is more utilized) compared to TSwapScanCurve. But in practice, right now this doesn't give any noticeable benefit.

Source: scene/castleraytracer.pas (line 242).

Methods

Public procedure Execute; virtual; abstract;

Do ray-tracing, writing a ray-traced image into the Image.

Source: scene/castleraytracer.pas (line 123).

Public procedure ExecuteStats(const Stats: TStrings);

Do ray-tracing, like Execute, additionally gathering some statistics. The statistics will be added to the given string list.

Source: scene/castleraytracer.pas (line 128).

Protected procedure AppendStats(const Stats: TStrings; const RenderingTime: Single); override;

This item has no description.

Source: scene/castleraytracer.pas (line 175).

Public constructor Create;

This item has no description.

Source: scene/castleraytracer.pas (line 177).

Public procedure Execute; override;

This item has no description. Showing description inherited from TRayTracer.Execute.

Do ray-tracing, writing a ray-traced image into the Image.

Source: scene/castleraytracer.pas (line 178).


Generated by PasDoc 0.17.0.snapshot.