DDS image format improvements #101405

Closed
opened 2022-09-27 15:02:27 +02:00 by Aras Pranckevicius · 15 comments

DDS Issues

Currently (Blender 3.3/3.4), .DDS file format support in Blender has a handful of issues:

  • No support for BC6H or BC7 GPU compressed formats (both Eevee and Cycles) (#64753).
  • No support for alpha-only (e.g. A8) format (both Eevee and Cycles).
  • Eevee-only issues:
    • DDS image loading performance "feels like" it's way too slow.
    • Luminance formats (L8, L8A8) produce either black or garbage pixel colors.
    • Two-channel formats often used for normal maps are interpreted as a normal map properly when using DX9 style "ATI2" format, but not when using DX10 style BC5 format.
  • Cycles-only issues (OpenImageIO issues really):
    • No support for BC4/ATI1 and BC5/ATI2 formats (#56248, #60530).
    • Images with "normal map" flag (e.g. using DXT5nm compression) aren't interpreted as normal maps properly.
    • Uncompressed 10-bit format (RGB 10, Alpha 2) produces garbage pixels.
    • No support for DXT5 "RXGB" format that Eevee does support.
  • Some malformed .dds files still produce a non-pink image, often with garbage colors. E.g. if a .dds file contains only the header.

System console output for various DDS issues often lacks context, e.g. often it just says Unable to find a suitable DXT compression with no further details.

Proposed Solution

Eevee/Viewport and Cycles use completely different image loading code paths, so the solutions for them are different:

Eevee uses "ImBuf" code inside Blender itself, which is partially taken from an old nvidia-texture-tools project for DDS handling.

  • Replace NVTT based code with manually written DDS loader, and bcdec.h library (https://github.com/iOrange/bcdec) for DXT/BCn decoding (MIT or Unlicense).
  • While at it, speed it up "at least several times".
  • Add support for BC6 and BC7 formats.
  • Make sure to retain proper handling of malformed files without crashing, and to retain various odd-cases of DDS formats that work today (e.g. "RXGB" format).

Cycles uses OpenImageIO. Currently Blender uses OIIO 2.3.x. Upcoming OIIO 2.4 contains support for BC4..BC7 (#3462) as well as performance improvements (#3463).

  • Have someone update to OIIO 2.4 :)
  • Look into adding missing pieces (normal map interpretation, RXGB support, etc.) and fixes to OIIO itself.

Test Project

Attached a test project that has a scene with 30+ different format DDS files, and screenshots how it renders in both Eevee and Cycles in Blender 3.3.

dds_tests_project.zip render_cycles_33.png render_eevee_33.png

### DDS Issues Currently (Blender 3.3/3.4), .DDS file format support in Blender has a handful of issues: - No support for BC6H or BC7 GPU compressed formats (both Eevee and Cycles) (#64753). - No support for alpha-only (e.g. A8) format (both Eevee and Cycles). - Eevee-only issues: - DDS image loading performance "feels like" it's way too slow. - Luminance formats (L8, L8A8) produce either black or garbage pixel colors. - Two-channel formats often used for normal maps are interpreted as a normal map properly when using DX9 style "ATI2" format, but not when using DX10 style BC5 format. - Cycles-only issues (OpenImageIO issues really): - No support for BC4/ATI1 and BC5/ATI2 formats (#56248, #60530). - Images with "normal map" flag (e.g. using DXT5nm compression) aren't interpreted as normal maps properly. - Uncompressed 10-bit format (RGB 10, Alpha 2) produces garbage pixels. - No support for DXT5 "RXGB" format that Eevee does support. - Some malformed .dds files still produce a non-pink image, often with garbage colors. E.g. if a .dds file contains only the header. # System console output for various DDS issues often lacks context, e.g. often it just says `Unable to find a suitable DXT compression` with no further details. ### Proposed Solution Eevee/Viewport and Cycles use completely different image loading code paths, so the solutions for them are different: **Eevee** uses "ImBuf" code inside Blender itself, which is partially taken from an old nvidia-texture-tools project for DDS handling. - Replace NVTT based code with manually written DDS loader, and `bcdec.h` library (https://github.com/iOrange/bcdec) for DXT/BCn decoding (MIT or Unlicense). - While at it, speed it up "at least several times". - Add support for BC6 and BC7 formats. - Make sure to retain proper handling of malformed files without crashing, and to retain various odd-cases of DDS formats that work today (e.g. "RXGB" format). **Cycles** uses OpenImageIO. Currently Blender uses OIIO 2.3.x. Upcoming OIIO 2.4 contains support for BC4..BC7 ([#3462](https:*github.com/OpenImageIO/oiio/pull/3462)) as well as performance improvements ([#3463](https:*github.com/OpenImageIO/oiio/pull/3463)). - Have someone update to OIIO 2.4 :) - Look into adding missing pieces (normal map interpretation, RXGB support, etc.) and fixes to OIIO itself. ### Test Project Attached a test project that has a scene with 30+ different format DDS files, and screenshots how it renders in both Eevee and Cycles in Blender 3.3. [dds_tests_project.zip](https://archive.blender.org/developer/F13581445/dds_tests_project.zip) ![render_cycles_33.png](https://archive.blender.org/developer/F13581450/render_cycles_33.png) ![render_eevee_33.png](https://archive.blender.org/developer/F13581455/render_eevee_33.png)
Aras Pranckevicius self-assigned this 2022-09-27 15:02:27 +02:00
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @aras_p

Added subscriber: @aras_p
Member

Added subscriber: @EAW

Added subscriber: @EAW
Member

Adding the BF Blender tag, as tracking gets messed up without it. :-)

Adding the `BF Blender` tag, as tracking gets messed up without it. :-)

This issue was referenced by cb2fb570f1

This issue was referenced by cb2fb570f1303e2262de4ce97f50bd87f8ae27b4

This issue was referenced by 6dd2e193e1

This issue was referenced by 6dd2e193e16fcae720b40d18e29c9e395b014833

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

Added subscriber: @mont29

Added subscriber: @mont29

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'

Wrong task number in commit, sorry...

Wrong task number in commit, sorry...
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Author
Member

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'
Author
Member

Wrongly closed due to mistyped task number in a commit, reopening.

Wrongly closed due to mistyped task number in a commit, reopening.

Added subscriber: @codeloadgame

Added subscriber: @codeloadgame
Philipp Oeser removed the
Interest
Core
label 2023-02-09 14:42:47 +01:00
Author
Member

This was addressed by @deadpin with switch to OpenImageIO for DDS loading, in Blender 3.6 and up. Now all of EEVEE/Cycles/Workbench interpret various DDS formats consistently, and has wider support compared to before. The test above looks like this:

Clipboard01.png

This was addressed by @deadpin with switch to OpenImageIO for DDS loading, in Blender 3.6 and up. Now all of EEVEE/Cycles/Workbench interpret various DDS formats consistently, and has wider support compared to before. The test above looks like this: ![Clipboard01.png](/attachments/3c09030e-b865-41e8-9c90-67af4560e322)
Aras Pranckevicius added
Status
Resolved
and removed
Status
Confirmed
labels 2023-08-17 10:37:22 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#101405
No description provided.