OpenGL and double?
Hi,
I've been using OpenGL for some time now. I like the API, it's clean, it's complete and very well designed. However, I've always wondered: Why are lighting and material calculations only possible with floats, respective GLfloats?
Just wondering. Everything I do is double-based (for accuracy). Converting to float isn't hard for sure, but why is it neccessary? ;)
Cheers,
Drag0n
probably be cause no graphics card natively supports operations on doubles, they all use floating point value internally (as does the GLSL)
You don't need a precision like double for, say materials. I don't think you would see the difference.
Also, if I'm correct, floats are faster than doubles in general.
Also, if I'm correct, floats are faster than doubles in general.
_the_phantom_: If I recall correctly, the values are converted to 80 bit extended precision internally in the GPU. But I might be wrong.
WanMaster: Sure, I don't need the extra precision (at least not for materials and lighting). But there are double-variants of virtually all OpenGL functions, why not for materials and lighting? ;)
Cheers,
Drag0n
WanMaster: Sure, I don't need the extra precision (at least not for materials and lighting). But there are double-variants of virtually all OpenGL functions, why not for materials and lighting? ;)
Cheers,
Drag0n
Well, for glInterleavedArrays there aro no double formats too... while it's possible to use glVertexd instead of glVertexf... mah... Because of this I decided to use floats instead of doubles :P
Quote:Original post by BladeWise
Well, for glInterleavedArrays there aro no double formats too... while it's possible to use glVertexd instead of glVertexf... mah... Because of this I decided to use floats instead of doubles :P
I'm starting to think, maybe it'll be my decision, too... ;)
Cheers,
Drag0n
Quote:Original post by Drag0n
WanMaster: Sure, I don't need the extra precision (at least not for materials and lighting). But there are double-variants of virtually all OpenGL functions, why not for materials and lighting? ;)
Drag0n
WanMaster, there are double-variants of virtually all OpenGL functions to simplify using your data structures. This is so that you do not have to explicitly convert your data structures. There are lots of situations where you need double precision, for example, game physics, and it is convenient that values from that can be used directly. However the above posts are correct that no video cards support double precision, and therefore several OpenGL commands will not accept doubles...basically anything that involves more than one data element (textures, vertex arrays).
So why no doubles for materials...they could be converted to floats internally...But the thing is you probably don't calculate material properties dynamically. You load them as part of your model...so it kind of makes sense that you'd start out with floats and never need to use doubles.
All philosophical though... :-)
Quote:Original post by renderer
All philosophical though... :-)
But right you are! ;) Didn't even think about that before, I probably don't really need to constantly convert floating point numbers around. Materials are pretty much constant I would think, and the lights that I can attach to my (double-based) "Movable" won't break the performance...
Cheers,
Drag0n
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement