• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Playable Quake 2 pathtracing demo (runs on Nvidia & AMD)

By Edd Biddulph
Link - Console Commands and Gallery (old)
GitHub Page - Source code
EXE - Prepackaged EXE using the Quake 2 Demo (August 2017 version)
Further Details - Post by Pathtracing Enthusiast Sam Lapere that goes into great detail about the version released last year.

This is a from-scratch GPU-based pathtracer created specifically for Quake 2. It has several optimisations which are only viable due to the typical characteristics of Quake 2 such as support for parallogram-shaped lightsources, BSP ray traversal, and special handling of sky 'surfaces' (portals). It doesn't officially have a name, but you can call it Raylgun.

Supports all static and dynamic light types that were used in the original game, for which illumination was originally baked into static lightmaps.
All objects can cast shadows.
In terms of graphics API support, only OpenGL 3.3 is required.
Requires no offline pre-processing of input data, so any mod or level which works with Yamagi Quake 2 (which is a no-frills port) should work.
Still uses the rasterisation capabilities of the GPU anywhere that it makes sense.
All code modifications reside within the refresher (Quake 2's rendering subsystem) and the pathtracing codepath can be averted entirely at runtime without qualitative detriment to the original renderer's results.

Sam Lapere (of Ray Tracey fame) made a great post putting together a lot of my answers to his questions about this project, and also provided some useful tips on getting it running yourself. Sam is quite passionate about raytracing in videogames, be sure to check out his other posts and past projects.

Update Log

August 2017
Improved sampling with blue noise dithering and Halton sequence sample points.
Added TAA (temporal anti-aliasing) using raytracing to detect disocclusions, rather than colour history or G-buffer data.
Added support for moving lightsources attached to level objects such as elevators.
Added bump mapping, with bumpmaps generated on start-up from diffuse texture brightness.
Added Simple Reinhard tonemapping with exposure control, and a gamma correction parameter.
Added specular reflections of light sources and indirect lighting.
The player's own weapon no longer casts shadows on the level geometry (it can still receive shadows, and it still casts shadows on itself).
Fixed a significant slowdown caused by GL buffer usage flags, in relation to dynamic entity lights.
Added more console variables.
Fixed numerous minor bugs.

Here are some average framerate measurements as measured by Quake 2 itself along with the graphics hardware that was used:

AMD FirePro W8100 - 49.3 fps
NVIDIA Quadro K6000 - 32.8 fps
GeForce GTX 960 - 31.1 fps
AMD FirePro W7100 - 29.3 fps
GeForce GTX 680 - 22.1 fps

Links

YouTube Video 4 (new for August 2017) / HQ Direct Feed (1.2 GB) - This one was run on a GTX Titan Xp

Out-dated Links

YouTube Video 1 (old)
YouTube Video 2 (old)
Youtube Video 3 (old)

By default, it looks worst than the video, so you have to do some settings tweaks in the console (press ~ while in game) to make it look better. The default settings are not listed, so to find them enter the command without a value (you might turn off/on something that affected performance/visuals heavily and want to go back). This is important because, for some reason, no matter if you delete the files/replace the files and folder/use a different copy of the folder or files, your changed settings are somehow retained. It's weird.

settings ending with 'enable' are on/off only (1=on, 0=off)
pretty much everything else is a strength value (with 0=off)

e.g.

gl_pt_enable 1
gl_pt_bounces 1
gl_pt_shadow_samples 1
gl_pt_light_samples 1
gl_pt_static_entity_lights_enable 0
gl_pt_recompile_shaders
vid_restart

Meaning: PT is enabled, light bounces 1 time in the scene, shadows are sampled at a rate of 1, the lights are sampled at a rate of 1, static entity lights are disabled. Shaders are recompiled, and the graphics engine has been refreshed (does not affect progress in the level). Recompile shaders is a requirement for changing most settings. Vid restart is required for changing static entity lights on or off.

Pro Tips:
You can change all settings with PT disabled, but to see any changes, it must be turned back on.
Static entity lights are required for full visibility in at least one room in the demo. Beware, it is a performance killer and is disabled by default.
Outside areas are darker and harder to render. Perhaps the key lies in tuning the skybox/skybox lighting settings?
The in-game options menu works as intended. Changing your resolution affects performance and image clarity.
 
So why is it called path tracing now instead of ray tracing?

EDIT: Aha, it's a variant. But there are so many other applications for word path that this just asks for confusion.
 

tuxfool

Banned
Impressive. Though I wonder if the game could retain frame samples and blend them in order lighten the load, instead of rebuilding each from scratch each frame.


So why is it called path tracing now instead of ray tracing?

EDIT: Aha, it's a variant. But there are so many other applications for word path that this just asks for confusion.

Both are used interchangeably, sometimes people use ray casting in contexts other than lighting.
 

Zaru

Member
It's great that a 90s game can run path tracing like this, but at the end of the day, getting rid of the last bits of noise takes way longer than lighting the scene to make it recognisable (like in the video), so we're still far off.
 

M3d10n

Member
So why is it called path tracing now instead of ray tracing?

EDIT: Aha, it's a variant. But there are so many other applications for word path that this just asks for confusion.

While both involving tracing rays, there's a distinct difference.

In "traditional" ray tracing, rays are cast from the camera (for example, one for each viewport pixel) and when they hit a surface, rays are cast from that point to each light in the scene to figure out that point's color. Surfaces can manipulate the ray to reproduce optical effects like reflection, refraction, caustics, etc.

The problem with vanilla ray tracing starts when you want to simulate phenomena that goes beyond a tracing a single ray from the camera to a light (aka: "global illumination" or "radiosity).

Path tracing works the opposite way: it traces rays from the light sources, let them hit surfaces on the scene and then determines how much of the resulting light is going to hit the camera (if at all). It's actually simulating how light propagates in the environment until it hits the camera, which has the advantage of simulating a whole lot of optical phenomena with one general algorithm in a physically correct way. A basic path tracer that can produce photoreal images can be written with very few lines of code.

The problem with path tracing is that, since rays are cast at random from light sources, they aren't guaranteed to reach the camera and the image becomes "noisy", much like trying to take a picture in a dark place with low-ISO camera. To get a clean image you need a lot of rays (like a longer exposure), which takes a lot of power. On the other hand, the early noisy image contains all effects from the start and it allows artists to get a quick and accurate preview of what their scene is going to look.
 

Shifty

Member
Very nice. I've been interested in ray & path tracing since building a space-bending raytracer back when I left uni.
The possibilities are nuts, I really hope to see it become the standard for real-time rendering in my lifetime.

Edit: God these threads are such schadenfreude at CluelessGAF's expense ❤️
 

wwm0nkey

Member
Not exactly sure what this is doing.

Basically realistic rendering, ray & path tracing are SUPER intensive because its basically bouncing atoms everywhere to calculate light and etc (iirc). So it's super resource intensive but once we can get these running in realtime? Games will look insane
 

vio

Member
I somehow expected better quality. Too bad you cannot change those settings. Still, very impressive framerate.
 
Sam's post goes into more detail on how it works.

I somehow expected better quality. Too bad you cannot change those settings. Still, very impressive framerate.

It's in the OP, and is demonstrated in video 4.

You can change your rendering resolution in the in-game options menu. Use the console (press ~ while in game) to change the path tracing settings, all of which are listed on the link at the top.
 
Top Bottom