Jump to content
How to Install Plugins ×

NormalMapPlus v1.0


Simon Brown

Recommended Posts

MODERATORS NOTE:  this plugin has been superseded by a newer version:

https://forums.getpaint.net/topic/111602-normalmapplus-codelab-implementation/

 

 

Based on harold's public domain plugin that he no longer supports (LINK). Note that the source is based on output from Reflector and i've done little so far besides getting it working.

Source

Download (Click NormalMapPlus.zip)

w9jwk0.png

efnpqh.png

 

Edited by toe_head2001
  • Upvote 1
KaHuc.png
Link to comment
Share on other sites

Brilliant! Thanks so much Simon.

Link to comment
Share on other sites

  • 2 weeks later...

Cool :D

Would you mind giving me a quick overview of the changes that were necessary to make it work again?

I would write plugins, if I knew what kind of plugins were needed.. :(

Link to comment
Share on other sites

Roughly:

1. I created a new effect using IndirectUI and copied the OnRender method out of the output from Reflector.

2. I copied the Float4 class across and changed the code in the OnRender method to use it instead of looking for it as a nested class.

3. I fixed the casting errors.

The source is here: http://github.com/simonbrown/NormalMapPlus

KaHuc.png
Link to comment
Share on other sites

  • 2 months later...

Hi Simon, is this plugin still supported? I tried the link provided but all I get is the source in a zip file. Sorry, but I don't know what to do with the source. I looked in your plugin pack and didn't see it there. Any chance of getting it as a dll for the current version of PdN? Thanks :D I use the height field to normal map for textures quite a bit and this plugin looks to be something I could really use. :D:D

 

SAC, WOTW and Photo Manip Competition Host

To visit the Comps click HERE

Link to comment
Share on other sites

It's in the "downloads" section.

I have it now, thank you Simon. For some reason I could not access the downloads area from my home connection, but here at my office it opened up quickly and I was able to download the dll. Thank you very much, I am sure I will find this to be a valuable plugin.

 

SAC, WOTW and Photo Manip Competition Host

To visit the Comps click HERE

Link to comment
Share on other sites

  • 1 year later...

I have it now, thank you Simon. For some reason I could not access the downloads area from my home connection, but here at my office it opened up quickly and I was able to download the dll. Thank you very much, I am sure I will find this to be a valuable plugin.

Hi Simon,

I tried downloading your normal map plus plugin but all i get is this one which i assume is the unsupported one

[/url]Kindly refrain from linking to illegal ripoff sites. Thanks./Features/Effects/Plugins/Color/Normal_Map/"]My link

would you be able to supply a direct link to the dll file please

Edited by joduffy
Link to comment
Share on other sites

Find the (functioning) link in the first post of this thread.

The URL you posted is an illegal site that rips off the hard work of plugin authors. As you can see the URL is removed whenever posted.

For your own security, NEVER download a plugin from any other site except this forum (or from links posted on this forum).

If you have downloaded from another site (especially a huge pack of plugins) I suggest you delete them all and download them again from here.

Link to comment
Share on other sites

Find the (functioning) link in the first post of this thread.

The URL you posted is an illegal site that rips off the hard work of plugin authors. As you can see the URL is removed whenever posted.

For your own security, NEVER download a plugin from any other site except this forum (or from links posted on this forum).

If you have downloaded from another site (especially a huge pack of plugins) I suggest you delete them all and download them again from here.

Thanks for your help.

I deleted all the files and re-installed paint.net

I also went back to the first link on this thread and found the downloads options on the far right hand side.

Thanks for your help Ego and also to Simon for the plugin

Link to comment
Share on other sites

Glad I could help. I trust you've got this plugin working now? :D

Link to comment
Share on other sites

  • 10 months later...

Simon,

 

I'm surprised to find artifacts in the normal maps created by this plugin.  As no one has reported this before, I assumed it was something unique to my system or I was doing something wrong.  I tried it on a different system, but got similar results.  One is a Dell laptop with an integrated GPU, the other is a Falcon NW with a discrete nVidia card.  The laptop is running Windows XP Professional, SP3.  The desktop is running Windows XP Home, SP3.

Although the artifacts appear to be present most of the time, they are most obvious when derived from artificial displacement maps with steep contours.

The following picture shows the displacement map on the bottom, an artifact free normal map created from it in the middle, and one showing the artifacts at the top.

  NormalMapIssue1.png

I also created a normal map while zoomed in near the center at 800%.  The resulting map is show below zoomed at 200% so you can see the artifacts more clearly.  Note that the portion that was visible on the screen does not have the artifacts.
NormalMapIssue2.png

The issue seems to be associated in some way with the aspect of the image and the zoom level when it is made.  I tried with and without antialiasing, and with both normal blending and overwrite.  I tried with the dimensions in pixels equal to powers of two and not.  These seem to have no affect.  I also tried NormalMapPlus in a new installation of Paint.Net (3.5.10) with no other .dlls in the Effects folder.

 

If I have missed something obvious, I apologize.  I understand that you converted this from someone else's work and may not be able to fix this.  I would like to know if others can reproduce my results.

 

Vince

Edited by Vince
Link to comment
Share on other sites

  • 4 years later...

Installed the plug in, (vers 4.0.16) tested it and it worked great.  Went to actually use it about a week later and it errors out with this message every time now.  

 

File: C:\Program Files\paint.net\Effects\NormalMapPlus.dll
      Effect Name: NormalMapPlus.NormalMapPlus
      Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at NormalMapPlus.NormalMapPlus.OnRender(Rectangle[] renderRects, Int32 startIndex, Int32 length)
   at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 98
   at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, IRenderer`1 clipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 170
   at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 150
   at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 142
   at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 239
   --- End of inner exception stack trace ---
   at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 419
   at PaintDotNet.Effects.BackgroundEffectRenderer.Abort() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 375
   at PaintDotNet.Effects.BackgroundEffectRenderer.Start() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 321
   at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass42_5.<RunEffectImpl>b__4() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 1004
 

Link to comment
Share on other sites

File: C:\Program Files\paint.net\Effects\NormalMapPlus.dll
      Effect Name: NormalMapPlus.NormalMapPlus
      Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at NormalMapPlus.NormalMapPlus.OnRender(Rectangle[] renderRects, Int32 startIndex, Int32 length)
   at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 98
   at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, IRenderer`1 clipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 170
   at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 150
   at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 142
   at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 239
   --- End of inner exception stack trace ---
   at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 419
   at PaintDotNet.Effects.BackgroundEffectRenderer.Abort() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 375
   at PaintDotNet.Effects.BackgroundEffectRenderer.Start() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 321
   at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass42_5.<RunEffectImpl>b__4() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 1021
 

Same here. Another Simon Brown plugin that fails to function in the new O/S PaintNet environment.

 

@Willy McCoy Also read https://forums.getpaint.net/index.php?/topic/111478-paintnet-4016-crashes-when-i-select-tools/#comment-532219

 

@Ego Eram Reputo @Rick Brewster Same issue as Olden. B)

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

