GLTF Support and Material Editing

GLTF Material Editing

Recently, I’ve spent some time improving the material system. The main motivation for this was to get support for Physical Based Rendering and importing files in the GLTF format. Here are the first results:

GLTF File Format

This is quite an interesting format. Although the feature set is rather limited compared to some high-end CAD formats, it is a nice refreshing take on 3D geometry storage. GLTF splits assets into a description part (stored as JSON) and binary buffers containing the actual data (e.g. vertex positions, image pixels). The latter are designed in a way that an application can directly upload them to the GPU without parsing and use the accessors in the JSON file to figure out what format and stride the different vertex attributes have.

There are various forms of storage: dense and sparse buffers, embedded binary buffers, binary GLTF files, but all in all implementation is rather straight forward.

Material Channels

I’ve reworked the material definitions to use generic channels. For example, a Phong material now has a diffuse channel and that channel supplies a color with optional texture. Since all properties of a material are now channels and one can iterate them, it is easy to write generative user interfaces to edit material properties. One example of this can be seen in the screenshot at the top of this post. The whole panel on the right is generated dynamically based on the type of material that is selected.

While there is already a definition for PBR materials and the UI would automatically handle them correctly, I haven’t extended the shader generator yet. So in the screenshot above, I’ve converted the PBR-material to a Phong-based material during import. For now, I’ll continue completing the UI for material editing and assigning of materials before tackling the integration of PBR rendering.

What is nice about having the UI is that it gives a glimpse of how much work has been done already under the covers:

  • Multiple materials per mesh are possible, a material can be assign per face
  • Vertical flipping of textures in shader
  • Channel masking: it is possible to use only a particular color channel (e.g. red for specularity)
  • Vertex color support
  • Reflectivity and opacity

Right now I’m working on drag & drop to assign materials from the material library to the objects in the scene as well as high-level operations such as “select by material”. Should be fun!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>