KhronosGroup / KTX-Specification

KTX file format source
Other
70 stars 12 forks source link

[Discussion] Desired texture/sampler state #38

Open lexaknyazev opened 5 years ago

lexaknyazev commented 5 years ago

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.

MarkCallow commented 5 years ago

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

MarkCallow commented 5 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

The GPU sampler state properties may be grouped like this:

Wrapping

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

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