Jump to content
How to Install Plugins ×
Paint.NET 5.1 is now available! ×

Recommended Posts

Posted

Norm_Render_Exam.png

 

Current Version: 7.3

I have officially cut development of this plugin to pursue a more advanced and useful project that will work with actual 3D models.

 

Description:

This plugin renders normal maps to shaded images. It has a cinematic light that can be orbited around the virtual 3D surface. It is very fast and renders almost live. It also has exponential drop-off/spread settings which can be used to modify sharpness, contrast, brightness, and angle effect. It does not support the normal map's blue channel (z offset). To add the diff, make the diff a new layer below the rendered normal map. Then set the blend mode to multiply. The plugin can be found under the textures tab in effects.

 

Known Bugs:

 

Fixed:

  • Light Orbit Angles do not yield correct vector rotation (Algorithm Incorrect)
  • Larger angles shade improperly (Algorithm Incorrect)

 

Features:

  • Cinematic Light
  • Light Angle
  • Spead/Drop-off Settings
  • Fast Preview Speed
  • Max Spread Setting

 

I have officially cut development of this plugin to pursue a more advanced and useful project that will work with actual 3D models. A work in progress image can be seen below:

Srender%20V3.png
 

Screenshots:

Norm_Render_Pros.png

(Version 7)

 

Norm_Render_ScrShot.png

(Version 7)

 

Downloads:

Plugin

 

Permissions:

Please don't hesitate make variations of this plugin using the source code, just post them in THIS topic not a new one and post the modified code as well. 90% of the work was debugging the vector algorithms and writing new ones to use different coordinate formats (spherical vs vector, etc). I would like to save others the time it took me, so feel free to use those in your own, original plugins.

 

CodeLab source code provided by @ReMake

CodeLab source provided by ReMake



// Title: Normal Map Render
// Author: Sam Sartor
// Submenu: Texture
// Name: Norm Render
// URL: http://forums.getpaint.net/index.php?/topic/24587-normal-map-renderer/
#region UICode
double Amount1 = 45; // [-180,180] Light Direction
double Amount2 = 45; // [-180,180] Light Height
int Amount3 = 2; // [0,5] 1,5] Increase (Exponent)
int Amount4 = 1; // [0,5] 1,5] Decrease (Exponent)
double Amount5 = 90; // [-180,180] Light Spread
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
	Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

	ColorBgra CurrentPixel;
	double Spr, Onx, Ony, nA, nB, nC, aB, aC, bA, bC, Shade, Col, Top, Edg, ltA, ltB, ltC;
      //Light Angle Conversion (Deg to Rad)
	Edg = 1.5707 + ((Amount1 / 180) * 3.1415);
    Top = 3.1415 - ((Amount2 / 180) * 3.1415);
	Spr = 3.1415 - ((Amount5 / 180) * 3.1415);
      //Per Pixel Functions	
	for (int y = rect.Top; y < rect.Bottom; y++)
	{
		for (int x = rect.Left; x < rect.Right; x++)
		{
			CurrentPixel = src[x,y];
			//Pixel Prossesing		
			Ony = (((double)CurrentPixel.R -128) / 128) * 1.5707;
			Onx = (((double)CurrentPixel.G - 128) / 128) * 1.5707;
			//Vector Conversion
			aB = System.Math.Cos(Onx);
			aC = System.Math.Sin(Onx);
			bA = System.Math.Cos(Ony);
			bC = System.Math.Sin(Ony);
			//Normal Calculations
			nA = (aB * bC);
			nB = (aC * bA);
			nC = 0 - (aB * bA);
			//Light Vector Conversion
			ltA = System.Math.Cos(Edg) * System.Math.Sin(Top);
			ltB = System.Math.Sin(Edg) * System.Math.Sin(Top);
			ltC = System.Math.Cos(Top);
			//Shader
			Shade = System.Math.Acos((nA * ltA) + (nB * ltB) + (nC * ltC));
			if (Shade > Spr)
			{
				Shade = Spr;
			}
			//RGB Shader
			Col = System.Math.Pow((1 - System.Math.Pow((Shade / Spr), Amount3)), Amount4)*255;
			//Write to Display
			CurrentPixel.R = (byte)Col;
			CurrentPixel.G = (byte)Col;
			CurrentPixel.B = (byte)Col;
			dst[x,y] = CurrentPixel;
		}
	}
}

 

 

Sam%20User%20Small.png

Eekysam

Posted

Well it`s certainly fast as you say! Seems very useful. I would just say though that it might be an idea to tell everyone where it can be found in the PDN effects list ( Effects>Texture) as I had a bit of trouble finding it once installed.

 

 

Please feel free to visit my Gallery on PDNFans

And my Alternatives to PDN

  • 1 year later...
Posted

@Ego Eram Reputo

 

Source code gone. Plugin gone.

G'MIC Filter Developer

 

I am away from this forum for undetermined amount of time: If you really need anything related to my PDN plugin or my G'MIC filter within G'MIC plugin, then you can contact me via Paint.NET discord, and mention me.

Posted
4 hours ago, Reptillian said:

@Ego Eram Reputo

 

Source code gone. Plugin gone.

 

I've rehosted the plugin DLL. I don't appear to have the source code archived.

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...