CesiumGS / cesium-native

Apache License 2.0
445 stars 216 forks source link

Move image loading into a separate library or class #221

Open kring opened 3 years ago

kring commented 3 years ago

Currently, we use CesiumGltf::GltfReader to load jpegs, pngs, etc. That's a little odd.

javagl commented 3 years ago

(Triggered by this (and the source, https://github.com/CesiumGS/cesium-native/pull/208#discussion_r615892972 ) being open in some abandoned Browser Tabs for nearly a month now: )

The solutions for this range from

People who have already looked into KTX2 might give some hints for the second option. KTX2 regularly discussed in the 3dformats calls, but I'm not familiar with it on a technical level. For example, I assume that medium-term, a single, static ImageLoader::loadThat(rawData) will not be sufficient. There will likely be some sort of configuration object like

struct ImageReaderParameters { 
    bool decompressThisAndThat; 
    int compressSoManyComponents;
    bool retainThisAndThatInformation; 
    ...
}

The result may not be a single CesiumImage with uint32_t rgba pixels, but something that can transport other forms of image data, and maybe even some sort of Mipmap levels or metadata or whatnot.

And ... this issue is talking about image loading. Image writing will also be a topic (although with much, much lower priority, of course - at least for cesium-unreal. The tilers folks might want some writeKtx(pixels) function rather sooner than later...),

javagl commented 3 years ago

If this was implemented, it would also fix https://github.com/CesiumGS/cesium-native/issues/150