Tiled Forward Rendering #5
No reviewers
Labels
No Label
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: SeanOMik/lyra-engine#5
Loading…
Reference in New Issue
No description provided.
Delete Branch "feature/tiled-forward-rendering"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Tiled forward rendering is a very common rendering technique for rendering scenes with many many lights. In short, it uses a grid of tiles, that uses a compute shader to cull the lights in each tile. Then the fragment shader uses the results of the compute shader, and only calculates the lighting for each light in each tile instead of all lights.
Resources:
Note: All screenshots shown in this PR are taken from a window that is 800x600 unless labeled otherwise.
This has already been worked on before I made this PR. Here's a screenshot of the id of the tile as red and green in the fragment shader, with some lines:
This is the sponza scene with a blue point light rendered with forward+:
The top left tile appears to be the effects of the directional light in the scene. There is also a weird slightly darker square in the point light on the floor, it moves around with the camera.
a0b1e90bc6
to834a864544
Tiled forward rendering is finally working!
I also added a triggerable debug view that shows the amount of lights in each tile (by pressing B). The brightness of each tile is
number of lights in tile / total number of lights
Keep in mind that no optimizations have been made to the culling (i.e., AABB culling for point lights) so the culling isn't super accurate.
I did a bit of work to get spot lights working, but the light gets cutoff when moving closer to it:
A bug was also discovered that made it so the same mesh can't be shared between models which is why there aren't boxes at each light source in the above images.
Spot light culling was fixed, but in a non-optimal way. I couldn't figure out the issue with the math that checked if a cone was in the frustum, so I just treat the spotlight as a point light for culling. This is okay for now since optimizations for spotlight culling would replace the frustum culling.
WIP: Tiled Forward Renderingto Tiled Forward RenderingThis can be considered complete. The performance is pretty poor, but for that I need to profile the engine to see what is taking up a lot of time. There can be future PRs for improving the performance of the renderer.
With 500 lights in the sponza scene I get ~180fps (release build, vsync disabled) when looking at the scene with the lights, or ~250fps when looking away.