It will run out due to 32bit precision. 0,938182345394 for example will NOT fit in a fp32. For non tiling you must specify a range of some kind:
patch LOD 0 = -1 / +1
patch LOD 1 = -1/0 and 0/1
etc: LOD 20 = 0,9959944 to 0,9959944
No more precision!
If you have the solution to this one, patent it first before sharing it, because in all planet renderers ive encountered so far this is a unsolved problem!
Of course it only starts apearring in very deep levels (18+ for normals and 20+ for height maps)...
Now this genuinely interests me. I've noticed that all planet renderers have problems with precision, but apparently I'm in a different dimension because I don't have an idea why.
I also don't understand what you are saying. If I have a heightfield containing elevation in range, say ±16km, it will use 14 bits for whole meters, and with 24 bit mantissa 10 bits remain for fractional part until the resolution starts to deteriorate.
That means that for elevation higher than 8km or lower than -8km the maximum resolution is 1/1024m, <1mm
That's for the heights where the precision for terrain doesn't matter that much. On the sea level the resolution is many times better.
I guess there is some really significant difference in how all other planet renderers work. But I've never studied papers about planet rendering so I can't tell, just did it my way and simply had not encountered such problem.
But I'll be glad if you could explain it to me, I'm really wondering what's going on.
I'll try to explain it! When having a planet of earth size completely procedurally generated, you have a cube (of course) mapped to a sphere. Every side of this cube is: +/-40000 / 4 = 10.000 x 10.000 km. the 0,0 in local space lies in the center of each square to maximize precision.
Lod0 will be 10.000x10.000 km, have 'coordinates' ranging from -1 to 1. for example: lod level = 32 vertices.
Precision will be enough for this lod: you can divide the texcoord in 32, without running out of it!
Now imagine a veryy deep lod of let's say: 22! a patch of lod 22 in the right bottom corner of a square of the cube. the texCoords would be something like (made them up to demonstrate): 0,9877679 to 1. and here comes the problem: you can no longer divide the 32 vertices between 0.9877679 and 1, because you would need MORE numbers behind the comma = more bits = failure
.
A solution i've come up with is the following: i will instead divide with the same fractal function to 70 meters resolution, and then 'fade in' another level of fractals generated on top of the 'base fractals'. this high resolution fractals will use another coordinate system: for example high reso fractals come in at level 18.
now every patch of level 18 that's created will get two coordinate systems: one for base fractal generation and one for fine detail generation: this fine coor. system wil use THAT patch as it's local system (from -1 to 1). because fractals can tile this wont be a problem!
The only problem here is: generation of tiles will take longer because not only base fractals must be generated but also a high resolution fractal must be generated on top.
I haven't implemented it yet for i'm now busy with finally writing an engine instead of crap code
!
Okay i understand. This must make it difficult for example to let a planet move? All objects then should be translated to match movement of the planet every frame?! that's crazy! ... It must work in a different way.
It uses ECEF coordinate frame so its the image of sun and stars that are moving. These are rendered specially anyway.
Ahhh i see. My renderer will use orbits around a sun, etc. Stars far away will be rendered to a skybox/dome of course.
Is there like a 'common' pipeline which all geometry goes through, or do you use specialized rendering systems per 'object'? And how does the shadering/materials/effects work in your engine? UberShader, dynamic linking, dynamic generation?
Not a completely common pipeline - objects use their common one (with an ubershader, basically).
Terrain uses its own special pipeline, relatively tightly integrated with the fractal generator framework and related stuff. The terrain material system will be updated to handle climate and land class data, but the development won't go in the direction of one common pipeline - the terrain subsystem is so huge and specialized that it deserves it's own optimized system. I'd say it wouldn't work very effectively if it used a generic pipeline, and we'd be probably elsewhere now ..
I understand. It's loosely how i'm integrating shaders myself too. Base effects for common stuff and specialized custom shaders for terrain, atmosphere, skybox, etc.
I hope you understand the part about the precision issues. if something is unclear i will try to explain it in more detail!