Code Monkey home page Code Monkey logo

pdn-ddsfiletype-plus's Introduction

pdn-ddsfiletype-plus

A Paint.NET filetype plugin that adds support for some of the DDS formats introduced in DirectX 10 and later.

This plugin is bundled with Paint.NET 4.2.2 and later.

If you need the features from a newer version you can still install the plugin into the FileTypes folder.
The installed plugin will override the bundled version if it has higher version number.

The plugin supports loading and saving DDS files that contain single images and cube maps, texture arrays and volume maps are not supported.
If the file contains mipmaps only the main image will be loaded, the plugin has the option to generate mipmaps when saving.

Cube maps are loaded and saved using a 'crossed image' layout, see Creating and Editing Cube Maps for more information.
An overview of the save UI options is provided on this page.

Supported DDS Formats

The plugin can read most DDS formats, but only the following formats are supported when saving:

Compressed

  • BC1 (Linear and sRGB)
  • BC2 (Linear and sRGB)
  • BC3 (Linear and sRGB)
  • BC4 (Unsigned)
  • BC5 (Signed and Unsigned)
  • BC6H (Unsigned 16-bit Float)
  • BC7 (Linear and sRGB)

Uncompressed

  • R8G8B8A8 (Linear and sRGB)
  • R8 (Unsigned)
  • R8G8 (Signed and Unsigned)
  • R32 (Float)
  • B8G8R8A8 (Linear and sRGB)
  • B8G8R8X8 (Linear and sRGB)
  • B4G4R4A4
  • B5G5R5A1
  • B5G6R5

Legacy DirectX 9

  • R8G8B8X8
  • B8G8R8
  • ATI1 (BC4 Unsigned)
  • ATI2 (BC5 Unsigned)
  • RXGB (A BC3/DXT5 variant used for normal maps)

Installing the plugin

  1. Close Paint.NET.
  2. Place DdsFileTypePlus.dll, DdsFileTypePlusIO_ARM64.dll and DdsFileTypePlusIO_x64.dll in the Paint.NET FileTypes folder which is usually located in one the following locations depending on the Paint.NET version you have installed.
Paint.NET Version FileTypes Folder Location
Classic C:\Program Files\Paint.NET\FileTypes
Microsoft Store Documents\paint.net App Files\FileTypes
Portable <Paint.NET folder>\FileTypes
  1. Restart Paint.NET.

License

This project is licensed under the terms of the MIT License.
See License.txt for more information.


Source code

Prerequsites

  • Visual Studio 2022
  • Paint.NET 5.0 or later

Building the plugin

  • Open the solution
  • Change the PaintDotNet references in the DDSFileTypePlus project to match your Paint.NET install location
  • Update the post build events to copy the build output to the Paint.NET FileTypes folder
  • Build the solution

3rd Party Code

This project utilizes the following code (located under 3rdParty folder)

pdn-ddsfiletype-plus's People

Contributors

0xc0000054 avatar bbowyersmyth avatar rickbrew avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdn-ddsfiletype-plus's Issues

Error when opening dds file

I've got error when opening dds file, exception message below:

Application version: paint.net 4.2.10

System.ArgumentException: Value does not fall within the expected range.
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at DdsFileTypePlus.DdsNative.Load(Stream stream)
   at DdsFileTypePlus.DdsFile.Load(Stream input)
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522
   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Base\Functional\Func.cs:line 158

This is the dds file (zipped):
beam_lo.zip

Regards,

Martinus

Low quality DXT compression?

I am using Paint.NET to edit and save DDS textures. I have noticed that Paint.NET with this plugin saves textures in a worse quality than other tools. For example, on a very old X-Ray SDK (S.T.A.L.K.E.R.), texture quality is better.

Paint.NET DXT1

PaintNET_DXT1

X-Ray SDK DXT1

XRaySDK_DXT1

Sorry for my English (I write through a translator).

Distortion after saving image having transparent pixels in BC1 format

I tried to save PNG image having transparent pixels into different BC formats and found that the image in BC1 format becomes sharper (see test_bc1a.dds).

the original image

Compare the following DDS files between themselves and the original image.

dds.zip

BC2, BC3 and BC7 formats support alpha channel so the original image is converted fine.
But even images in BC4 and BC5 formats that don't support transparency are still similar to the original one.
Also after adding to the original image opaque layer in Paint.NET I saved it in BC1 format to show how I expected it supposed to look like.

Update README

Can remove DDS"2" stuff, as well as talk about how the plugin is now bundled with the app, and how you can still install it and have it override the built-in bundled version of the plugin as long as it's a newer version.

DDS files with a header size of 24

Hello! I have a similar problem with textures from the game STALKER SHoC.

Exception:

System.FormatException: The DDS file is invalid.
   at DdsFileTypePlus.DdsNative.Load(Stream stream, DDSLoadInfo& info) in D:\Dev_projects\DdsFileTypePlus\src\DdsNative.cs:line 57
   at DdsFileTypePlus.DdsReader.Load(Stream input, IServiceProvider services) in D:\Dev_projects\DdsFileTypePlus\src\DdsReader.cs:line 30
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 491
   at PaintDotNet.Data.FileTypeProxy.OnLoad(Stream input) in D:\src\pdn\src\PaintDotNet\Data\FileTypeProxy.cs:line 60
   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 491
   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Fundamentals\Functional\Func.cs:line 60

Diagnostics:

Application                                          paint.net версия 5.0.10 (Stable 5.10.8674.32967)
Build Date                                           1 октября 2023 г.
Install type                                         Classic

These textures are displayed in the game and opened in Photoshop:
textures.zip

