Jump to content

Sample Effect Plugins for Paint.NET 5.0 (with source code)


Recommended Posts

I've created some samples to show how to write effects using the new GPU plugin system in PDN 5.0.

 

Download: PDNv5EffectSamples.2023.01.07.zip

To install, extract the ZIP to your effect plugin folder. Do not move the files outside of their folder.

GitHub repository (source code)

 

Here's what's included. Some of these are genuinely fun, others are strictly for showing how to code certain things:

 

Bandlimited Synthesis -- This was ported from a ShaderToy shader written in GLSL.

image.png

Channel Blur -- This lets you select which channels are affected by a Gaussian Blur effect. This sample is mostly to show how to combine existing Direct2D effects in your own plugin.

image.png

Drop Shadow -- This is mostly just a coding example. The app has a built-in Drop Shadow effect of its own now.

 

Gaussian Bokeh -- This is another example on how to combine two built-in effects: Direct2D's Gaussian Blur, and Paint.NET's Bokeh blur. There's a slider to cross-fade between the two results.

 

Hue Rotate -- This is another example on how to write a simple Direct2D-based GPU plugin. There is both a simple and advanced implementation, the latter illustrating a method for writing a GPU plugin that has improved performance.

 

Night Circuit Shader -- This is a very complicated effect ported from a Shader Toy shader written in GLSL.

image.png

Outlined Text with Shadow -- This is an example of how to use Direct2D and DirectWrite together.

image.png

Polarized Mandelleaves -- This is a really fun one to play with. It combines a ShaderToy shader ported from GLSL and Polar Inversion.

image.png

Rainbow -- A simple tutorial on how to draw a rainbow in Direct2D using a linear gradient brush.

image.png

Random Noise -- Shows how to generate random numbers on the GPU.

 

image.png

Ripple -- An example of how to write a distortion effect using SampleMapRenderer and multisample sub-pixel antialiasing.

image.png

Shadow Around Selection -- An example of how to render outside of the active selection.

image.png

Square Blur -- An example of how to write an effect plugin that uses a custom pixel shader and a transform mapper.

image.png

Wavey Transform -- An example of how to write a distortion effect using SampleMapRenderer and multisample subpixel antialiasing.

image.png

Zone Plate Shader -- An example of how to write an output-only (aka "Render") pixel shader effect. Implementation based on code by Clinton Ingram @saucecontrol. A "zone plate" is often used for testing systems (physical or digital) and image processing algorithms to see how they eliminate, preserve, or introduce aliasing artifacts.

image.png

  • Like 3

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

I'll be updating these over the next few weeks, especially to include comments that better describe what's going on in the code.

 

Feel free to post questions here, or file an issue on the GitHub repository.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

I'm really hoping that more "around selection" plugins could be made, like "outline around selection", or just any outline plugin can be updated to include the "outside selection" function. This will help me with editing pixel art or make it easier to edit photos in some cases.

I'm also thinking that a stamp tool or content aware stamp tool (which is in photoshop already) can be made.
It's just some ideas I thought of, nothing too serious.

Edited by Setnour6
Stamp tool already exists and I forgot about it
  • Like 1
Link to comment
Share on other sites

4 hours ago, Setnour6 said:

I'm really hoping that more "around selection" plugins could be made, like "outline around selection", or just any outline plugin can be updated to include the "outside selection" function. This will help me with editing pixel art or make it easier to edit photos in some cases.


I already include this in my plugin pack.  Download here: https://forums.getpaint.net/BoltBaitPluginPack

 

After install, look at Effects > Selection > Outline Selection...

 

image.png

 

  • Like 1
Link to comment
Share on other sites

  • BoltBait unfeatured this topic
  • 8 months later...

Source code ZIPs do not contain the plugin DLL. That's always been true.

 

You don't need ComputeSharp.D2D1.dll if you're working with the source code. Visual Studio will automatically download it as part of the NuGet package restore process.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

34 minutes ago, Rick Brewster said:

Visual Studio will automatically download it as part of the NuGet package restore process.

I saw the error while looking at the source code in VS 2022. Did I not give it enough time? I know what you mean - but it didn't happen. 

Replace "will" with "should". And yes - I made sure everything was up to date.

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

It's not a matter of time. The NuGet packages will be automatically downloaded as part of the build process. You don't have to do anything for it to happen.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Looks like I am the only one playing with your examples. They are invaluable in getting me up to speed in plugin development. I took a closer look at VS 2022 and found one of the extensions was not up to date. I remember updating VS2022 but not the extensions. I bet you can guess which extension was not up to date. 

 

Having working examples allows me to break everything and put it back together. Just my method. I use Visual Studio Code to look at things, but now with the introduction of AI, I have to be careful in the VSCode app. What is annoying is the intellisense from Microsoft. Something I doubt you use. It will report errors in VS Code and once corrected and brought in VS2022 it creates numerous errors.

 

I believe the intent of these sample effects is to show all the changes in the naming conventions. Looking at the conversation in the Codelab thread showed me it was a work in progress. I do forget I am in a private thread but all this information is too important to keep secret. I was hoping to stay away until all these betas were complete. With your release yesterday, that day has come. Now to just wait for Codelab to catch up.

 

I am confident that one of your cs scripts still reflect an old method that you depreciated. I corrected it but now I'm not sure which one it was. It was related to the Bokeh Blur.

My copy assembled fine and works perfectly alongside yours.

 

The other lesson learned is how 1 DLL file can contain so many effects. I'll have to try that with some of my own builds.

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

3 hours ago, AndrewDavid said:

