GPWiki.org
GPWiki.org
It is currently Sun May 19, 2013 2:36 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Jan 07, 2012 8:48 am 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
I have come to a bit of a problem well its not reall a problem as it is anoying. I have reached my limit on my planet renderer, if the planet radius is over 5000000.0f, i get wiered issues with the camera and also the distance calculation always comes out as NAN. i gather this is due to the float been too small to handle the numbers. I know in dx you could just write a double vector class, is it possible to use one in xna, or would i just hae to find a way round it , any advice is great guys.

Thanx in advance.


Top
 Profile  
 
PostPosted: Sat Jan 07, 2012 2:07 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
floats can hold really big numbers (up to 10^34). It's just that you only have about 7 significant figures with single precision. If you're getting a NAN, I think that means you're dividing by 0 somewhere. So rather than your problem being that floats can't hold big enough numbers, maybe they're not able to hold a small enough number somewhere in your code.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
PostPosted: Sat Jan 07, 2012 3:01 pm 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
Thanx.
sorry thats what i mean i think its to do with precicion on a smaller numbers specially when it get down to the really high detail on the terrain. but would using doubles work for this, or is it just completely pointless as the numbers passed to the shader/rendering piepline are stil float.


Top
 Profile  
 
PostPosted: Sat Jan 07, 2012 7:37 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
Using doubles might work, but it would still leave you with the same problem if you crank up your scales enough and it would possibly slow your program down a bit. Rather have a look at where the NaN is getting spat out and add some code to handle the edge case.

Reading this http://steve.hollasch.net/cgindex/coding/ieeefloat.html I think I was wrong about you dividing by 0 - that should give you infinity. Have a look at the "Special Operations" table where it shows what operations will result in NaN. There's an even more comprehensive list on Wikipedia http://en.wikipedia.org/wiki/NaN#Creation. Rather fix your code than try to solve the problem with a bigger data-type.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
PostPosted: Sun Jan 08, 2012 12:29 pm 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
I figured it out it was the noise generation function, and also a little added variable i shouldent, so i just used my new simplex noise class, and got rid of the redundant variable and hey presto :). The only thing was that it bloody took 4 hours of adding NAN exceptions to functions and tracing it back to the right line of code causing the problem. The funny thing was it was only troughing this out if i used a heightmap, if i used a heightmap generated using fractals, it just works, cant be bothered to figure out why it works perfectly now. I have though moved most distance calculation variables to doubles, i want the acuracy and to be ohnest at the ground i get around 120fps not moving and about 40 - 60 moving, but ofcource the problem with quadtrees, its the updating, i need to find a way to speed this up.

cant use vertex and index buffers they just take too dam long to create, cant create them at loadtime or memory will go nuts. I only use 1 set of index buffers so this helps. anyways im just rambling now, thanx for the help :).


Top
 Profile  
 
PostPosted: Sun Jan 08, 2012 8:45 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
Nice, well done 8)

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group