#OpenGL 32 bits limits

1 messages · Page 1 of 1 (latest)

eager sparrow
#

Hi everyone ! I’m making a Minecraft clone for fun and decided to add chunk génération. Everything is working perfectly, my chunks can render at trillion of blocka from the world origin and all except I got one problem. Starting to 1 million in coordinates, OpenGL starts tweaking and messing up the rendering. After doing some research, I got it. I’m using vec4 for my position instead of dvec4 with doubles. The more the number gets, the less precise is the float. So a double (which has 52 bits for that) is the right choice then !
Well… not really

Doubles are INSANELY slow. I got from 180 FPS with a 16x16 render distance by 20 FPS with the same render distance. I cannot use it at all. So can someone give me some tips to how I can increase the precision of matrices instead of using doubles and destroying performances ?

I tried many things like the “move the camera around the world and not the other way” method and it doesn’t seem to work. I tried the “use doubles in CPU but send results only float in the GPU”. But none of that increased the distance where things are cracking up.

#

And how even Minecraft achieved the 21 million blocka away from world origin before things being messed up ?

#

Me it’s already doing a thing at 1 million blocks away from world origin 😭😭

light glen
#

You have to carefully plan your operations around the available precision so that you keep your float ops to relatively small orders of magnitude

#

Just go through your generation+transformation pipeline and identify which operations are involving large values and then use integer offsets or doubles or whatever method is most appropriate to do that step in a less lossy way so that the single precision floats and GPU stuff is all relative to a nearby origin

#

There isn't one universal way to do this it depends on the implementation details of your specific application

eager sparrow
#

I see

#

But isn’t Unity or No man’s sky achieved something like this ?

light glen
#

Yes

#

Wdym "but"

eager sparrow
#

Basically, no man’s sky doesn’t have all this planets in the same “world space”

#

They’re all levels, or, let’s call them région which are used like offsets

#

As for Unity… idk but I think I can go with the NMS approach

light glen
#

Unity doesn't support any of this out of the box it's something that the game needs to handle itself

#

Even general purpose engines that do support double precision are still only supporting doubles which get you about one solar system worth of distance without unacceptable degradation of precision

#

These mega scale things like no man's sky or infinite scale procgen need more than just doubles

heady ether
#

there is nothing tying you to a single 'world space'

#

world space is just a convention

#

its up to you to figure out how to render things without precision becoming an issue

#

minecraft has a flat grid which it can index with simple integers