No, that's a different crash. Olden is sending bad data to another built-in plugin. NormalMapPlus is trying to access memory that it doesn't have permission for.

 

I'll file a bug though ... I may need to block both of these plugins if there isn't a reasonable workaround I can find.

  • Upvote 2

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

  • 2 weeks later...

NormalMapPlus is probably the one plugin I can't do without as it's my Normal map tool of choice.

So firstly a big thank-you kindly to Simon Brown for it!

 

I'm running Paint.net 4.0.16 on a Windows 7 64 bit OS & NormalMapPlus was working just fine, I used it all the time.

Then one day it would not work & caused the error report mentioned by others above.

 

I'd recently had a Windows update & knew the plugin had been working prior so I looked into that.

Turns out that Net Framework 4.6 was updated to 4.7.

 

On a hunch I rolled back to 4.6 & the NormalMapPlus plugin worked again.

Net Framework should be backwards compatible, so it's probably something quite simple wrong within NormalMapPlus, possibly specifying 4.6 rather than any later version.

 

I did not want to stay with the old Net Framework in permanently so as a workaround, while old 4.6 was still installed, I went to:

 

%WINDIR%\Microsoft.NET\Framework64

 

Or, if you're not using a 64 bit OS:

 

%WINDIR%\Microsoft.NET\Framework

 

I made a copy of the folder:

 

v4.0.30319

 

& added OLD at the end of its name.

 

I then updated to Net Framework 4.7 again.

 

When I need to use NormalMapPlus I go to the Framework64 folder & rename the v4.0.30319 folder to v4.0.30319New & remove the OLD from the copy I'd made. Do the rename before opening Paint.net of course.

 

If you have a 64 bit OS you only need to change that folder in the Framework64 folder as that's the default that's used.

 