I believe the intent of these sample effects is to show all the changes in the naming conventions.

It's a lot more than "naming conventions."

 

3 hours ago, AndrewDavid said:

I am confident that one of your cs scripts still reflect an old method that you depreciated.

I just updated it yesterday. You need to fetch/pull the latest commits.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

@Rick Brewster I have the alpha version installed. I Have your repository in VS2022 showing me the locked icons, Why is it now full of errors?

 

New menus in VS2022 and Device manager just kicked in on my machine. I had the wrong Project loaded. I expected your repo would be in my quick access list but no - I have to access it from within VS2022. 

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

VS2022 has a wizard that will create a new project from an existing one. Sooooooo

Yes I ran it against your Plugin and it created a new project for me to play with.

 

It also showed me references to Net 4.0 in the project that required me to select 4.0 from the assembly reference which wasn't there. I selected the next highest version - and it resolved that issue - but I noticed something else. Turns out I didn't have the NuGet app installed. I had the extension, so never really encountered a problem. Your project file makes a refence to it. Installing now to clear that issue. 

 

Man I am learning a lot from your repo. Rather than a donation, come up to Vancouver so I can buy you dinner, :)

 

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

10 hours ago, AndrewDavid said:

It also showed me references to Net 4.0 in the project that required me to select 4.0 from the assembly reference which wasn't there.

 

There should be no references or mentions of .NET 4.0. If that happens then you're doing something wrong or you used the wrong tool. Everything is on .NET 7 right now, and we're about to jump to .NET 8.

 

You can just open up the solution file (.sln) in Visual Studio. You don't need to do any project conversions or wizards. It's good-to-go.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

1 hour ago, Rick Brewster said:

You don't need to do any project conversions or wizards.

@Rick Brewster While your project was open - I updated and installed a few tools that automatically applied suggestion/corrections to the code. I learned not to update accessories while an active file is open. I accepted their remarks and applied them. Most of it was just house cleaning by inteliSense. One of the apps I installed was NuGet and the extension  .Net Upgrade assistant.   

So I know about push and pull. Ok - A chance to learn about GIT. Obviously I can do no harm to your repository because I don't have a key.

I just wanted to see the process to understand it. Can you see I am learning things. Now I understand it.  Even did some old dos commands well.

What I don't understand is after loading the new beta version last night - your project shows an error regarding the D2D1.Assembly - which I'll guess is a newer version then what your project points to. 

Well new update for VS2022 just kicked in.(17.7.5)

Now, You mentioned Net 8. Still in its beta phase I see. I just installed Net 7 last night and that caused my PC to go through an update process when I shut it down. I must say my computer has never acted better. If I ever design a plugin that runs on NET 7 - I'll worry about Net 8 (which I understand won't be released until next year. I would expect eventually I will get a notice of an update to your repo and I can see about cancelling the pending update I created. (I haven't found it yet.) Now to look at the updated software.

 

Comment 2 - Your plugin now fails to load.

Severity    Code    Description    Project    File    Line    Suppression State
Error    NU1301    Failed to retrieve information about 'ComputeSharp.D2D1' from remote source 'https://packagesource/FindPackagesById()?id='ComputeSharp.D2D1'&semVerLevel=2.0.0'.    PdnV5EffectSamples    C:\Users\Andrew\Desktop\MyVS2022Plugins\PaintNet510\PaintExamples\PdnV5EffectSamples.csproj    1    
 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

I will keep the crash log here 

Found my mistake 

 

 

Spoiler

File: C:\Users\Andrew\Documents\paint.net App Files\Effects\AndrewDavid\PdnV5EffectSamples.dll
Effect Name: PaintDotNet.Effects.Samples.Gpu.ZonePlateShaderEffect
Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception
 ---> System.TypeLoadException: Could not load type 'ComputeSharp.D2D1.Interop.D2D1PixelShaderEffect' from assembly 'ComputeSharp.D2D1, Version=2.1.0.0, Culture=neutral, PublicKeyToken=dc35fa229f6881d8'.

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

@Rick Brewster

 

Keeping you updated to what has transpired since last we talked. 

 

The steps I have followed (in case I want to do it again.)
1.     Export a template from the original Solution
InteliSense detects errors - corrects them and exports a clean solution

2.    Open the exported cleaned template - which allows me to create a new solution (Andrew David's Plugins) based on your project
It came out as a linked GIT Solution (All the lock symbols) Now here is the interesting part. Intel identifies errors in the code (I found

that odd seeing as VS created the solution)

3.     Go through each CS script and errors are easily corrected by adding some use statements to maybe 7 CS files. 
All errors were corrected by inteliSense (These were the errors the export process detected?)
I was able to correct them all except this one.

 

AndrewDError.png.f056dcffa62a708b2504101156a3d69a.png

4.    I excluded that script from the solution and "viola" a clean solution (no errors anywhere, clean code and it allows me to build a working plugin)


I also learned that if I update any of the analyzers, it breaks the plugin. (There are updates available) 

I can also understand why you didn't post any .png files.

The solution has been uploaded to my GIT account privately. 
I've added you as a collaborator if you would like to see for yourself.

You may not like the ¨cleaned code , but I think you use a few tricks to get around errors
The part I like is no errors. No tricks


This is one of the first plugin (other than codelab) that uses the new infrastructure. Its best for me to keep on top of things.

 

2 years and I can finally say thank you for all the experience :)

 

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

21 minutes ago, AndrewDavid said:

The solution has been uploaded to my GIT account privately. 

I was just about to ask for this, it will help tremendously

 

I’ll take a look at it hopefully sometime later today

  • Thanks 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...