View Full Version : Size of the model: render time and light intensity
01-31-2012, 03:03 AM
For a OpenGL/JOGL application, I have a real-size model of an object. My model is a little big (it can be surrounded by a sphere of radius 3 meters). While working on this, couple of questions have puzzled my mind:
Does the size of the model has any effect on the render time? More precisely, if I scaled down my model by a factor of 0.01, am I going to have a faster render? (scaling down the model before importing and not using glScale) Consider I'm brightening my scene with a light source which has a certain intensity. If I scale (up/down) my model, in order to obtain the same appearance, should I also scale my light intensity?
Thanks in advance :)
01-31-2012, 05:03 AM
1. no, size does not have any effect on rendering speed, the size of how big it is on the screen might, but normally it shouldn't make that much of a difference.
Scaling before also does not have any effect since you are still scaling/rotating/translating at render time.
The only scaling you should do beforehand is to get the objects in the same scale as everything else, personally i make sure all objects use 1.0f = 1.0m
2.no, but you will have to move the lights position in relation to the objects scaling to obtain the same appearance.
01-31-2012, 08:45 AM
zeoverlord isn't wrong, but to be pedantic... :p
If you are using Fixed Function functionality (aka FFP) of OpenGL (pre GL2.0, no GLSL shaders), then scaling with glScalef will actually affect lighting because the normals (glNormal3f) will be scaled also. Calling glEnable(GL_NORMALIZE); at your application initialization will instruct OpenGL to automatically correct the normals' magnitude to compensate for this.
And theory, this re-normalization might affect performance negatively, though negligible on all modern hardware. If you're not sure, GL_NORMALIZE will do no harm, so try it if lighting looks odd after scaling (excessively bright when scaling up, or darker when scaling down).
There are situations where scaling does cause problems; floating point accuracy. Very large (or very small) floating point numbers may cause polygons to appear wobbly in relation to a moving camera viewpoint. So generally it is preferred to keep numbers in 0.0 to 1.0 range for optimal accuracy (but the 3.0 of your example just fine still!). Wikipedia has some more details: http://en.wikipedia.org/wiki/Floating_point
Not really important for beginners, but awareness of the problem can be useful further down the road.
As zeoverlord hinted at, please note that OpenGL is dimensionless. A "3m radius" doesn't particularly mean anything. OpenGL units are whatever you want them to be. I'll assume that you meant the number "3.0". Not a huge difference, but there's a subtle importance. :)
02-02-2012, 08:15 AM
One other point to consider is numerical accuracy and data precision range.
If your app wanted to display both a model that is say 2 millimeters and a model that is 2 kilometers, then the data type of how you store this data becomes important and the data types used in OpenGL also become important.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.