Making a shortcut to that Framework64/Framework folder will also save you time.

 

I then rename the folders back again after I'm done to return to Net Framework 4.7.

 

Obviously not ideal but it's actually pretty straight forward in practice & allows you to have the latest Net Framework for the rest of the time & only use 4.6 when wanting to use NormalMapPlus.

 

A proper fix would be greatly appreciated!

 

Hope this helps!

 

Prensa

Edited by Prensa
tidy up structure
Link to comment
Share on other sites

2 hours ago, Prensa said:

On a hunch I rolled back to 4.6 & the NormalMapPlus plugin worked again.

Net Framework should be backwards compatible, so it's probably something quite simple wrong within NormalMapPlus, possibly specifying 4.6 rather than any later version.

 

I am on the Windows 10 Creators Update so I am not able to rollback the .NET Framework version,

but that would concur with my testing that the crash appears to be caused by a regression in the .NET 4.7 JIT optimizer.

 

@Ego Eram Reputo @Rick Brewster

 

Using the MethodImplAttribute to disable JIT optimizations for the OnRender method has fixed the crash.

 

Download: https://github.com/0xC0000054/NormalMapPlus/releases

 

  • Upvote 1

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

@Prensa and @null54

I too am on Win 10 creators update. What I find interesting is that I have no update to 4.7 Net framework. (Yes I have auto updating on)

Another app you are running must need it. Would be interested to see if you can figure that one out. This cant be the exact solution as I have trouble running the plugin. @Rick Brewster explained it better than I could.

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

28 minutes ago, AndrewDavid said:

I too am on Win 10 creators update. What I find interesting is that I have no update to 4.7 Net framework. (Yes I have auto updating on)

Another app you are running must need it. Would be interested to see if you can figure that one out.

 

I do not know what application installed .NET 4.7, Visual Studio 2017 would be my guess.

I wrote that it may be a .NET 4.7 bug based on @Prensa stating that the plugin works on .NET 4.6.

 

If my update fixes your crash then the problem may have started with an earlier .NET version, or be caused by something else.

  • Upvote 2

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

Hello - null54!

 

"Using the MethodImplAttribute to disable JIT optimizations for the OnRender method has fixed the crash. "

 

Wow, that was fast work! :)

I've tested your new version of the plugin & it works!

 

Compared its effects to using the older version & they appear the same so this seems perfect (fingers crossed).

 

Thank-you kindly for taking the time to fix this & sharing the results. :)

 

~~~~~~~~~~~~~

 

Hello - AndrewDavid!

 

"I too am on Win 10 creators update. What I find interesting is that I have no update to 4.7 Net framework. (Yes I have auto updating on)
Another app you are running must need it."

 

It was a standard Windows Update on my Win7 OS, after I rolled back it even quickly reappeared in the updates list to install again.

I was able to determine it was the change from 4.6 to 4.7 because I'd made a normal the day or so before the update yet could not run it after.

 

Try null54's updated version of NormalMapPlus, it's working for me so hopefully will for you too. :)

 

Prensa

Edited by Prensa
Link to comment
Share on other sites

What this plugin does appears to be reasonably simple, but I'm not certain exactly what it does. If those who use it could describe what it should do and what they use it for, I might be able to write a new plugin that does that. I can't really see what it's useful for. Is the lighting control actually used, or is it just set to (1, 0, 0) so the unaltered coordinates are returned. Is applying the transformation to the alpha channel used?

 

EDIT: On second thought, maybe I'll just make a updated version that does the same thing, without worrying about the whats and wherefores. I don't think it would be difficult. Whatever is the problem with this plugin, I don't think it's related to the actual functionality. Still, if anyone wants to explain how the plugin is used, that might be helpful.

 

EDIT 2: Let me explain what confuses me. Because the main operation appears to be differentiation, my impression is that the plugin converts some sort of height map into surface-normal vectors. So I'd assume the normal vectors would be returned, in integer form, in the RGB components. I'd also assume the height map would either be represented as a 24-bit number using RGB, a 32-bit number using ARGB, or some 8-bit or so representation using either one of the color components, or the sum of the color components, or something similar. However, the code seems to be treating each of the ARGB components separately as source (height?) values. Also, if the purpose is to compute normal vectors, what is the lighting for? Seemingly, there are things I misunderstand. My question is: in actual use, what is the source image, and what is the desired output?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...