/IMT2531-Assignment-2

An OpenGL Model Viewer, Scene builder & shader playground, all, neatly accessible through into hotloadable files

Primary LanguageC

Curiosity task - 3D object viewer

We are not doing Pacman. Instead we are doing a Curiousity Task. We are focusing heavily on Architecture/Framework development for an OpenGL graphics engine.

The goal of our engine is to provide a 3D viewer with loading of resource files during run-time. The 3D-viewer will support 5 different files which may be loaded, edited, re-loaded during run-time by the user:

  • Texture files (e.g. brickwall.jpg)
  • Shader files (e.g. base.glsl)
  • Material files (e.g. brickwall.yml - custom format)
  • Model files (e.g. cube.yml - custom format)
  • Scene files (e.g. playground.yml - custom format)

We are focusing on beiing as generic as possible when supporting these files, to empower the user. We are trying to make it possible for non-programmers to enjoy the 3D-viewer, although the text-only input system might scare some people awy.

Our target user is an educator or a student who wants to learn about 3D graphics datastructures.

To make our custom Model format usable, we want to write an exporter for Blender for exporting high-poly models to our custom format.

We want to model an entire scene graph.

Roadmap

Minimum Requirements assignment 2

  • Textured walls floors
  • Menu for pause, resume and exit. (pull from assignment 1?)
  • Move objects/camera using keyboard or mouse.
  • Load at least 1 model from a model file. (custom format)
  • Basic lighting model

Optional requirement assignment 2

  • Advanced lighting/reflection materials
  • Change perspective
  • Use of multiple advanced mesh.
  • Write own object loader
  • Make Camera movable
  • Multiple scenes

Own requirements Engine

  • Render a cube.
  • Add texture to the cube
  • Make the cube spin.
  • Add material to the cube.
  • Use 2 materials on different parts of the cube.
  • Move the cube using mouse input.
  • Add floor.
  • Texturize the floor.
  • Toggle camera spin around the cube.
  • Toggle ambient light. Scale ambient light up down.
  • Add a directional light.
  • Implement Phong lighting model using cube vertex normals.
  • Render cube with specular map.
  • Add one of the simple shadow models.
  • Swap between 2 different shaders at run-time.
  • Swap between 2 different cube materials at run-time.
  • Render 2 cubes side by side with different materials.
  • Repeat the above with model of the teapot.

Extra File loader

  • Load a Shader. (vertex & geometry & fragment)
  • Load a Texture. (diffuse & specular)
  • Load a Vertexbuffer
  • Load a Mesh with indicies to that vertexbuffer.
  • Load a Material.
  • Load a Transform.
  • Load an Entity { Mesh, Material, Transform }
  • Render that loaded Entity.
  • Update render of loaded Entity on file change

Reflection

Things we would have done differently

Decouple vertex-mesh from material and shader

Currently in our model-files we are specifying which shader and material are to be used in the rendering of our models. This has created a strong coupling of a mesh to the shader and material. Stronger than we would like.

I will mention two big problems with this:

  1. It is not convenient to go inside the model file, in between all the vertices and triangle to edit the materials and shaders attached to that model.
  2. For every new model with the same vertices, but with different materials, we have to duplicate all the vertices and indicies. This does not make sense for a big model.
vertices: 1560
v:  1.138500  0.598000 -0.100000    0.707 -0.707  0.000    0.000  0.000   255 255 255 255
v:  1.138500  0.598000  0.100000    0.707 -0.707  0.000    0.000  0.000   255 255 255 255
v:  1.138500  0.384000 -0.100000    0.707  0.707  0.000    0.000  0.000   255 255 255 255
v:  1.138500  0.384000  0.100000    0.707  0.707  0.000    0.000  0.000   255 255 255 255
.... 1000's more vertices

meshes: 1
mesh: blendermesh
material: _default   # < -- Awkward to have to go here to edit material here in between 1000's of lines of data.
shader: _default
triangles: 1166
t: 64 92 65
t: 92 66 65
t: 92 0 66
t: 92 1 0
t: 92 2 1
t: 92 3 2
t: 92 4 3
t: 92 5 4
.... 1000's more triangles

The entity specifies that it wants to use a model. This implicitly also select which materials and shaders are to be used. An intermediate format like a prefab model would have been nice.

A prefab would then stich everything together. An entity would be an instance of a prefab with a transform in a scene.

prefabs: 2

prefab: cube
meshes: 4

    mesh: rightarm
    shader: basic-color
    material: red

    mesh: leftarm
    shader: basic-color
    material: blue

    mesh: head
    shader: mat-texture
    material: _default

    mesh: foot
    shader: mat-texture
    material: brick


prefab: Suzanne
meshes: 1

    mesh: suzanne-head
    shader: subsurface-scatter
    material: glass