MJW Posted September 9, 2016 Share Posted September 9, 2016 (edited) Height maps, as used by my Texture Shader plugin, are typically black and white images, where the height corresponds to the intensity. Because there are only 256 intensity levels, the height maps are low precision, which often results in image problems, such as wavy "waterlines." The Texture Shader actually supports 24 bit precision, where the depth is represented by the concatenated red, green, and blue channels. Unfortunately, producing the 24-bit height maps isn't easy. That's the purpose of the Texture Smoother. The Texture Smoother attempts to smooth black-and-white height maps into 24-bit height maps. The method is called "Laplacian smoothing," which amounts to repeatedly replacing each depth with a weighted average of the depths in the immediate neighborhood. The plugin joins the Texture Shader in the "Effects>Height Map" submenu. Here is the plugin: TextureSmoother.zip Here is the user interface: As the Help menu says: Texture Smoother smooths a 24-bit height map. Typically, the height map will be originally produced as a gray-scale map, with black pixels representing the lowest values and white pixels the highest. Because there are only 256 different values, the height map is low precision. Texture Smoother applies a smoothing algorithm which modifies each pixel based on nearby pixels. The result is a full-precision 24-bit height map. The controls are: Repetitions: Specifies the number of smoothing passes to perform each time the Smooth Texture button is pressed. Increasing the number of repetitions make the texture smoother, but less like the original texture. Smooth Texture: Initiates the number of smoothing passes specified by Repetitions. Because the texture is not reset when the button is pressed, the button can be repeatedly pressed until the desired smoothness is achieved. Reset Texture: Resets the texture to its initial state. Treat Transparent Pixels as Far (Resets texture if changed): Specifies that all transparent pixels are to be treated as if the 24-bit texture value is zero. If this option isn't selected, the actual pixel values are used. Changing the state of this option resets the texture to its initial state. Don't Move Far Pixels: Specifies that zero-valued pixels are to remain unchanged. This option can be used to prevent smoothing the edge where an object intersects the far plane. The option can be enabled or disabled at any time. This allows a small amount of edge smoothing by performing most, but not all, of the smoothing with the option enabled. Show Shading (Disable before exiting): Specifies that instead of showing the smoothed texture as a colored image (which is usually not too meaningful), the shaded texture should be shown. To preserve the actual texture for later use, this option must be disabled before exiting. All the controls that follow are used only to control shading, and have no effect of the smoothed texture. Show All Pixels as Opaque: The transparency of shaded pixels is normally determined by their alpha values. When this option is enabled, all pixels are shown as opaque. Texture Height Scale: Increases or decreases the texture height. Ambient Light Intensity: Increases or decreases the intensity of the Ambient Light. Ambient light affects every pixel identically, independent of the gradient. Directional Light Direction: 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. (The control's outer ring currently has no function.) 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. The user interface is slightly unusual in that pressing the Smooth button doesn't start from the beginning image, but instead from the currently smoothed version. I do this because the amount of smoothing required to produce the desired degree of smoothing is quite unpredictable, and over-smoothing can eliminate details. This method allows the user to progressively smooth the texture to the preferred extent. One very inconvenient feature is that in order to judge the smoothing, the Show Shading option must be enabled; but if the option isn't disabled before exiting the plugin, the result will be the shaded texture, not the texture. Unfortunately, there's currently no (allowed) solution to problem, though there may be in the future. If there is, I'll happily change the plugin to use it. The Don't Move Far Pixels option is useful for preventing textures, such as the earring texture below, from spreading out. It can sometimes -- or even often -- produce some undesirable wrinkling at the edge, where the object meets the far background. It often helps to first run a few passes with the option disabled, to smooth the edge boundary. The Treat Transparent Pixels as Far is very useful when the far background is transparent. Most often transparency is represented by "transparent white," which will likely cause problems if this option isn't enabled. I'll show a couple of examples. First a texture intended to represent a gold earring. Here is the original texture: Here is the shaded texture: As is obvious, the shaded version has waterline anomalies. Here is the smoothed texture (which required, I believe, 200 smoothing cycles): Here is the shaded version: Here is a (low-roughness) Cloud image shaded with the Texture Shader: Here is the same texture after smoothing (about 25 smoothing passes): Edited July 11, 2018 by toe_head2001 Fixed broken Postimg images 5 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.