Rick Brewster Posted November 22, 2022 Share Posted November 22, 2022 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. 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. 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. Outlined Text with Shadow -- This is an example of how to use Direct2D and DirectWrite together. Polarized Mandelleaves -- This is a really fun one to play with. It combines a ShaderToy shader ported from GLSL and Polar Inversion. Rainbow -- A simple tutorial on how to draw a rainbow in Direct2D using a linear gradient brush. Random Noise -- Shows how to generate random numbers on the GPU. Ripple -- An example of how to write a distortion effect using SampleMapRenderer and multisample sub-pixel antialiasing. Shadow Around Selection -- An example of how to render outside of the active selection. Square Blur -- An example of how to write an effect plugin that uses a custom pixel shader and a transform mapper. Wavey Transform -- An example of how to write a distortion effect using SampleMapRenderer and multisample subpixel antialiasing. 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. 3 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted November 22, 2022 Author Share Posted November 22, 2022 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. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted January 8, 2023 Author Share Posted January 8, 2023 Updated with a new build that works on the new Paint.NET 5.0 beta (build 8407) 1 2 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Setnour6 Posted January 11, 2023 Share Posted January 11, 2023 (edited) 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 January 13, 2023 by Setnour6 Stamp tool already exists and I forgot about it 1 Quote Link to comment Share on other sites More sharing options...
BoltBait Posted January 11, 2023 Share Posted January 11, 2023 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... 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 2, 2023 Share Posted October 2, 2023 @Rick Brewster Does this need to updated for the latest release? I am getting a error regarding the Package ComputeSharp.D2D1(2.0.3) Lesson learned. Source code ZIP did not contain the files. Your download of the plugin did which I copied over to the source code to resolve my issue. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted October 2, 2023 Author Share Posted October 2, 2023 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. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 2, 2023 Share Posted October 2, 2023 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. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted October 2, 2023 Author Share Posted October 2, 2023 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. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 3, 2023 Share Posted October 3, 2023 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. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted October 3, 2023 Author Share Posted October 3, 2023 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. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 9, 2023 Share Posted October 9, 2023 @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. Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 10, 2023 Share Posted October 10, 2023 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, Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted October 10, 2023 Author Share Posted October 10, 2023 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. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 10, 2023 Share Posted October 10, 2023 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 Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 10, 2023 Share Posted October 10, 2023 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'. Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 11, 2023 Share Posted October 11, 2023 @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. 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 Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted October 11, 2023 Author Share Posted October 11, 2023 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 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 13, 2023 Share Posted October 13, 2023 @Rick Brewster @toe_head2001 @Ego Eram Reputo @BoltBait Another milestone reached. I just found this that is invaluable. On 11/22/2022 at 1:57 PM, Rick Brewster said: how to write effects using the new GPU plugin system in PDN 5.0. If anyone plans on writing a plugin, they have a lot of reading to do. Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 13, 2023 Share Posted October 13, 2023 On 10/10/2023 at 10:00 AM, Rick Brewster said: You don't need to do any project conversions or wizards. It's good-to-go. It wouldn't build on my machine because of that error I posted. Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 14, 2023 Share Posted October 14, 2023 @Rick Brewster No choice - it is now public. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted October 14, 2023 Author Share Posted October 14, 2023 I didn't ever see an invite 🤔 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
otuncelli Posted October 14, 2023 Share Posted October 14, 2023 27 minutes ago, AndrewDavid said: @Rick Brewster No choice - it is now public. It can be done by adding people under Settings -> Collaborators section. Insights tab is for statistics about your repository which most functions are only available to GitHub Pro users for private repositories. Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 14, 2023 Share Posted October 14, 2023 That whole screen is now active. It makes a difference. Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 21, 2023 Share Posted October 21, 2023 @Rick Brewster My issue with your source code has been resolved. I plan to remove all traces of my copy on GitHub But I want to keep this open- https://github.com/AndrewDavid007/AndrewDavidsPlugins/discussions Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.