Evaluation - miminashca/Ray-Tracing GitHub Wiki

Evaluation

This page provides an evaluation of performance of the custom GPU Ray-Tracer developed in Unity compared to Unity's built-in renderer. The evaluation criteria focus on performance metrics and visual quality differences measured using self-made FPS and triangle count tracking script.

Evaluation Criteria

The evaluation covers two main aspects:

Performance: Render timings (measured in seconds per frame) across varying complexities.

Visual Quality: Assessment based on clarity, realism, and overall rendering fidelity.

Evaluation Methodology

To perform the evaluation, two scenarios were defined:

Scene Complexity Scaling: Different numbers of lights and objects were tested in the scenes.

Resolution: Different basic resolutions were tested.

Tools Used

FPS Tracker Script: A script that displays triangle count and a 30-second countdown. Once the 30 seconds are up, it calculates and displays the average FPS over that period.

Hardware and Software Used

Computer: MacBook Pro M2, 13-inch (2022)

Operating System: macOS Sonoma

Unity Version: Unity 6 6000.0.40f1 (LTS)

Test Scene setup

I made a scene ("TestScene"), where I conducted my evaluation. It contains:

  • 1 directional light - used both by the shader, and by the standard rendering setup.
  • 4 point lights - for second iteration. For testing my shader they will be represented by small spheres with emission (spheres don't add much computing complexity, as they are not "meshes" in my setup). For builtin - those will be typical point lights, provided by Unity.
  • 1 plane for first iteration -> 20 cubes + 1 plane for last iteration.

I chose cubes - as they are already treated as meshes by the shader, but still moderate complexity and don't freeze out my laptop. Spheres are treated as meshes by Unity, and by my shader they are treated more as a "mathematical representation of a shape", thus the calculations are going to be different, and I am not sure if it would be a fair comparison, so I decided not to use them.

Elapsed time

Each test-session takes same time (30s) for the clarity of testing. After that - I note down the stats, and process them.

Note: my laptop will be on charge at all times.

Results

FPS performance evaluation with increasing amount of cube meshes

Result: Even with the simplest scene, ray tracing introduces significant performance overhead with exponential drop (15-1 FPS), despite the relatively slight increase in number of triangles (3k - 4.2k). This shows the cost of ray tracing’s physically accurate lighting model, even when geometry is minimal. Built-in renderer on the other side shows a good performance metrics (~330 FPS), with slight linear drop (336-326 FPS).

FPS performance evaluation with increasing amount of lights

Result: Ray tracing FPS drops linearly (5 - 4.5 FPS). Same goes for built-in (330 - 270 FPS).

FPS performance evaluation with increasing resolution

Result: Ray tracing FPS drops linearly (5 - 1 FPS). Same goes for built-in (315 - 115 FPS).

Visual Quality Evaluation

It is obvious - ray tracer does much better job at creating photo-realistic renders. It can be observed by how the light behaves in pictures above: Ray-tracer creates softer shadows, allows for environment contribution, creates natural reflections, diffuse. Also allows features like anti-aliasing, depth of field. But it does come at a high cost of calculating close to real-life light behaviour.

Big O Notation

Ray-Tracing:

Rays per pixel (R);

Number of pixels (P);

Ray bounces (B);

Scene objects (N);

Total complexity: O(P × R × B × N)

Rasterization (Unity built-in):

Total number of pixels (screen resolution) (P);

Total number of vertices in scene (V);

Number of triangles (T);

Average overdraw factor (usually small constant: 1–4) (D);

Total Complexity ≈ O(V + T × A + P × D)

Rasterization is several times cheaper in complexity — which explains its privilege in efficiency.

Conclusion

In conclusion, the performance evaluation, as visualized by the accompanying graphs, decisively demonstrates the cost of real-life rendering of Ray-Tracing. The data clearly illustrates the significant increase in render times of Ray-Tracing, compared to Unity's built-in renderer, especially as mesh complexity in scene increases.