Photon Mapping on Photon Mapping on Programmable Graphics Programmable Graphics Hardware Hardware Timothy J. Timothy J. Purcell Purcell Mike Cammarano Mike Cammarano Pat Hanrahan Pat Hanrahan Stanford Stanford University University Craig Donner Craig Donner Henrik Wann Henrik Wann Jensen Jensen University of University of California, San California, San Diego Diego
53
Embed
Photon Mapping on Programmable Graphics Hardware Timothy J. Purcell Mike Cammarano Pat Hanrahan Stanford University Craig Donner Henrik Wann Jensen University.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Photon Mapping on Photon Mapping on Programmable Graphics Programmable Graphics
HardwareHardware
Timothy J. Timothy J. PurcellPurcell
Mike Mike CammaranoCammarano
Pat HanrahanPat Hanrahan
Stanford Stanford UniversityUniversity
Craig DonnerCraig Donner
Henrik Wann Henrik Wann JensenJensen
University of University of California, San California, San
DiegoDiego
MotivationMotivation
MotivationMotivation
• Interactive global illumination on the Interactive global illumination on the GPUGPU• Nearly have sufficient compute power and Nearly have sufficient compute power and
• CPU-based interactive global CPU-based interactive global illuminationillumination• Supercomputers [Parker et al.]Supercomputers [Parker et al.]
• Clusters [Tole et al., Wald et al.] Clusters [Tole et al., Wald et al.]
• Global illumination on programmable Global illumination on programmable GPUsGPUs• Ray tracing [Carr et al., Purcell et al.]Ray tracing [Carr et al., Purcell et al.]
• Photon mapping [Ma et al.]Photon mapping [Ma et al.]
• Radiosity [Carr et al., Coombe et al.]Radiosity [Carr et al., Coombe et al.]
• Translucency [Carr et al., Stamminger et al.]Translucency [Carr et al., Stamminger et al.]
• No priority queueNo priority queue• Can’t build on GPUCan’t build on GPU
•Too much stateToo much state
ContributionsContributions
• Mapped complete grid-based photon Mapped complete grid-based photon mapping algorithm onto the GPUmapping algorithm onto the GPU• Including photon tracing, ray tracing, etc.Including photon tracing, ray tracing, etc.
• Implemented an adaptive Implemented an adaptive kk-nearest -nearest neighbor searchneighbor search• kNN-gridkNN-grid
• Show how to construct a sparse data Show how to construct a sparse data structure on the GPUstructure on the GPU• Bitonic merge sort with binary searchBitonic merge sort with binary search
• Stencil routingStencil routing
Configuring the GPU for Configuring the GPU for ComputingComputing• GPU as data parallel compute engineGPU as data parallel compute engine
• Fragment programs execute compute kernelsFragment programs execute compute kernels
Building a Sparse Data Building a Sparse Data StructureStructure
Building a Sparse Data Building a Sparse Data StructureStructure• Requires scatterRequires scatter
• Dependent texture writeDependent texture write
• Why don’t we have fragment Why don’t we have fragment scatter?scatter?• Fragment processing has highly coherent Fragment processing has highly coherent
blocked memory writesblocked memory writes
• Extra hardware support would be needed Extra hardware support would be needed
•Write hazardsWrite hazards
•Memory latenciesMemory latencies
Scatter on the GPUScatter on the GPU
• Sort photons into grid cellsSort photons into grid cells• Grid cell is sort keyGrid cell is sort key
• Simulate scatter with fragment Simulate scatter with fragment programsprograms• Bitonic merge sort followed by binary searchBitonic merge sort followed by binary search
• Grid cell searches for self in photon Grid cell searches for self in photon listlist• If none, find first element in next cellIf none, find first element in next cell
• Grid cell searches for self in photon Grid cell searches for self in photon listlist• If none, find first element in next cellIf none, find first element in next cell
v0v0 v0v0 v2v2 v2v2 v5v5v0v0 v5v5SortedSortedPhoton ListPhoton List
v2v2
Searching for first v5 photon
initialize
Binary SearchBinary Search
• Grid cell searches for self in photon Grid cell searches for self in photon listlist• If none, find first element in next cellIf none, find first element in next cell
v0v0 v0v0 v2v2 v2v2 v5v5v0v0 v5v5SortedSortedPhoton ListPhoton List
v0v0 v0v0 v2v2 v2v2 v2v2v0v0 v5v5
v2v2
v5v5
Searching for first v5 photon
initialize
step 1
v5v5
Binary SearchBinary Search
• Grid cell searches for self in photon Grid cell searches for self in photon listlist• If none, find first element in next cellIf none, find first element in next cell
v0v0 v0v0 v2v2 v2v2 v5v5v0v0 v5v5SortedSortedPhoton ListPhoton List
v0v0 v0v0 v2v2 v2v2 v2v2v0v0 v5v5
v0v0 v0v0 v2v2 v2v2 v5v5v0v0
v2v2
v5v5
v2v2
Searching for first v5 photon
initialize
step 1
step 2
v5v5
Binary SearchBinary Search
• Grid cell searches for self in photon Grid cell searches for self in photon listlist• If none, find first element in next cellIf none, find first element in next cell
v0v0 v0v0 v2v2 v2v2 v5v5v0v0 v5v5SortedSortedPhoton ListPhoton List
v0v0 v0v0 v2v2 v2v2 v2v2v0v0 v5v5
v0v0 v0v0 v2v2 v2v2 v5v5v0v0
v0v0 v0v0 v2v2 v2v2 v2v2v0v0 v5v5
v2v2
v5v5
v2v2
v5v5
Searching for first v5 photon
initialize
step 1
step 2
step 3
v5v5
Binary SearchBinary Search
• Grid cell searches for self in photon Grid cell searches for self in photon listlist• If none, find first element in next cellIf none, find first element in next cell
• Accept or reject photons in cell visit Accept or reject photons in cell visit orderorder
kNN-grid AlgorithmkNN-grid Algorithm
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Candidate photons Candidate photons must be within max must be within max search radiussearch radius
• Visit voxels in Visit voxels in order of distance order of distance to sample pointto sample point
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• If current number If current number of photons in of photons in estimate is less estimate is less than number than number requested, grow requested, grow search radiussearch radius
1
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• If current number If current number of photons in of photons in estimate is less estimate is less than number than number requested, grow requested, grow search radiussearch radius
2
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Don’t add photons Don’t add photons outside maximum outside maximum search radiussearch radius
• Don’t grow search Don’t grow search radius when radius when photon is outside photon is outside maximum radiusmaximum radius2
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Add photons within Add photons within search radiussearch radius
3
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Add photons within Add photons within search radiussearch radius
4
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Don’t expand Don’t expand search radius if search radius if enough photons enough photons already foundalready found
4
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Add photons within Add photons within search radiussearch radius
5
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Visit all other Visit all other voxels accessible voxels accessible within determined within determined search radiussearch radius
• Add photons within Add photons within search radiussearch radius
6
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
kNN-grid AlgorithmkNN-grid Algorithm
• Finds all photons Finds all photons within a sphere within a sphere centered about centered about sample pointsample point
• May locate more May locate more than requested than requested kk--nearest neighborsnearest neighbors6
sample point
photons in estimatecandidate photon
Want a 4 photon estimate
System ImplementationSystem Implementation
• NVIDIA GeForce FX 5900 Ultra NVIDIA GeForce FX 5900 Ultra (NV35)(NV35)
• How to prevent program execution How to prevent program execution over a subset of pixels?over a subset of pixels?• Non-uniform pixel computation distributionNon-uniform pixel computation distribution
•Radiance estimateRadiance estimate
• KILL is only a write maskKILL is only a write mask
• Compute mask, branching, or stream buffer?Compute mask, branching, or stream buffer?
• Improve radiance estimate speed by 30-70% Improve radiance estimate speed by 30-70% over tilingover tiling
Open Issues (2)Open Issues (2)
• ScatterScatter• Makes (a programmer’s) life easierMakes (a programmer’s) life easier
• Is it worth implementing?Is it worth implementing?
•Gain factor of logGain factor of log2 2 n avoiding sortn avoiding sort
Future WorkFuture Work
• Kd-treesKd-trees
• Photon power redistributionPhoton power redistribution
• Adaptive samplingAdaptive sampling
• Progressive refinementProgressive refinement
ConclusionsConclusions
• The GPU can compute an entire global The GPU can compute an entire global illumination solutionillumination solution• Nearly interactiveNearly interactive
• Implemented an adaptive Implemented an adaptive kk-nearest -nearest neighbor query for the GPUneighbor query for the GPU• kNN-gridkNN-grid
• Shown how to construct sparse data Shown how to construct sparse data structures on the GPUstructures on the GPU• Bitonic merge sort and binary searchBitonic merge sort and binary search
• Stencil routingStencil routing
• Sorting and searching algorithms Sorting and searching algorithms applicable to other computationsapplicable to other computations
AcknowledgmentsAcknowledgments
• Stanford FlashGStanford FlashG• Ian Buck, Mike Houston, Kekoa ProudfootIan Buck, Mike Houston, Kekoa Proudfoot
• Stencil routingStencil routing• Kurt Akeley, Matt PapakiposKurt Akeley, Matt Papakipos
• Hardware and driversHardware and drivers• David Kirk, Nick TriantosDavid Kirk, Nick Triantos