filipwasil / fillwave

Multiplatform C++14 graphics engine
https://filipwasildev.bitbucket.io/
MIT License
23 stars 6 forks source link

Texture compression #69

Closed filipwasil closed 6 years ago

filipwasil commented 8 years ago

http://www.xnview.com/en/nconvert/

filipwasil commented 7 years ago

Current class diagram looks like this:

@startuml TextureSystem o-- TextureLoader TextureSystem o-- TMSTexture1D TextureSystem o-- TMSTexture2D TextureSystem o-- TMSTexture2DRendreable TextureSystem o-- TMSTexture2DRendreableDynamic TextureSystem o-- TMSTexture3D TextureSystem o-- TMSTexture3DRenderable TextureSystem o-- TMSTexture3DRenderableDynamic @enduml

http://plantuml.com/plantuml/png/2qcjA2ajIWskB2v9pLN8rzLL2868-EGdfgGMSOLWoli6GmKDNV1A6n6I3ahDIobAJKpAIILQeKjbNc9kPZ9UzSOk1AH1ngKM4RGNMI7KNW00

Now the problem is that TextureLoader should actually be an interface, which will be able derive from ITextureLoader.

@startuml TextureSystem o-- ITextureLoader ITextureLoader <|-- ITextureLoaderSTB ITextureLoader <|-- ITextureLoaderGLI TextureSystem o-- Template_ManagerSmartTextureXXX @enduml

http://plantuml.com/plantuml/png/2qcjA2ajIWskB2v9pLN8rzLLy0o12Fda9wQa5d6XSXLiQZ2K18Su4Q7AtSUJAmJ3if3Kt8ASn9BKUD_4lCHqe5cvYKKbK6KH4H40

The thing is that every model, while being created, uses the Texture system to get the texture, and the output of the loading operation is a "FIle".

@startuml Texture2DFile o-- Texture2DFileConfig Texture2DFile o-- Texture2DFileHeader Texture2DFile o-- Texture2DFileData Texture2DFile o-- eMemoryAllocation Texture3DFile <|-- Texture2DFile Texture3D o-- Texture3DFile Texture2D o-- Texture2DFile @enduml

The diagram shows the relations. Each 2D Texture has a 2D file. Each 3D texture has a 3D File.

http://plantuml.com/plantuml/png/2qcjA2ajIZLoSSlCILN8rzLL244MSSxFIyjCvmh1hyeZDJ4bjOYGAfV4aaGiQb9zKtFpYoeTStBoanDBClFpO6gC8MfiQj0DGYX0jiGOHSx81TC10000

IN GLI implementation GLI, basically returns only handlers to textures. We want to take the construct our texture from gli::texture.

Of course better ideas are welcome. This is just a draft.

filipwasil commented 6 years ago

https://github.com/filipwasil/fillwave/blob/master/src/loaders/textureloader/stb/TextureLoaderTraitsSTB.cpp#L135

Compressed fle size is needed to read.

Also Texture Generator

filipwasil commented 6 years ago

Checking available compresssions:

glGetIntegerv (GL_NUM_COMPRESSED_TEXTURE_FORMATS, localInt)

also put the verification here:

https://github.com/filipwasil/fillwave/blob/master/src/loaders/textureloader/stb/TextureLoaderTraitsSTB.cpp#L135

filipwasil commented 6 years ago

Thread to read about compression matter

filipwasil commented 6 years ago

https://stackoverflow.com/questions/27548932/opengl-best-texture-compression-format-on-desktop-nowadays

analysis for compressions in OpenGL

filipwasil commented 6 years ago

Conclusion:

As default option, keep a set of uncompressed textures and a set of compressed S3TC (DXT1, DXT3, DXT5) or ETC/ETC2 (good enough for RGB w/o transparency).

filipwasil commented 6 years ago

example compression tool for S3TC