Sign in to follow this  
MJW

Texture Smoother

Recommended Posts

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:

 

TextureSmootherUI.png

 

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:

earringtexture.png

 

Here is the shaded texture:

earringshaded.png

As is obvious, the shaded version has waterline anomalies.

 

Here is the smoothed texture (which required, I believe, 200 smoothing cycles):

earringtexturesmoothed.png

Here is the shaded version:

earringsmoothedshaded.png

 

Here is a (low-roughness) Cloud image shaded with the Texture Shader:

cloudsshaded.png

 

Here is the same texture after smoothing (about 25 smoothing passes):

cloudssmoothedshaded.png

 

 

 

  • Upvote 5

Share this post


Link to post
Share on other sites

i was on way to share another TextureShader Map and i sew this.

and i come to this point before:

BLUE_MAP_EX1140x547_Sign.png

 

and after 1 smooth i getting this:

 

BLUE_MAP_EX1140x547_Sign_BW.png

 

 

 

I can't get the blue color for some reason  :roll:

 

Edited by Shochi

Share this post


Link to post
Share on other sites

Shochi, I'm not sure why you're not getting the blue color, but I'm pretty sure it's not the Texture Smoother. Perhaps you're trying to use the Texture Smoother to actually draw the shaded image, which is not what it's intended for. The only reason it does any shading is to let you evaluate how well the height map has been smoothed.

 

Or perhaps you're running the new version of the Texture Shader, and you didn't change the Image source to Clipboard. In the previous version, Clipboard was the default, but in the new version I changed it to White so that the Texture Shader would give a result even if there was no clipboard image.

 

Or maybe you're trying to smooth the already-shaded image. That's the wrong order of doing it. You need to: 1) create a black-and-white height map (often done by making a black-and white image, then applying blurs to make the sides slope); 2) run the Texture Smoother to smooth the height map (making sure to disable "Show Shading" before exiting!) ; 3) shade the smoothed height map with the Texture Shader.

 

One thing I'll add is that for the type of height map in your image, which has a relatively flat texture, the Texture Smoother won't give you much advantage, if any. That type of texture works fine as-is with the Texture Shader. The Texture Smoother is intended for "tall" height maps, like the ones in my examples. As a general rule, smoothing the texture won't be necessary unless the Texture Shader's "Texture Height" control is quite high. Or more simply, try the texture without smoothing, and if it has no problems, don't smooth it.

Share this post


Link to post
Share on other sites

just to be sure i start new map for the example:

 

1)here is the black and white original:

Untitle90.png

 

2)here is the Texture shaded clipboard:

 

untitle200.png

 

3) but after 1 smooth i am getting this:

untitle300.png

 

how it can be ?:/

 

Share this post


Link to post
Share on other sites

The smoothing should be done on the texture, not the shaded image. In your example, the Texture Smoother is treating the shaded image as a height map and smoothing it to produce a 24-bit height map (hence the odd colors). Run it on the original black-and-white image instead.

 

I also suggest you might want to run a small blur on the original texture first. Something like a 2-pixel Gaussian blur. I think it may produce a more interesting shaded image. (As I mentioned previously, I'm not sure that height map will gain much by being smoothed.)

Share this post


Link to post
Share on other sites

Yes. The Texture Smoother is for smoothing the height map, not the final image. I think you may want to move the position of the directional light in the Texture Shader. Making the light come from the upper-left generally works well. Or at least I like it.

Share this post


Link to post
Share on other sites

Because the original is on the background of gradient black and white, and the white is from up-right, i can't.

I tried to play the directional scale but i didn't change the direction.

Share this post


Link to post
Share on other sites
11 minutes ago, MJW said:

That really looks like it was stamped out of metal, Eli! I particularly like the indented border.

I used Toe_head2001's Inset Box Shadow effect to make the border and give it a 3D look.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this