TechnoRobbo Posted June 8, 2013 Share Posted June 8, 2013 (edited) The grayscale of an image copied to the Clipboard modifies your image's pixel locations in 3D space. Endless varieties of can be achieved. Effect->Distort->TRs Displacement Map 3D Version 2.0 added a bunch of fun creative features. Highligth and Shadow Light Source Positioning Color Adjustment Alpha Transparency. Here's the Quick Demo on Youtube: http://youtu.be/VfLRw4wsE2Q Here's the Demo on how to create the 3 Skulls on Youtube: http://youtu.be/aXQeIOBKabk Download: DispMap.zip Here's the code: Spoiler // Name: TRs Displacement Map 3D // Submenu: Distort // Author: TechnoRobbo // Title: Displacement Map 3D PlugIn - v2.1 // Version: 2.1 // Desc: // Keywords: // URL: http://www.technorobbo.com // Help: #region UICode DoubleSliderControl Amount1 = 0.5; // [0,1.5] Control PanSliderControl Amount2 = Pair.Create(0.000,0.000); // Light Source DoubleSliderControl Amount3 = 15; // [0,32] Intensity DoubleSliderControl Amount4 = 1; // [0,1] Red Channel DoubleSliderControl Amount5 = 1; // [0,1] Green Channel DoubleSliderControl Amount6 = 1; // [0,1] Blue Channel CheckboxControl Amount7 = false; // [0,1] Alpha Transparency #endregion private Surface clipboardSurface = null; private bool readClipboard = false; protected override void OnDispose(bool disposing) { if (disposing) { // Release any surfaces or effects you've created. if (clipboardSurface != null) clipboardSurface.Dispose(); clipboardSurface = null; } base.OnDispose(disposing); } void PreRender(Surface dst, Surface src) { if (!readClipboard) { readClipboard = true; clipboardSurface = Services.GetService<IClipboardService>().TryGetSurface(); } } private static void getNormal(double[] v0, double[] v1, double[] v2, double[] normal) { double[] A = new double[3], B = new double[3], product = new double[3]; A[0] = v2[0] - v1[0]; A[1] = v2[1] - v1[1]; A[2] = v2[2] - v1[2]; B[0] = v0[0] - v1[0]; B[1] = v0[1] - v1[1]; B[2] = v0[2] - v1[2]; product[0] = A[1] * B[2] - A[2] * B[1]; product[1] = A[2] * B[0] - A[0] * B[2]; product[2] = A[0] * B[1] - A[1] * B[0]; double length = Math.Sqrt(product[0] * product[0] + product[1] * product[1] + product[2] * product[2]); if (length == 0) { normal[0] = 0; normal[1] = 1; normal[2] = 0; } else { normal[0] = product[0] / length; normal[1] = product[1] / length; normal[2] = product[2] / length; } } void Render(Surface dst, Surface src, Rectangle rect) { if (clipboardSurface == null) { dst.CopySurface(src, rect.Location, rect); return; } Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); double CenterX = ((selection.Right - selection.Left) / 2) + selection.Left; double CenterY = ((selection.Bottom - selection.Top) / 2) + selection.Top; double offx = 0; double offy = 0; double z = 0; double tmp = 0, tmp2 = 0; int nx = 0, ny = 0; const double zp = 255; double SunX = Amount2.First * -1; double SunY = Amount2.Second * -1; double SunZ = 1; ColorBgra CP; ColorBgra shadePixel; double[] shade1 = new double[3]; double[] shade2 = new double[3]; double[] shade3 = new double[3]; double shade = 0; double[] norms = new double[3]; //test variables======= // //SunX=-1; //SunY=-1; //Amount1=1; //Amount3=.7; //======================= for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { //================================ //Get Real Pixels CP = clipboardSurface.GetBilinearSampleClamped(x, y); tmp = ((double)CP.R + (double)CP.B + (double)CP.G) / 3; z = 255 + tmp * Amount1; // 3D Projection tmp2 = tmp; tmp = (double)x - CenterX; offx = tmp * zp / z + CenterX; tmp = (double)y - CenterY; offy = tmp * zp / z + CenterY; CP = src.GetBilinearSample((int)offx, (int)offy); if (tmp2 > 0) { //=============================== //Plot Reflections and shading nx = x - (x % 2); ny = y - (y % 2); shadePixel = clipboardSurface.GetBilinearSampleClamped(nx, ny); tmp = ((double)shadePixel.R + (double)shadePixel.B + (double)shadePixel.G) / 3; shade1[0] = nx; shade1[1] = ny; shade1[2] = tmp; shadePixel = clipboardSurface.GetBilinearSampleClamped(nx + 1, ny); tmp = ((double)shadePixel.R + (double)shadePixel.B + (double)shadePixel.G) / 3; shade2[0] = nx + 1; shade2[1] = ny; shade2[2] = tmp; shadePixel = clipboardSurface.GetBilinearSampleClamped(nx, ny + 1); tmp = ((double)shadePixel.R + (double)shadePixel.B + (double)shadePixel.G) / 3; shade3[0] = nx; shade3[1] = ny + 1; shade3[2] = tmp; getNormal(shade1, shade2, shade3, norms); shade = Math.Sqrt(Math.Pow(norms[0] - SunX, 2) + Math.Pow(norms[1] - SunY, 2) + Math.Pow(norms[2] - SunZ, 2)); shade = (shade * 2 - 1) * Amount3; CP.R = Int32Util.ClampToByte((int)(shade + (double)CP.R * Amount4)); CP.G = Int32Util.ClampToByte((int)(shade + (double)CP.G * Amount5)); CP.B = Int32Util.ClampToByte((int)(shade + (double)CP.B * Amount6)); } else if (Amount7) { CP.A = 0; } dst[x, y] = CP; } } } Old Version: Spoiler OLDER 2.0 version DispMap.zip // Submenu: Distort // Name: TRs Displacement Map 3D // Title: Displacement Map 3D PlugIn - v2.0 // Author: TechnoRobbo // URL: http://www.technorobbo.com #region UICode double Amount1 = 0.5; // [0,1.5] Control Pair<double, double> Amount2 = Pair.Create( 0.0 , 0.0 ); // Light Source double Amount3 = 15; // [0,32] Intensity double Amount4 = 1; // [0,1] Red Channel double Amount5 = 1; // [0,1] Green Channel double Amount6 = 1; // [0,1] Blue Channel bool Amount7 = false; // [0,1] Alpha Transparency #endregion protected Surface img { get { if (_img != null) return _img; else { System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(GetImageFromClipboard)); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); return _img; } } } private Surface _img = null; private void GetImageFromClipboard() { Bitmap aimg = null; IDataObject clippy; try { clippy = Clipboard.GetDataObject(); if (clippy != null) { aimg = (Bitmap)clippy.GetData(typeof(System.Drawing.Bitmap)); } } catch (Exception ) { } if (aimg != null) { _img = Surface.CopyFromBitmap(aimg); } else { _img = null; } } private void getNormal(double[] v0, double[] v1, double[] v2,double[] normal) { double[] A = new double[3], B= new double[3], product= new double[3]; double length; A[0] = v2[0] - v1[0]; A[1] = v2[1] - v1[1]; A[2] = v2[2] - v1[2]; B[0] = v0[0] - v1[0]; B[1] = v0[1] - v1[1]; B[2] = v0[2] - v1[2]; product[0] = A[1] * B[2] - A[2] * B[1]; product[1] = A[2] * B[0] - A[0] * B[2]; product[2] = A[0] * B[1] - A[1] * B[0]; length = Math.Sqrt(product[0]*product[0] + product[1]*product[1] + product[2]*product[2]); if (length == 0) { normal[0] = 0; normal[1] = 1; normal[2] = 0; }else{ normal[0] = product[0] / length; normal[1] = product[1] / length; normal[2] = product[2] / length; } } void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); double CenterX = ((selection.Right - selection.Left) / 2)+selection.Left; double CenterY= ((selection.Bottom - selection.Top) / 2)+selection.Top; double offx =0; double offy =0; double z=0; double tmp =0, tmp2 =0; int nx =0, ny =0; double zp=255; double SunX = Amount2.First * -1; double SunY = Amount2.Second * -1; double SunZ = 1; ColorBgra CP; double[] shade1 = new double[3]; double[] shade2 = new double[3]; double[] shade3 = new double[3]; double shade = 0; double[] norms = new double[3]; double[] RGB={0,0,0}; //test variables======= // //SunX=-1; //SunY=-1; //Amount1=1; //Amount3=.7; //======================= for (int y = rect.Top; y < rect.Bottom; y++) { shade=0; for (int x = rect.Left; x < rect.Right; x++) { if (img == null){ dst[x,y] = src[x,y]; }else { //=============================== //Plot Reflections and shading nx= x - (x % 2); ny= y - (y % 2); CP= img.GetBilinearSampleClamped(nx,ny); tmp =((double) CP.R + (double) CP.B + (double) CP.G)/3; shade1[0]=nx; shade1[1]=ny; shade1[2]=tmp; CP= img.GetBilinearSampleClamped(nx+1,ny); tmp =((double) CP.R + (double) CP.B + (double) CP.G)/3; shade2[0]=nx+1; shade2[1]=ny; shade2[2]=tmp; CP= img.GetBilinearSampleClamped(nx,ny+1); tmp =((double) CP.R + (double) CP.B + (double) CP.G)/3; shade3[0]=nx; shade3[1]=ny+1; shade3[2]=tmp; getNormal(shade1,shade2,shade3,norms); shade = Math.Sqrt(Math.Pow(norms[0] - SunX , 2) + Math.Pow(norms[1] - SunY , 2) + Math.Pow(norms[2] - SunZ , 2)); shade = (shade * 2 - 1) * Amount3; //================================ //Get Real Pixels CP= img.GetBilinearSampleClamped(x,y); tmp =((double) CP.R + (double) CP.B + (double) CP.G)/3; z=255 + tmp * Amount1; // 3D Projection tmp2=tmp; tmp=(double)x-CenterX; offx = tmp * zp / z + CenterX; tmp=(double)y-CenterY; offy= tmp * zp / z + CenterY; CP = src.GetBilinearSample((int)offx,(int)offy); if (tmp2 >0){ CP.R = Int32Util.ClampToByte((int)(shade + (double) CP.R * Amount4 )); CP.G = Int32Util.ClampToByte((int)(shade + (double) CP.G * Amount5 )); CP.B = Int32Util.ClampToByte((int)(shade + (double) CP.B * Amount6 )); }else if (Amount7){ CP.A=0; } dst[x,y]=CP; } } } } Edited September 19, 2019 by toe_head2001 2 Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted June 8, 2013 Share Posted June 8, 2013 This seems vastly different to the other bump map plugins. Are you sure you wish to call it that? That said - it's an interesting distortion! Thanks for sharing it. Edit: Seems incredibly slow?? Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 8, 2013 Author Share Posted June 8, 2013 (edited) It's only slow when the size of the image doesn't match the size of the map. When it does match the transformation is instant. I wasn't sure whether to call it a bump map or a displacement map. Since both refer to 3D shaders. Perhaps Displacement would be better. Update: I've changed the name and included the recommendation to use same size image and map , I also modified the Youtube tutorial to reflect the changes. Thanks for your help Ego. Edited June 8, 2013 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
archip Posted June 8, 2013 Share Posted June 8, 2013 Very fun plugin, I'm sure it will be useful Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 9, 2013 Author Share Posted June 9, 2013 (edited) How to make a faux reflection pond with the plug-in: http://youtu.be/1zIqTkgiIbw Edited December 28, 2015 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
DrewDale Posted June 9, 2013 Share Posted June 9, 2013 (edited) Using a filled shape ellipse can produce some cool selective bulge type effect. Nice work TechnoRobbo Edited June 9, 2013 by DrewDale Quote Link to comment Share on other sites More sharing options...
doughty Posted June 12, 2013 Share Posted June 12, 2013 Nice...I like that it uses copy to clipboard. The name change doesn't show in the menu options. Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 12, 2013 Author Share Posted June 12, 2013 Doughty, Thanks - I must have not uploaded the changes - just the source code. Will do Thanks Again Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
doughty Posted June 12, 2013 Share Posted June 12, 2013 (edited) Sorry I meant the name change doesn't show in the effects menu. I deleted, redownloaded and reinstalled, but please tell me if I'm not doing something right. Edit: Just noticed I have multiples of a few things. Edited June 12, 2013 by doughty Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 12, 2013 Author Share Posted June 12, 2013 (edited) Doughty That's it, the Displacement Map without an icon. The others are different plugins probably from different plugin packs. Maybe I should change the name to TR's Displacement Map to avoid confusion. Ok - done reinstall Edited June 12, 2013 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
doughty Posted June 13, 2013 Share Posted June 13, 2013 Sorry for my confusion. I used your Line Tracer plugin on the photo of my cat to create a map. The frame from another project worked just as I hoped. 1 Quote Link to comment Share on other sites More sharing options...
nitenurse79 Posted June 13, 2013 Share Posted June 13, 2013 Nice example doughty, looks almost like a frosted glass effect too. Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 21, 2013 Author Share Posted June 21, 2013 Version 2.0 Displacement Map 3D - Original post refreshed 1 Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
DrewDale Posted June 21, 2013 Share Posted June 21, 2013 Cool new update, works good with symbols too Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 21, 2013 Author Share Posted June 21, 2013 (edited) DrewDale, I too find nature inspiring. 3 Image Created with TRs Displacement Map 3D v2.0 and Kate Upton. Edited December 28, 2015 by TechnoRobbo 1 Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 22, 2013 Author Share Posted June 22, 2013 (edited) New Reflecting pond instruction at http://youtu.be/1zIqTkgiIbw. guaranteed to be less boring than the last Reflecting pond Demo. One more for the road - The All Seeing Eye Edited December 28, 2015 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
TechnoRobbo Posted July 5, 2013 Author Share Posted July 5, 2013 Awesome Graphic!!!!!!!! WB Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted July 6, 2013 Share Posted July 6, 2013 That's why he is the King! Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
nitenurse79 Posted July 7, 2013 Share Posted July 7, 2013 Very nice plug-in TechnoRobbo. Nice image example Welshblue I found it works just as effective on non-Gaussian blurred text too. What I did extra was copy the background, tick the alpha transparency box then added drop shadow to the text. Quote Link to comment Share on other sites More sharing options...
Lana Posted August 20, 2013 Share Posted August 20, 2013 (edited) Thank youuuuuuu!!!!I love this effect. It was the first , will train . Do not kill me . Did the Paint Net. Uploaded with ImageShack.com Edited August 20, 2013 by Lana Quote Uploaded with ImageShack.com Link to comment Share on other sites More sharing options...
KellyJ13 Posted March 17, 2014 Share Posted March 17, 2014 Hello, I'm having more than one problem today: First I tried pasting my crash log right into this post but it wouldn't let me so I had to make an attachment of the crash log. Second when I tried to use this TR's Displacement I had PDN crash on me twice. Can anyone please read the crash log and tell me what I need to do to fix this? Quote Link to comment Share on other sites More sharing options...
KellyJ13 Posted March 17, 2014 Share Posted March 17, 2014 Update: For some reason I cannot paste or insert an image of the crash log: but when inserting the image link from Photobucket this website froze on me and it also won't let me do an attachment.....Paint.net doesn't like me . Anyone else having problems with posting? I also e-mailed the crash log to the professionals at this website hopefully they will get back to me soon. Quote Link to comment Share on other sites More sharing options...
Pixey Posted March 17, 2014 Share Posted March 17, 2014 Hi Kelly - I tried it too and it's incompatible with the new version. I have added it to the Incompatible Thread for you.FYI - if you want to add the crash log next time to your post, here is a way. C&P the text then, when you are in your post, click on the little light switch (upper left corner of the tool bar) and add your text between this code: [hide}C&P your text here[/hide} Replace the 2 }'s with ]and[ then it will appear like this Hidden Content: text here Bye . Quote How I made Jennifer & Halle in Paint.net My Gallery | My Deviant Art "Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon. Link to comment Share on other sites More sharing options...
TechnoRobbo Posted March 17, 2014 Author Share Posted March 17, 2014 (edited) Thanks for the heads up, I will look into it when I get home. By the way the Pixey that crash log posted was for Curtis Black's Displacement. Edited March 17, 2014 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Pixey Posted March 17, 2014 Share Posted March 17, 2014 (edited) @Kelly - it may not be TR's that is crashing. I got confused between the Displacement plugins in the Effects folder. One shows as 'Displacement' and another shows as 'Displacement Map'. It's hard to tell which belongs to whom .Edit: I just tried TR's D-Map in Beta v4 and it's working fine - hopefully you will get it sorted soon. I know I've had awful trouble with internet connections the past few days .... perhaps it's work-wide and causing chaos . Edited March 17, 2014 by Pixey Quote How I made Jennifer & Halle in Paint.net My Gallery | My Deviant Art "Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon. 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.