Popular Post MJW Posted June 27, 2015 Popular Post Share Posted June 27, 2015 (edited) This plugin applies shading to a texture defined by a height map, and also applies various displacement modes to an image that's mapped onto the texture.. The height map is a black and white image. Normally black represents 0 and white represents the maximum height, but this can be reversed. I know there are plugins that do similar things (so you don't need to tell me) but I believe this plugin has more features. It certainly has plenty of controls. The plugin is under "Effects>Height Map>Texture Shader." ("Look for the golden orb!") ============================================================================= The plugin: TextureShader_ver2_3_0.zip ============================================================================= The interface (or as much as will fit) looks like: he controls are:Image: Specifies the source of the image mapped onto the texture. It can either be the clipboard, or a constant color. Pixels outside the image range of the clipboard can be transparent, Clamped, Tiled, or Alternately Tiled. When Alternately Tiled is selected, the tile orientation is reversed for every other tile, so that the tiles match at the edges. The edge pixels are not repeated. When a color is used, the image mapping methods have no effect on the final image.Clipboard Image Size: Increases or decreases the size of the clipboard image.Clipboard Image Offset: Moves the clipboard image relative to the texture.Clipboard Image Rotation: Specifies a counterclockwise rotation angle, in degrees.Clipboard Image Mapping Method: Specifies how the image is mapped onto the texture. The choices are: Surface Offset 1: Uses the height and gradient of the texture to attempt to map the image onto the texture as if it were painted onto the surface. Surface Offset 2: An alternate method of mapping the image as if painted onto the surface. Gradient: The simplest mapping method. Displaces the image in the direction of the gradient, in proportion to the gradient magnitude. Gradient-Z: Displaces the image in the direction of the gradient, in proportion to the product of the texture height and the gradient magnitude. Refraction: Displaces the image as if it were refracted by the texture, in accordance with Snell's Law. The Displacement Scale is proportional to the Index of Refraction Reflection: Displaces the image as if it were reflected by the texture surface. The Displacement Scale is proportional to the distance from the texture to the reflected plane. Because the angle of reflection equals the angle of incidence, points with gradients of more than 45° will not reflect the image and will be rendered as transparent. Reflection (Ignore Height): Displaces the image as if it were reflected by the texture surface, but uses only the gradient, ignoring the effect caused by the texture height. Reflection (with Re-reflection): Applies reflection, but approximates the re-reflection of downward reflection vectors. Faux Reflection: Approximates reflection for gradients of less than 45°, but produces non-transparent pixels for gradients greater that 45°. Faux Reflection (Ignore Height): Applies Faux Reflection, ignoring the effect caused by the texture height. Reflection Map (Equirectangular): Displaces the image as if it were reflected from a sphere surrounding the texture surface. The clipboard image is an equirectangular projection. Normally the width of an equirectangular projection is twice the height, but any image will be scaled to cover the entire sphere when the Clipboard Image Size is 1. The sphere can be rotated using the Clipboard Image Offset and Clipboard Image Rotation controls. The Mapping Displacement is inversely proportional to the sphere's radius. The higher the value, the more the reflection depends on the surface position. When 0, the reflection depends only on the gradient. Large values can result in the texture surface extending outside the sphere, in which case the outside region will be transparent. Gradient Map (Equirectangular): Displaces the image based on the intersection of the surface gradient vector with a sphere surrounding the texture surface. The clipboard image is an equirectangular projection. This mapping method is similar to Reflection Mapping, except the gradient vector is used in place of the reflection vector. Divide Mapping Displacement by Ten: Specifies that the Mapping Displacement should be divided by 10 to decrease the control's range.Mapping Displacement: Controls the amount the image pixels are displaced. The effect depends on the Mapping Method. For most methods, it acts as a general scaling factor, but for Refraction and Reflection it has a specific physical meaning. For some mapping methods, such as reflection, setting this value to 0 does not result in no displacement. Divide Texture Height Scale by Ten: Specifies that the Texture Height Scale should be divided by 10 to decrease the control's range. Texture Height Scale: Increases or decreases the texture height.Texture Height Curvature: Increases or decreases the texture height curvature. Generally, positive values round the texture while negative values steepen the texture. Intensity Increases with Height: Normally black represents 0 and white represents the maximum height. When this control is unchecked, the direction is reversed.Use Alpha from Texture: Selecting this option causes the alpha value of the texture to be multiplied by the image alpha. Otherwise, the alpha value of the texture is ignored. (Use caution in making areas of the texture transparent; many methods that make pixels transparent also modify the color components, which will change the edge gradient.)Ambient Light Color: Sets the color of the ambient light source. Ambient light affects all pixels equally, no matter their orientation. The default color is black (no ambient lighting).Directional Light Color: Sets the color of the directional light. The default color is white.Directional Light Direction (Use Outer Ring to Reverse): Sets the direction of the directional light. The directional light's effect on a pixel is determined by light's direction and the texture's gradient at the pixel. Moving the outer ring to the left side of the control reverses the light direction.Directional Light Intensity: Increases or decreases the intensity of the directional light. The directional light contributes both diffuse and specular (reflected) light.Specularity: Determines the shininess of the surface. Increasing this value decreases the diffuse lighting and increases the specular lighting.Specular Concentration (Exponent): Determines the sharpness of the specular highlights. Higher values produce sharper highlights.Apply Surface Color to Highlight: Normally the specular highlight is the color of the directional light, and does not depend on the surface color. Highlights on colored metal take on the color of the metal. Selecting this option multiplies the light color by the surface color when producing the highlight.Antialias: Specifies that antialiasing should be used. Antialiasing can improve many images, especially when reflection is used. Antialiasing will slow the effect, because many more points need to be processed.Antialias Quality: Specifies the number of samples in each direction per pixel. The total number of samples per pixel is this value squared. In what may to some seem contrary to expectations (but which I think makes sense), the canvas image is the texture map, not the image that's mapped onto the texture. The image to be mapped onto the texture must be in the clipboard. There's also the option of using a color rather than a clipboard image, in which case only shading is applied. Typically, the height map is produced by blurring a black and white image. For example, the MJW in the gold reflection image is blurred text. The height map normally must be black and white. The plugin does not convert color images into intensities. One problem is that for some textures there are obvious "waterlines." This is a result of the very limited precision of the height map when used with the normal black-and-white representation. BTW, the gold refection example was produced by the trick of setting the light colors to a gold color (something like RGB = (255, 190, 0) when at full brightness). If I'd wanted to make the background silver, I could have rendered it with white light. The fact that plugins preserve the settings, including image position, between invocations can be a big advantage when rendering different parts of the image with different distortions, light colors, etc. The texture height map can be 24 bits, consisting of the concatenated RGB components (which is why 8-bit maps must be black and white). Here is a 24-bit sphere height maps: If you use this is a texture, and set the Texture Height Scale to 255, it will produce a very smooth sphere. EDIT: A few suggested changes by Red ochre, and a couple of additional comments abut the reflection example. EDIT: I discovered I forgot to remove some try-catch debug code from the float version of GetSurfaceGradient. Though it shouldn't cause any problems, other than perhaps a slight slow down, I removed it from the posted source code, and will post a new DLL later today. If anyone discovers any spelling errors in the plugin, or has any suggestions for improved wording (or other improvements) for the controls, please let me know, so I can fix them at the same time. EDIT 08 Sep 2016: Release version 2.0.*. Now a Visual Studio project instead of CodeLab. Moved from Distort submenu into new Height Map submenu. Made various cosmetic and functional modifications to the user interface, such as using the Angle Control, and changing the number of decimal places. Made White instead of Clipboard the default Image. Added Texture Height Curvature control. Removed option of offsetting relative to selection instead of window. Added option of reversing Directional Light direction. Added Help menu. EDIT 09: 06 Apr 2017: Release version 2.1.* Mostly cosmetic changes. The interface was modified to look more like the Texture Merger. The Texture Height Scale range was increased. EDIT 10: 11 Feb 2018: Release version 2.2.0 Added Reflection Map (Equirectangular) mapping mode. EDIT 11: 28 Feb 2018: Release Version 2.3.0 Added Gradient Map (Equirectangular) mapping mode. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Edited August 21, 2020 by Ego Eram Reputo restored title & location 15 Quote Link to comment Share on other sites More sharing options...
Eli Posted June 27, 2015 Share Posted June 27, 2015 Thanks MJW The effect is very COOL! 5 Quote Link to comment Share on other sites More sharing options...
Maximilian Posted June 27, 2015 Share Posted June 27, 2015 Oh, yet another toy to play with! Looks like a busy weekend ahead of me! Quote Link to comment Share on other sites More sharing options...
Red ochre Posted June 27, 2015 Share Posted June 27, 2015 Looks interesting (downloading) - thanks!Plenty of well annotated code to read through - thanks for that too. ps. I think it would be useful to state the SubmenuName (Distort) and Pdn version compatibility (Pdn 4 only)? pps. Work well! Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings Link to comment Share on other sites More sharing options...
racerx Posted June 27, 2015 Share Posted June 27, 2015 Good plugin. Took a lot of fidgeting, but the end result is good. Gotta have money...... 3 Quote Link to comment Share on other sites More sharing options...
Maximilian Posted June 28, 2015 Share Posted June 28, 2015 I get an error while trying to compile for PdN 3.5.11. Seems the old CodeLab can't recognize the "Tuple" type or something like that. Would there be a way around this problem? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted June 28, 2015 Share Posted June 28, 2015 I get an error while trying to compile for PdN 3.5.11. Seems the old CodeLab can't recognize the "Tuple" type or something like that. Would there be a way around this problem? The 3D Roll Control doesn't exist in Paint.NET 3.5x. Sorry. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Maximilian Posted June 28, 2015 Share Posted June 28, 2015 I see. Thank you, BoltBait. Quote Link to comment Share on other sites More sharing options...
AgentGoodspeed Posted June 28, 2015 Share Posted June 28, 2015 I've downloaded/installed this yesterday and played around a little.However, I'm sad to say that… I don't get it.Could somebody please give me a hint about how to use this? I mean, should it be used on the layer with your text? Or above it? Underneath it?I've figured out that you need to copy your image/texture on the clipboard but I can't get any of these cool result. At best I got the outline of my text with the clipboard image as a background Any tip would be appreciated! Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted June 28, 2015 Share Posted June 28, 2015 I'm really diggin' this, nice work!! 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...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 Maximilian: I'll try to come up with an alternative for you for the light position using the X-Y control. AgentGoodspeed, open the following image in PDN. Then open any other image and copy it into the clipboard (using ctrl-C). Now go to the MJW image and run Texture Shader. The clipboard image should appear mapped onto the MJW image. You may have to adjust the size of the clipboard image with Image Scale. Adjust the directional light position so the light doesn't come from straight ahead for a more effective image. Set the Image Source to White, and the MJW wil be shaded, with no image. Remember that to a plugin there's only one layer: the current active layer. That's where the texture should be. The only other image is the one in the clipboard. From your description, you may need to do several things. First, as I mentioned, move the light from dead center to upward and off to the side. Second, adjust the texture height. Then try different Mapping Modes. The Reflection modes are the most dramatic, but they're kind of picky, since the reflections may be of the outside transparent pixels. Adjust the Texture Height Scale, Texture Displacement Scale, and Image Scale to deal with that. Tiling will get rid of random remaining transparent pixels. The Faux Reflection and Re-reflection modes won't produce transparent pixels when tiling is used. Antialiasing very often improves reflected images. Adjust the Specularity controls. To me, specularity is the secret sauce to producing cool images. For variety, add a small amount (around 15) of black-and-white (Saturation 0) Noise, followed by a small (Radius 1 to 3) Gaussian Blur. That will make a rough texture. Or use a Motion Blur instead of a Gaussian. Most of the light will probably be Directional, but don't be afraid to add a bit of Ambient Light to fill in the shadows. Using a slightly yellowish Directional Light and a slightly bluish Ambient Light can sometimes give a nice effect. Quote Link to comment Share on other sites More sharing options...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 (edited) Duplicate comment deleted. See following comment. Edited June 28, 2015 by MJW Quote Link to comment Share on other sites More sharing options...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 (edited) Maximilian: Try this. Replace the UI variable line for the directional light with: Pair<double, double> Amount14 = Pair.Create(0.0,0.0); // Directional Light Direction Then replace GetDirectionalLightDirection (near the end of the code) with: // Get the direction the directional light is pointing. float lX, lY, lZ; void GetDirectionalLightDirection(Pair<double, double> dir) { double x = -dir.First, y = -dir.Second; if ((x == 0.0) && (y == 0.0)) { lX = lY = 0.0f; lZ = 1.0f; } else { // Map the square into a circle by dividing by the distance to the nearest side. // In an abundance of caution, very slightly scale down the transformed x and y to avoid the // possibility of round-off error causing the square root of a negative number in the z calculation. double absX = Math.Abs(x), absY = Math.Abs(y); double distScale = 0.999999 * Math.Sqrt(Math.Max(absX, absY) / (absX + absY)); x *= distScale; y *= distScale; // Now the x and y coordinates are within a unit circle. // Get the z coordinate from the unit sphere. lX = (float)x; lY = (float)y; lZ = (float)Math.Sqrt(1.0 - x * x - y * y); } } I tested it, and it seems to work fine. The control won't be quire as intuitive as the original version, but since you can look at the light in the actual image, it should be serviceable. (Actually, while the control on the left is less intuitive, I prefer the slider controls to the 3D Roll Control equivalents.) Edited June 29, 2015 by MJW 1 Quote Link to comment Share on other sites More sharing options...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 Avatar on foil: 2 Quote Link to comment Share on other sites More sharing options...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 Avatar on cloth: 2 Quote Link to comment Share on other sites More sharing options...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 MJW in black: Quote Link to comment Share on other sites More sharing options...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 MJW under water (from sig comp): Quote Link to comment Share on other sites More sharing options...
MJW Posted June 28, 2015 Author Share Posted June 28, 2015 (edited) Golden "Birthday" (sorry it's so tall): Edited June 28, 2015 by MJW 1 Quote Link to comment Share on other sites More sharing options...
MJW Posted June 29, 2015 Author Share Posted June 29, 2015 Some advice for blurring text. If you want rounded text, just applying the blur will likely produce text edges that won't be crisp enough. Instead (starting with white text on a black background), first apply a few pixel-width blur. Then select the black area with the Magic Wand. Use Global mode and zero Tolerance so only the absolute black is selected. Invert the selection so the text is selected. Now apply a larger blur. I think that it perhaps works better to consecutively apply several smaller blurs to produce the larger blur. Once the text is sufficiently blurred, Deselect and perhaps apply another blur of a few pixels to smooth the edge transition. Gaussian blur is the standard blur, but other blurs also work well. Applying a 45° Motion Blur followed by a 135° (-45°) Motion Blur seem to produce a good effect. Quote Link to comment Share on other sites More sharing options...
Maximilian Posted June 29, 2015 Share Posted June 29, 2015 Really nice pieces by everyone. Liking everything seen so far! I'll be posting a couple of my quick tests later today, but in the meantime I wanted to add to this thread my thanks for the tailor-made alternative source code, comments, and suggestions and also the 3.5.11 version of the plugin I compiled, should anyone else want it. Texture Shader 1.0 for PdN 3.5.11.zip 1 2 Quote Link to comment Share on other sites More sharing options...
AgentGoodspeed Posted June 29, 2015 Share Posted June 29, 2015 MJW, that makes a lot of sense. Thanks!I guess my problem was that I was working only with text on an otherwise empty layer. But using an entire image really showed me what I was missing. So now I'm off to experiment Quote Link to comment Share on other sites More sharing options...
Maximilian Posted June 30, 2015 Share Posted June 30, 2015 (edited) Photo carved on a concrete surface: My avatar eagle sketched on a concrete surface with black chalk, or something like that (original eagle is a pencil sketch scanned and edited with PdN): My avatar eagle carved on concrete (same concrete texture as above): Edited July 11, 2022 by Maximilian 7 Quote Link to comment Share on other sites More sharing options...
Seerose Posted July 8, 2015 Share Posted July 8, 2015 MJW! Thanks for the beautiful plugin. My final product: 4 Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi Link to comment Share on other sites More sharing options...
Pixey Posted March 5, 2016 Share Posted March 5, 2016 I only just got around to trying this out. A very neat Plugin @MJW - thank you. 3 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...
MJW Posted March 7, 2016 Author Share Posted March 7, 2016 Thank you, Pixey! I am, I immodestly admit, quite fond of the Texture Shader, and am always pleased to see more people using it, in spite of its somewhat intimidating number of controls. 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.