Time-gated rendering (online)¶
This tutorial renders the Cornell box from Time-gated rendering in an interactive window. The image converges while the camera stays still, and the settings and the camera can be changed while it runs.
1. Open a window and load the scene¶
With a window, the frame buffer takes the window size, so no resize_frame_buffer call is needed.
import falcorcomp as falcor
testbed = falcor.Testbed(create_window=True, width=1024, height=1024, title="Time-gated Cornell box")
testbed.load_scene("cornell-box/scene-v4-nolight.pbrt")
testbed.scene.camera.aspectRatio = 1.0
testbed.clock.pause()
2. Build the render graph¶
The graph is the offline one. The window shows the first marked output, so only the tone-mapped image is marked.
graph = testbed.create_render_graph("TimeGated")
graph.create_pass("VBuffer", "VBufferRT", {"samplePattern": "Center", "sampleCount": 1})
graph.create_pass("Laser", "LaserLight", {
"laserPosition": [0.0, 1.7, 6.8], "laserDirection": [0.0, 0.0, -1.0],
"laserPower": [170.0, 120.0, 40.0], "laserAngle": 0.0,
})
graph.create_pass("Tracer", "TimeGatedPathTracerInline", {
"samplesPerPixel": 16, "maxBounces": 6, "computeDirect": False,
"timeGateMode": "box", "timeGateWindow": 0.1, "timeMin": 17.337, "timeMax": 17.337,
})
graph.create_pass("Accumulate", "AccumulatePass", {"precisionMode": "SingleCompensated"})
graph.create_pass("ToneMapper", "ToneMapper", {"autoExposure": False})
graph.add_edge("VBuffer.vbuffer", "Tracer.vbuffer")
graph.add_edge("VBuffer.viewW", "Tracer.viewW")
graph.add_edge("Laser", "Tracer")
graph.add_edge("Tracer.color", "Accumulate.input")
graph.add_edge("Accumulate.output", "ToneMapper.src")
graph.mark_output("ToneMapper.dst") # shown in the window
testbed.render_graph = graph
3. Run¶
run() renders frames until the window is closed.
testbed.run()
Controls¶
Camera: drag with the mouse to look around;
W/A/S/Dmove,Q/Emove down and up (holdShiftto move faster,Ctrlto move slower).Settings: the Render Graph window has a section per pass. Under Tracer, Time gate sets the gate center, window and kernel; Shift gate moves the gate one step per frame from Gate min to Gate max, so the light front sweeps through the scene. The sampling method is below it. Under Laser, the laser position, direction, cone angle and type can be edited.
Window:
F1shows the help,F2hides the UI,Escexits.
Changing a setting or moving the camera restarts accumulation. With Shift gate on, every gate
step restarts it too, so each gate shows a single frame of samplesPerPixel samples.
The full script: time_gated_online.py.