Skip to content

Add support for importing R8 and R8G8 DDS textures#116307

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
Quantx:dds_r8_rg8
Feb 19, 2026
Merged

Add support for importing R8 and R8G8 DDS textures#116307
Repiteo merged 1 commit into
godotengine:masterfrom
Quantx:dds_r8_rg8

Conversation

@Quantx

@Quantx Quantx commented Feb 15, 2026

Copy link
Copy Markdown

Closes godotengine/godot-proposals#14231 by adding support for importing R8 and R8G8 DDS textures. I've implemented the conservative approach outlined in the proposal so when a non-FourCC DDS texture is imported it must either be in R8 or R8G8 (G8B8 or B8R8 will not work).

I've tested this by importing both non-FourCC style DDS textures (RGB Bits), and by importing DX10 style DDS headers which use DXGI Enums.

Let me know your thoughts on whether the conservative or greedy approach outline in the proposal should be used here for non-FourCC textures.

@Quantx Quantx requested a review from a team as a code owner February 15, 2026 07:44
@fire

fire commented Feb 15, 2026

Copy link
Copy Markdown
Member

@BlueCube3310 If you have time, can you take a look?

@BlueCube3310

Copy link
Copy Markdown
Contributor

I've looked around at other DDS loaders, and it looks like R8 and RG8 are both nonstandard formats. For instance, GIMP and Paint.net (DirectXTex) read an R8 file as L8, but both will fail when given an RG8 file. On the other hand, NVIDIA Texture Tools can properly read both files.
Since when it comes to compatibility between loaders/writers the DDS file format is already a huge mess, I think this should be fine to add to the engine.
I'm not certain about the _UINT DXGI formats though, since their purpose is to specifically map to integer-based Image formats (i.e. DXGI_FORMAT_R16_UINT to FORMAT_R16I), rather than the 'standard' UNORM formats.

@Quantx

Quantx commented Feb 18, 2026

Copy link
Copy Markdown
Author

The _UINT was actually a mistake on my part. You're correct that they should be _UNORM but this raises a few conflicts with the existing importer.

We should probably make R8_UNORM map to FORMAT_R8 and A8_UNORM map to FORMAT_L8 instead of them both mapping to FORMAT_L8:

case DXGI_R8_UNORM:
case DXGI_A8_UNORM: {
	return DDS_LUMINANCE;
}

It also looks like R8G8_UNORM is already mapped to FORMAT_LA8 and there aren't any good DXGI alternatives for it. I'd argue that mapping R8G8_UNORM to FORMAT_RG8 makes more sense and is probably the expected behavior, but I don't want to remove support for FORMAT_LA8.

case DXGI_R8G8_UNORM: {
	return DDS_LUMINANCE_ALPHA;
}

If you have any suggestions for how to accommodate both FORMAT_RG8 and FORMAT_LA8 let me know. Maybe R8G8_TYPELESS?

@BlueCube3310

Copy link
Copy Markdown
Contributor

I think it's fine to map the DXGI R8/R8G8 to FORMAT_R8/FORMAT_RG8, most writers make use of the 'legacy' dds header for simple uncompressed formats anyway, so compatibility wouldn't be broken.

@Quantx

Quantx commented Feb 18, 2026

Copy link
Copy Markdown
Author

I've mapped DXGI_R8_UNORM / DXGI_R8G8_UNORM to FORMAT_R8 / FORMAT_RG8 and dropped DXGI support for FORMAT_LA8.

@BlueCube3310 BlueCube3310 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Repiteo Repiteo modified the milestones: 4.x, 4.7 Feb 18, 2026
@Repiteo

Repiteo commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Could you squash your commits? See our pull request guidelines for more information

@Quantx

Quantx commented Feb 19, 2026

Copy link
Copy Markdown
Author

Squashed

@Repiteo

Repiteo commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Thanks! Congratulations on your first merged contribution! 🎉

(PR is merged, GitHub is being slow to update)

@Repiteo Repiteo merged commit c67a8a1 into godotengine:master Feb 19, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment