Resources for writing a glTF viewer


I am a intern at a company and I have worked through the learnopengl tutorials in my free time. I have been tasked with creating a glTF viewer and have 2 months to do so. Can anyone point me in the correct direction on where to start? I have been going through the reference viewer but I am finding it difficult to tell what its doing as it jumps through a bunch of functions and is mostly undocumented. I already have the file to class converter complete but am struggling to move forward and actually render it on the screen.

Worth a scan, if you haven’t already:

which language are you using? just asking, because wikipedia says that glTF file format is basically JSON, and there is a python module which can read a JSON file and convert it to a dictionairy. so parsing the file would be just 4 lines of code. of course you would still have to build up a 3d model structure from that dictionairy, containing nodes and trias etc.

Regardless of language, I don’t think the parsing of the actual JSON is the hard part of this process. It’s more a matter of interpreting its meaning, reading the binary data streams that represent meshes and images, writing all of the shaders needed to properly build a glTF material, and building the buffer objects/textures/etc needed to actually render the scene.

I’m using C# but I have the gltf file to C# classes already done my main issue is the rendering and shaders as I don’t have much experience in that.

Yeah this is exactly where I am stuck. I keep trying to figure out what the reference viewer does but manually going through the code is quite long and even with my notes its hard to keep it all in my head.

I guess my question is why you’re looking at the reference viewer at this point. Your task is to write your own viewer. You should instead be starting from your knowledge of your rendering API of choice and the glTF specification that explains what the various glTF structures do.

Start from a point where you can render a fairly arbitrary model with textures, shaders, lighting, and such, with a mobile camera. Then evolve that from there: using the glTF cameras, importing glTF meshes and textures, building shaders that can render glTF materials, etc.

Trying to learn from just reading a blob of source code is pretty much the wrong way to go. Even if you’re going to look at their code as a template, you need a firm understanding of what glTF is doing first.

1 Like

I will get on this! Thanks for the help!

it may not be hard to write a function that parses a JSON file, but that’s not the question. if you use a library, it is not necessary to write something new, that’s the point. if you program in python and use the json module, you have an easy to use and working solution. even though a JSON parser doesn’t seem to be hard to implement, if you make your own one, it will be less stable than the json module.

Every language has JSON parsers out there these days. All of them. They may not be built in, but if you need to parse JSON, it will be maybe 5-15 minutes of time before you’re parsing JSON. Yes, even in C++; RapidJSON doesn’t take any significant time to set up.

Python’s JSON module is thus not a significant leap ahead in terms of getting a glTF viewer up and running.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.