Progessive Ray Tracer with Photon Mapping

BlitzMax Forums/BlitzMax Programming/Progessive Ray Tracer with Photon Mapping

AdamRedwoods(Posted 2010) [#1]
I've ported over a ray tracer that uses photon mapping. It is interactive and progressive, so you are able to drag around the spheres and light.

Originally written with Processing by Grant Schindler in 2007.
http://www.cc.gatech.edu/~phlosoft/photon/

I feel this version is slower than the Processing version, so there may be some ways to speed it up, but I'll leave that to someone else.

Enjoy!



Last edited 2010

Last edited 2010


KronosUK(Posted 2010) [#2]
slight correction to one of the functions

in Function Filtercolor

For Local c:Int=0 To 2 NOT For Local c:Int=0 To 3



Pretty amazing demo.


AdamRedwoods(Posted 2010) [#3]
Fixed, thanks for catching that!


Richard Betson(Posted 2010) [#4]
Pretty slick. :)


ima747(Posted 2010) [#5]
Very very cool, doesn't really like outputting on my system (lots of flicker and black spaces unless I'm moving something) but still really impressive


smilertoo(Posted 2010) [#6]
impressive, now can you multithread it?


AdamRedwoods(Posted 2010) [#7]

Very very cool, doesn't really like outputting on my system (lots of flicker and black spaces unless I'm moving something) but still really impressive



Yes, sorry about that. It's using a simple FLIP, assuming there is no backbuffer, and the backbuffer remains intact (bad, bad, bad). Converting the display code to use a pixmap would fix that.


AdamRedwoods(Posted 2010) [#8]
Now it's multi-threaded, but it's terrible!!!

I've also switched it to pixmaps instead of just flipping the redraw.

I think threading isn't always the way to go, especially with passing so much data around. It just isn't smooth, but I could be doing something wrong. ( but that's for someone else to explore )

Multi-threading:



BlitzSupport(Posted 2010) [#9]
Just got around to trying this -- impressive stuff!


Kryzon(Posted 2010) [#10]
I'm getting a "Identifier TMutex not found".


Perturbatio(Posted 2010) [#11]
I'm getting a "Identifier TMutex not found".

Me too, despite having the latest BMax installed and the threads module is definitely there.


BlitzSupport(Posted 2010) [#12]
Turn on Threaded Build!


Perturbatio(Posted 2010) [#13]
oops :)


Kryzon(Posted 2010) [#14]
oops [2]


col(Posted 2011) [#15]
Does this profile info help for the single thread version ?

Name			Average ms	Total ms	Calls		Lines	
raySphere		0.01		403		513912		15	
rayPlane		0.01		287		1284780		5	
rayObject		0.01		949		1798692		5	
checkDistance		0.01		70		1311247		6	
lightDiffuse		0.00		0		0		2	
sphereNormal		0.00		0		16414		1	
planeNormal		0.01		54		204506		4	
surfaceNormal		0.01		12		220920		5	
lightObject		0.00		0		0		2	
raytrace		0.01		1227		256956		8	
computePixelColor	0.62		116331		187648		31	
reflect			0.01		38		33272		2	
gatherPhotons		0.62		115161		187648		14	
emitPhotons		60.45		544		9		36	
storePhoton		0.01		13		54054		11	
shadowPhoton		0.01		198		27027		8	
filterColor		0.01		11		27027		5	
GetColorRGB		0.01		1		27027		7	
normalize3		0.01		67		280895		2	
sub3			0.01		108		563598		2	
add3			0.01		4058		19819653	2	
mul3c			0.01		4133		20536143	2	
dot3			0.01		493		21570536	1	
rand3			0.01		17		26703		3	
gatedSqDist3		0.01		18349		193699404	11	
odd			0.01		13		502016		2	
draw			181.25		116726		644		24	
drawInterface		0.00		0		1		1	
render			181.25		116723		644		34	
resetRender		60.25		482		8		6	
drawPhoton		0.00		0		27027		8	
GrabObject		0.20		1		5		11	
DragObject		35.09		421		12		15	

Function		Total time ms	% of program run time
.draw			116726		99.24
.render			116723		99.24
.computePixelColor	116331		98.91
.gatherPhotons		115161		97.91
.gatedSqDist3		18349		15.60
.mul3c			4133		3.51
.add3			4058		3.45
.raytrace		1227		1.04
.rayObject		949		0.80
.emitPhotons		544		0.46
.dot3			493		0.41
.resetRender		482		0.40
.DragObject		421		0.35
.raySphere		403		0.34
.rayPlane		287		0.24
.shadowPhoton		198		0.16
.sub3			108		0.09
.checkDistance		70		0.05
.normalize3		67		0.05
.planeNormal		54		0.04


I ran the code for 117612 ms (almost 2 mins) on a Vaio VGN-FW31M (Vista Home).

Last edited 2011


Doc Holliday(Posted 2011) [#16]
@col: sorry, but I'm new to bmx. How did you do the profiling? Is there any software out to do that? It's very interesting for me ...

Thanks in advance

Doc Holliday


col(Posted 2011) [#17]
@Doc Holliday

Hi, I did the profiling using software that I'd written. It loads in a BMax file and creates another file with profiler timing functions and data. Each function runs full speed, although the final exe runs slower because its only the bits in-between function calling that slow it down - obviously it doesnt matter about this slowdown as its only used for profiling.

Last edited 2011


Doc Holliday(Posted 2011) [#18]
@col:

Hello and thanks for the answer!

The profiling software you have written isn't available at random? ;-)
I'm interested in this piece of software, so is there a chance to get it?

Thx

Doc Holliday


col(Posted 2011) [#19]
Without meaning to 'off-topic' this thread Ive posted a reply in your thread about profiling in the BMax Beginner Forum

Dave