cpp-gamedev / facade

Native 3D GLTF scene viewer and editor (WIP)
MIT License
5 stars 0 forks source link

Incorporate samplers from GLTF data into textures #28

Closed karnkaul closed 2 years ago

karnkaul commented 2 years ago

Context

This PR addresses two broad points:

  1. Using samplers created from GLTF data for textures.
  2. Replacing the ad-hoc on demand texture creation approach with one where all textures are created when the scene is parsed: this improves rendering stability and enables async loading of textures.

Bonus!

It appears that the changes here also close #12!

Screenshot_20221021_201145

Background

Colour spaces are a complicated rabbit hole, for this PR just being aware that the same image data can be interpreted in two different ways by textures in Vulkan (sRGB vs linear) is sufficient.

Textures were being created on demand because there's no direct way to know whether one should be in sRGB or linear format: this decision was deferred all the way to a Material requesting a texture of the corresponding format at render time. This PR uses the GLTF material spec to encode the desired colour space of each texture in the returned GLTF scene data, which is then used by Scene to create corresponding textures right after parsing that data.

Changes

Close #16