0 Replies - 1524 Views - Last Post: 19 September 2012 - 09:01 PM

#1 PyroCybin  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 02-July 12

Faster Viewport.Unproject

Posted 19 September 2012 - 09:01 PM

Im making a raytracer in c# using XNA and have run into a bottleneck in the speed of viewport.Unproject.

This function is called twice per pixel to create the ray and i have found that this is by far the bottlneck as using the same precomputed ray for each pixel (just for the purposes of a speed comparison) is the difference between 10fps and 60fps. My only conclusion, given that the Unproject function is significantly slower even than the ray/tree traversal, is that unproject must be severely unoptimized. This I'll admit would not usually be a problem given that its mostly used for picking but in this case it needs to be as fast as possible. Could someone with a better handle on 3D math show me an exposed version of the function (optimized if possible but not necessary).

As a pointer i feel there ma be an optimization that could be found in precomputing an array of rays based on a viewport at some specific location and then transforming the rays within the ray loop. I also tried simply unprojecting the starting point of the ray and setting the direction to the forward vector of my view matrix, to cut out one of the Unprojects. I expected something akin to orthographic projection but got something akin to a dog's breakfast, still don't understand why :P

Is This A Good Question/Topic? 0
  • +

Page 1 of 1