knightcrawler25 / GLSL-PathTracer

A toy physically based GPU path tracer (C++/OpenGL/GLSL)
MIT License
1.87k stars 176 forks source link

why use tile rendering #84

Closed qstx closed 1 year ago

qstx commented 1 year ago

Hi, I have to admit it's a pretty cool project,but I have a question about the tile rendering. Why would you think of rendering a small tile multiple times, which seems to be indistinguishable from rendering the entire frame at once?

knightcrawler25 commented 1 year ago

Hey :) Rendering the frame a tile at a time increases responsiveness of the application on older GPUs.

Some background:

The project is aimed at older GPUs that do not have support for hardware-accelerated RT. That is why everything from BVH traversal, and ray-triangle intersections to shading is done in a pixel shader. This allows people with old yet relatively decent GPUs to run the code. However, pixel shaders have their limitations as there's no control over how work gets executed on the GPU. This, along with the compute intensive nature of path tracing would mean rendering the entire frame at once will often cause the GPU to hang up and the display driver to crash. A simple solution to this is to split the rendering into small tiles, essentially simulating (in an very unsophisticated way of course) what CUDA/Compute shaders explicitly allow you to do.

With Vulkan/DXR/OptiX, significantly higher performance can be achieved with the cost of being locked to a vendor and/or the need to have a modern GPU that supports hardware-accelerated RT.

qstx commented 1 year ago

Thanks a lot for your quick answer, it lets me know why you're doing this. ≧◠◡◠≦

qstx commented 1 year ago

Hey :) I just make a simple real-time raytracing (with gpu filtering) using your framework. Can I make this repositorie public? Here is my url(https://github.com/qstx/Real-Time-GLSL-Based-PathTracing).

knightcrawler25 commented 1 year ago

Sure, you can make the repo public 😊

ib00 commented 1 year ago

You mention that pixel shaders are executed in a different way than compute shaders (hence need of tiles). Is there a good reference describing this (difference of pixel vs compute shaders are executed)?

Thanks.

knightcrawler25 commented 1 year ago

@ib00 This answer from stack overflow explains it in a more understandable way than I probably did:

https://stackoverflow.com/questions/44181875/ray-tracing-via-compute-shader-vs-screen-quad

ib00 commented 1 year ago

Thanks for the link. Good explanation.