DDS format BC5 auto-generates Blue channel #111325

Closed
opened 2023-08-20 18:00:50 +02:00 by Lukas-deaton · 2 comments

System Information
Operating system: Windows 10
Graphics card: Nvidia GTX 2080 SUPER

Blender Version
Broken: 3.6.2
Worked: N/A

Short description of error

When importing a DDS texture of format BC5 (only contains Red and Green channels), the Blue channel is auto-generated. From my non-exhaustive testing, no other DDS format behaves like this.

Exact steps for others to reproduce the error

  1. Create a new Blender project
  2. Import a BC5 DDS texture (see attached)
  3. View the texture in the image editor
  4. Observe the Blue channel isn't empty

I assume this is because normal maps exclude the blue channel to save memory, instead computing it at run-time. Since the BC5 format only contains Red and Green, Blender seems to think this is exclusively used for normal maps and generates Blue. Since BC5 can be used for textures besides normal maps, and Blender doesn't do this for normal maps in other formats (not BC5 DDS), this is an odd and confusing "feature".

I've uploaded an example BC5 texture created with texconv, a tool from Microsoft (creators of the DDS format). I've also uploaded a BC4 texture, which only contains Red; it does not auto-generate any data. BC1 contains RGB channels, and again does not auto-generate anything.

**System Information** Operating system: Windows 10 Graphics card: Nvidia GTX 2080 SUPER **Blender Version** Broken: 3.6.2 Worked: N/A **Short description of error** When importing a DDS texture of format BC5 (only contains Red and Green channels), the Blue channel is auto-generated. From my non-exhaustive testing, no other DDS format behaves like this. **Exact steps for others to reproduce the error** 1. Create a new Blender project 2. Import a BC5 DDS texture (see attached) 3. View the texture in the image editor 4. Observe the Blue channel isn't empty I assume this is because normal maps [exclude the blue channel to save memory](https://polycount.com/discussion/comment/637818#Comment_637818), instead computing it at run-time. Since the BC5 format only contains Red and Green, Blender seems to think this is exclusively used for normal maps and generates Blue. Since BC5 can be used for textures besides normal maps, and Blender doesn't do this for normal maps in other formats (not BC5 DDS), this is an odd and confusing "feature". I've uploaded an example BC5 texture created with [texconv](https://github.com/Microsoft/DirectXTex/wiki/Texconv), a tool from Microsoft (creators of the DDS format). I've also uploaded a BC4 texture, which only contains Red; it _does not_ auto-generate any data. BC1 contains RGB channels, and again _does not_ auto-generate anything.
Lukas-deaton added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2023-08-20 18:00:51 +02:00

This behavior is currently by-design. Additionally, 2-channel formats are not well supported in general (known issue) unless you manually separate/combine the RG channels yourself. They can give different results between Eevee/Cycles/OSL.

The problem with BC5 in particular is that historically they've been frequently used as normal maps which assumed the creation of the blue channel. However, there's nothing "official" in the file header declaring them as normal maps so software cannot reliably auto-detect this case. Nvidia tools set a special flag, but other tools do not, and this lead to other bugs we were forced to fix like #109442.

This sometime comes up over on the DirectXTex github as well:
https://github.com/microsoft/DirectXTex/issues/125
https://github.com/microsoft/DirectXTex/issues/214

Since the relative complexity of having the user recreate the blue channel vs. having them separate out the 2 channels themselves, we chose to maintain the creation of the blue channel by default.

Providing an option for the user to select during DDS load is enticing but is also problematic. The imaging library we use to load DDS files only offers very course grained support for enabling/disabling this behavior, not in a per-Image way that's reliable. Even if that improved, rendering systems like OSL and Hydra have no way to consume such metadata as they control image loading themselves. It would also be lost on import/export since formats like FBX or USD don't have any provisions to tag images with this metadata either. So even if we provide an option at load time, surprising things might happen if the data is exported out of Blender.

The recommendation currently is to extract the RG channels directly in the Material or Geometry Nodes graphs when using such images to eliminate ambiguity.

This behavior is currently by-design. Additionally, 2-channel formats are not well supported in general (known issue) unless you manually separate/combine the RG channels yourself. They can give different results between Eevee/Cycles/OSL. The problem with BC5 in particular is that historically they've been frequently used as normal maps which assumed the creation of the blue channel. However, there's nothing "official" in the file header declaring them as normal maps so software cannot reliably auto-detect this case. Nvidia tools set a special flag, but other tools do not, and this lead to other bugs we were forced to fix like #109442. This sometime comes up over on the DirectXTex github as well: https://github.com/microsoft/DirectXTex/issues/125 https://github.com/microsoft/DirectXTex/issues/214 Since the relative complexity of having the user recreate the blue channel vs. having them separate out the 2 channels themselves, we chose to maintain the creation of the blue channel by default. Providing an option for the user to select during DDS load is enticing but is also problematic. The imaging library we use to load DDS files only offers very course grained support for enabling/disabling this behavior, not in a per-Image way that's reliable. Even if that improved, rendering systems like OSL and Hydra have no way to consume such metadata as they control image loading themselves. It would also be lost on import/export since formats like FBX or USD don't have any provisions to tag images with this metadata either. So even if we provide an option at load time, surprising things might happen if the data is exported out of Blender. The recommendation currently is to extract the RG channels directly in the Material or Geometry Nodes graphs when using such images to eliminate ambiguity.

Will close as this is expected behavior right now.

Will close as this is expected behavior right now.
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-09-06 20:12:49 +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
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
No Assignees
2 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#111325
No description provided.