Skip to content

Latest commit

 

History

History
198 lines (153 loc) · 5.36 KB

lecture03_modelLoading.asciidoc

File metadata and controls

198 lines (153 loc) · 5.36 KB

Model Loading

What is a Model, in Computer Graphics?

  • What does it represent?

  • What is in model files?

  • What information/data to we need?

What is a Model? 2

  • Meshes / Geometry

    • set of Vertices

    • set of Normals

    • set of UV coordinates

    • set of faces (tris, quads, generic polys)

What is a Model? 3

  • Materials

    • Colours (per Vertex/face)

    • Textures (texture information and UV map)

    • Light properties (Diffuse, Specular, Ambient)

    • Other surface properties (Bump maps)

    • Shaders

What is a Model? 3

  • Animations

    • key-frames

    • skinning data

  • Model Node Hierarchy

  • Scale/Units

  • Metadata

What else can be in a model file?

  • Perhaps an entire Scene

    • Multiple models

    • Cameras

Model Formats

  • What formats do can you name?

  • What formats do asset generating tools export to?

Model formats, a short, incomplete list

  1. .3ds - 3D Studio

  2. .blen - Blender

  3. .dae - COLLADA

  4. .dxf - AutoCAD

  5. .fbx - Autodesk exchange

  6. .obj - Wavefront Obj

  7. .ply - Polygon file format

  8. .skp - Google sketchup

  9. .stl - STereoLithography

  10. .tri

  11. .v3d

  12. .wrl - VRML

  13. .x3d

  14. .x3dv

Text vs. Binary formats

  • Text formats have some pros and cons in comparison to binary formats

  • ???

Text formats

  • human-readable

  • easy to debug

  • LARGE and SLOW

    • needs lots of parsing

  • Can, sometimes, compress well

  • lots of standard formats (JSON, XML)

Binary formats:

  • non-human readable

  • hard to debug

  • SMALL and FAST

    • need little (possibly no) parsing; need no text to binary conversion

      • 2153253232 (10 bytes) ⇒ 0x80580970 (4 bytes, 32 bit)

      • 3.1415927 (9 bytes) ⇒ 0x40490fdb (4 bytes, 32 bits)

    • can load directly into memory

    • could, perhaps, bypass the CPU and main RAM entirely (DMA)

  • Could still compress

A look at .obj

  • OBJ file format

  • Open (no licensing issues)

  • Using by many 3D graphics application vendors

    • A pretty universally accepted format

  • Coordinates have no units

    • file can contain scale information in a comment line

.obj example

# List of geometric vertices, with (x,y,z[,w]) coordinates, w is optional and defaults to 1.0.
v 0.123 0.234 0.345 1.0
v ...
...
# List of texture coordinates, in (u, v [,w]) coordinates, these will vary between 0 and 1, w is optional and defaults to 0.
vt 0.500 1 [0]
vt ...
...
# List of vertex normals in (x,y,z) form; normals might not be unit vectors.
vn 0.707 0.000 0.707
vn ...
...
# Parameter space vertices in ( u [,v] [,w] ) form; free form geometry statement ( see below )
vp 0.310000 3.210000 2.100000
vp ...
...
# Polygonal face element (see below)
f 1 2 3
f 3/1 4/2 5/3
f 6/4/1 3/5/3 7/6/5
f 7//1 8//2 9//3
f ...
...

A look at .stl

A look at .ply

Connecting to Graphics / OpenGL

  • What data is important to have in a binary representation?

    • ???

Connecting to Graphics / OpenGL

  • What data is important to have in a binary representation?

    • BIG data

      • vertex data (position, colour, UV, etc.)

      • vertex index data

      • texture data

      • animation data

      • skinning data

Binary data is graphics-appropriate formats

  • Ideally, we’d like the data exactly the same when:

    • in GPU-memory

    • in a file

    • on the wire (network)

optimized for download speed or fast loading at runtime

Transmission Format (glTF)

"" The GL Transmission Format (glTF) is a runtime asset delivery format for GL APIs: WebGL, OpenGL ES, and OpenGL. glTF bridges the gap between 3D content creation tools and modern GL applications by providing an efficient, extensible, interoperable format for the transmission and loading of 3D content. ""

glTF - closer look

  • Vendor and runtime neutral format

  • Can be loaded and rendered with minimal processing

  • Use a JSON scene description (easily parseable), plus binary files for:

    • geometry

    • animations

    • and other rich data

  • Binary data can be loaded directly into GL buffers without additional parsing or other manipulation

  • glTF can faithfully preserve full hierarchical scenes with nodes, meshes, cameras, materials, and animations

  • glTF enables efficient delivery and fast loading

  • source: glTF introduction

glTF Basics

"" glTF assets are JSON files plus supporting external data. Specifically, a glTF asset is represented by:

  • A JSON-formatted file (.gltf) containing a full scene description: node hierarchy, materials, cameras, as well as descriptor information for meshes, shaders, animations, and other constructs

  • Binary files (.bin) containing geometry and animation data, and other buffer-based data

  • Image files (.jpg, .png, etc.) for textures

  • GLSL text files (.glsl) for GLSL shader source code ""