Originally posted by @xrSimpodin in #14 (comment)

Add cancellation support

FileTypeOptions.SupportsCancellation, which adds the possibility of OperationCanceledExceptions being thrown from both the Stream and ProgressEventHandler, would make the user experience better. Happy to implement this myself if you'd like.

Remove .dds2 extension

.dds2 is no longer necessary. So, maybe remove it :) The app will still allow .dds2 if the user has installed the plugin, but only if the user's plugin version is newer than the bundled plugin's version. I can change that policy if needed, but since we'd both like to get rid of .dds2 this is what I've done for now.

BC7 encoding with WARP can freeze the Paint.NET UI

When encoding larger images with the WARP DirectCompute device the Paint.NET UI stops responding when the progress reaches a certain point.
WARP batches its rendering calls, and after it starts rendering the SaveConfigDialog will freeze if you try to interact with it.

Edit: The UI freeze occurs regardless of whether D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS is set, so I am not sure what could be causing it.

I observed the SaveConfigDialog being marked as not responding in task manager when using a 4096x4096 pixel blank canvas.
On a 1024x1024 pixel blank canvas the SaveConfigDialog does not fully paint until the image has been compressed, it is not blocked long enough on my system to show up as not responding in task manager.

Screenshots with a blank 4096x4096 pixel canvas

UI not responding

PDN task manager

Paint.NET diagnostics:

Application	paint.net 4.2.13 (Final 4.213.7521.38873)
Build Date	Tuesday, August 4, 2020
Install type	Classic
	
Hardware accelerated rendering (GPU)	False
Animations	True
DPI	96 (1.00x scale)
Language	en-US
	
OS	Windows 10 Pro x64 (10.0.19041.0) (0x30)
.NET Runtime	4.0.30319.42000
Physical Memory	32,709 MB
	
CPU	Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
    Speed	~3998 MHz
    Cores / Threads	4 / 8
    Features	SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2
	
Video Card	NVIDIA GeForce RTX 2070 SUPER
    Dedicated Video RAM	8,011 MB
    Dedicated System RAM	0 MB
    Shared System RAM	16,354 MB
    Vendor ID	0x10DE
    Device ID	0x1E84
    Subsystem ID	0x31733842
    Revision	161
    LUID	0x00009E4C
    Flags	AcgCompatible, SupportMonitoredFences, KeyedMutexConformance
    Graphics Preemption	PixelBoundary
    Compute Preemption	DispatchBoundary
    Outputs	2
    Feature Level	Direct3D_12_1
    DXGI Formats	A8_UNorm, B8G8R8A8_UNorm, R16G16B16A16_UNorm, R16G16B16A16_Float, R32G32B32A32_Float
    Buffer Precision	UNorm8bpc, UNorm8bpcSrgb, UNorm16bpc, Float16bpc, Float32bpc
	
Video Card	Microsoft Basic Render Driver
    Dedicated Video RAM	0 MB
    Dedicated System RAM	0 MB
    Shared System RAM	16,354 MB
    Vendor ID	0x1414
    Device ID	0x008C
    Subsystem ID	0x00000000
    Revision	0
    LUID	0x0000AAB7
    Flags	Software, AcgCompatible, SupportMonitoredFences, KeyedMutexConformance
    Graphics Preemption	InstructionBoundary
    Compute Preemption	InstructionBoundary
    Outputs	0
    Feature Level	Direct3D_12_1
    DXGI Formats	A8_UNorm, B8G8R8A8_UNorm, R16G16B16A16_UNorm, R16G16B16A16_Float, R32G32B32A32_Float
    Buffer Precision	UNorm8bpc, UNorm8bpcSrgb, UNorm16bpc, Float16bpc, Float32bpc

Unfortunately, the DirectXTex CPU encoder for BC7 is extremely slow so it is not a viable alternative when compressing large images.

cc @rickbrew

Paint.Net DDS2 naming files .dds2 - Plus no Linear fine option

Couple of issues found ...

  1. When saving one of the new format DDS .. Say BC7

The file is given a filename like name.dds2

Which is sort of ok, if you rename it to .dds then the target game will recognise it for the type of dds it is anyway - Would just be better if we did not have to rename it and it used the .dds extension as normal.

Note Intel Texture Works plugin for Adobe Photoshop does not have this problem, a BC7 dds file with the normal .dds file extension loads just fine into Adobe Photoshop, just like they do with a game engine that supports them (Skyrim Special Edition / Fallout 4).

Also, when loading the same texture back into Paint.Net, if the file is now named .dds, PDN will try to load it but fails to recognise the file, even though it was made with PDN - Solution = rename it name.dds2

Then PDN will recognise and load it correctly O_o, bizarre state of affairs.

Can you fix this behaviour please.


  1. In accordance with Intel Texture Works plugin save dialogue we are supposed to be able to save a BC7 as Linear Fine (second BC7 option in the linked screenshot)

But in the save dialogue for dds2 implemented in PDN there is no such option that seems to stick to the same naming convention

Which of your options equates to ..

BC7 8bpp Fine (Linear, DX11+)

And if you do actually support the same option, could it be made to read as BC7 Fine Linear in accordance with the Intel Texture Works dialogue screenshot, so that we are all singing off the same hymn sheet and know for certain the format saved is the format desired.

Add link to plugin page in the SaveConfigWidget

I think it'd be useful for people to know where the DDS plugin comes from and who the author is, and that they can install a newer version if they need to (probably need to add instructions to the plugin's forum post?).

You can add a clickable link by using a UriProperty in the PropertyCollection.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.