How is regular data usually stored?

This is a pretty simple question. I am studying 3D graphics and lighting at the moment and was wondering how normal data is stored (usually).

Is it standard to store this data as part of any external "model" file loaded into your program, or to recalculate the normal data from the vertex data every time a new model is loaded? Or are there benefits to both methods and are sometimes used for different reasons?

+3


source to share


3 answers


opengl allows multiple attributes of each vertex when sent to the GPU for processing, the most commonly used for this are position, normals and texture mappings



the most basic of all submitted models (obj file) allows you to choose whether to include data at all. But for most more complex models, normals are not standard and need to be stored in model files.

+1


source


It, as always on the schedule, depends.

If you have a simple model, don't recompose the normals. Storing them is basically caching.



However, if you use pixel-based highlighting, normals are preserved in pixels in normal (bump, etc.) maps. In this case, they usually cannot be generated procedurally (they are generated from models with a higher number of policies).

+2


source


In general, this is not just an assessment of effectiveness. Normals are part of the model and cannot be dropped and re-created from vertex positions.

Imagine a typical case when you create a shape in a modeling program. Internal data describing a shape in software most likely consists of analytical surfaces, for example. slotted surfaces. When you export a shape to a vertex-based format, the analytic surface is approximated by a triangular mesh. The mesh vertices will be written out as the positions of the vertices, as well as connectivity information that determines how the vertices form the mesh. The analytic surface normals at the vertex point will be calculated for each vertex and written out along with the vertex positions.

If you have a vertex mesh with no normals (for example, since you never exported normals or selected them), you can still compute surface normals. This is usually done by averaging the face normals of all the faces adjacent to each vertex, perhaps as a weighted average that takes into account the area or angle of the face. However this calculation is performed, the result is an approximation of the normals of the original analytical surface.

The difference between using exact normals from the original analytic surface and using approximate normals reconstructed from a triangular mesh can be very noticeable when rendering. This will largely depend on how subtle the tessellation is and which lighting model is used. But in most cases, the reconstructed normals are not as good as the normals from the original model, and the machined surface will look smoother / cleaner if the original normals are used.

+1


source







All Articles