Skip to content

Conversation

karnkaul
Copy link
Member

@karnkaul karnkaul commented Oct 22, 2022

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

  • Replace on-demand texture creation with material-based ColourSpace decisions.
  • Remove TextureProvider.
  • Add check for Id<Camera> if attached to Node being added.
  • Rename TestMaterial to LitMaterial.

Close #16

- Replace on-demand texture creation with material-based `ColourSpace` decisions.
- Remove `TextureProvider`.
- Add check for `Id<Camera>` if attached to `Node` being added.
- Rename `TestMaterial` to `LitMaterial`.
class Texture;
class Pipeline;

struct TextureProvider {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore

};

class TestMaterial : public Material {
class LitMaterial : public Material {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests have been successful, time to formalize this material

@karnkaul karnkaul force-pushed the karnage/gltf-samplers branch from 247958c to eb6c45a Compare October 22, 2022 02:27
@karnkaul karnkaul marked this pull request as ready for review October 22, 2022 02:33
@karnkaul karnkaul requested a review from Rinzii October 22, 2022 03:14
Copy link
Member

@Rinzii Rinzii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides a typo I found and fixed I can’t see really any issues with my glance over. I’d double check everything but I’m gonna approve the pr.

@karnkaul karnkaul merged commit a13e95f into main Oct 22, 2022
@karnkaul karnkaul deleted the karnage/gltf-samplers branch October 22, 2022 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix texture creation: avoid during rendering Figure out why UVs are borked when loading Damaged Helmet
2 participants