Hundred Lights
You'll build a deferred renderer that writes positions, normals and colors to a G-buffer, then lights the scene with ten times more lamps than forward rendering could manage.
About
Forward rendering does the lighting math for every light on every pixel of every object, whether the light reaches it or not, and it falls over somewhere around ten lights. Deferred rendering draws the scene once into a set of textures, then lights only the pixels each light can touch. It's how most big games handled lighting for a decade, and building one teaches you multiple render targets, screen-space passes and why transparent things are such a pain. A hundred lights is the number where the difference is impossible to miss.
At a glance
- Per requirement
- 35 XP
- Completion bonus
- 300 XP
- Requirements
- 6
- Takes
- Two to three weeks
- Skill level
- Advanced (years of practice)
- Cost
- Free
- Supplies
- Nothing special
- Where
- At home
- Other people
- On your own
Requirements
-
1
Render a scene with ten lights the forward way and measure the frame time. Loop over the lights in the fragment shader. Raise the count until the frame time doubles, and note the number. Take a screenshot with the light count and the milliseconds on screen. Photo
-
2
Write position, normal and albedo into a G-buffer and display each one. Use multiple render targets in one pass. Show the three textures tiled on screen, where the normals look like a rainbow and the positions look like a gradient. Take a screenshot of the tiled G-buffer. Photo
-
3
Light the scene in a full-screen pass that reads the G-buffer. Draw two triangles, sample the three textures per pixel and apply the lighting. The result should match the forward version exactly. Take a screenshot of forward and deferred side by side with the same scene. Photo
-
4
Draw each light as a sphere so it only touches the pixels it reaches. Give every point light a radius where its brightness falls below about 5 over 256, and draw a sphere of that size that runs the light shader only inside it. Take a screenshot showing the light volumes as wireframes over the scene. Photo
-
5
Run a hundred moving lights and compare the frame time to the forward version. Animate the lights so they drift through the scene, and print the count and the frame time. Film twenty seconds with both on screen. Video
-
6
Write one page on what deferred cannot do and how you'd handle it. Transparency, antialiasing and many different materials are the usual answers. Take a photo or a screenshot of the page. Photo