Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussion] Desired texture/sampler state #38

Open
lexaknyazev opened this issue Dec 23, 2018 · 7 comments
Open

[Discussion] Desired texture/sampler state #38

lexaknyazev opened this issue Dec 23, 2018 · 7 comments

Comments

@lexaknyazev
Copy link
Member

Since KTX2 already has swizzling metadata, it's fair to explore what other runtime properties may need to be stored in the same way (using optional metadata). Keep in mind that API support is not consistent for these and also depends on pixel format used.

  • Border color and width.
  • Wrapping modes.
  • Min / mag filters.
  • LOD min/max/bias.
@MarkCallow
Copy link
Contributor

I have no objection to adding this metadata as which of these modes, etc. are best to use is clearly data dependent.

@MarkCallow
Copy link
Contributor

CTTF TSG telecon 5/20/19. Keep this open for possible future addition. Won't be in first release. Can be added without bumping version as it is just metadata.

@Leadwerks
Copy link

Leadwerks commented Nov 23, 2021

Valve texture files support this information:
https://developer.valvesoftware.com/wiki/Valve_Texture_Format

The reason I am interested in this is because we have a 1:1 relationship in our engine between media and file paths. When the user loads an asset from a file path, it is cached with a weak pointer, and if the same file is loaded again, the original asset is returned. So the idea of having multiple different content with different settings loaded from the same file does not make sense in our usage.

Also, the fact that these properties are defined at creation time in Vulkan makes it more rigid, so it makes sense to define these as part of the texture file itself, for our purposes.

@MarkCallow
Copy link
Contributor

I have no objection to adding a metadata item to provide sampler information. I want to hear opinions from more people before making a decision.

Note that since such metadata doesn't currently exist there will be much software that will ignore it. Also @Leadwerks note that there is nothing stopping you from adding your own metadata. Just don't use KTX or ktx as its prefix.

@Leadwerks
Copy link

Yeah, I can only say what our own usage is. I am curious to hear how other people are handling this. In glTF these properties are stored in the sampler, which to me implies the information is part of the model file, but my described usage has been a lot more practical for us.

Since the wrap and filter properties are optional in glTF, it makes sense that the values stored in the KTX files should be used if they are not present in the glTF sampler.

@lexaknyazev
Copy link
Member Author

the wrap and filter properties are optional in glTF

The wrapping is always defined in glTF. By default, it is repeat when the sampler object or its wrapping parameters are not present. The filtering may be undefined but assets that require something other than all-linear should define their sampler configs. Besides, only supercompressed 2D textures are currently supported in glTF. KTX files on their own may be used in many other contexts.

@lexaknyazev
Copy link
Member Author

The GPU sampler state properties may be grouped like this:

Wrapping

  • up to three independent axes (U/V/W);
  • normalized / unnormalized coordinates;
  • five wrapping options:
    • repeat;
    • mirrored repeat;
    • clamp to edge;
    • mirrored clamp to edge;
    • clamp to border, requires border color:
      • predefined or custom value;
      • may rely on the texture's swizzle config and/or may have border-specific component mapping.

I don't think there's a strong case for standardizing on KTX metadata for these properties because the effective wrapping behavior heavily depends on the asset's texture coordinates that are not a part of KTX.

Filtering

  • minification / magnification:
    • nearest;
    • linear;
    • cubic (optional);
  • mipmap mode:
    • nearest;
    • linear;
  • reduction mode:
    • average (default);
    • minimum;
    • maximum;
  • comparison mode (depth only);
  • LOD bounds: min, max, bias;
  • anisotropy.

These options are usually specific to the texture data so it may be reasonable to store them inside KTX. There are two issues though:

  • some options represent quality / performance choices that apps are supposed to make for themselves;
  • not all combinations should be legal, e.g., enabling aniso with nearest filtering is undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants