User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
textures:perfect_detail_maps [2006-03-31 22:02]
Carsten created
textures:perfect_detail_maps [2013-01-07 12:07] (current)
Line 1: Line 1:
 ====== Making "​perfect"​ Detail-Maps ====== ====== Making "​perfect"​ Detail-Maps ======
- 
-\\ 
  
 ===== The Problem ===== ===== The Problem =====
Line 11: Line 9:
 Getting 1. right is the task of the artist, and is easily done in any paint program that supports contrast and brightness adjustments and histogram views. Getting 1. right is the task of the artist, and is easily done in any paint program that supports contrast and brightness adjustments and histogram views.
  
-Getting 2. right is more difficult if not impossible for the artist. For example, I started with the original detail map show at the right (click to enlarge). Observe that this detail-map has a big dark spot roughly in the mid of the right half. <​clear>​+Getting 2. right is more difficult if not impossible for the artist. For example, I started with the original detail map shown at the right (click to enlarge). Observe that this detail-map has a big dark spot roughly in the mid of the right half. <​clear>​
  
-{{ textures:​perfectdetailmap-originalscreen.jpg?​200x200}} This screenshot shows the effect of applying ​this detail-maps to a large terrain. Note the well-visible pattern both on the near ground as well as on the far rocks. This strong pattern is caused by the non-balancedness of the detail texture.+{{ textures:​perfectdetailmap-originalscreen.jpg?​200x200}} This screenshot shows the effect of applying ​the detail-map to a large terrain. Note the well-visible pattern both on the near ground as well as on the far rocks. This strong pattern is caused by the non-balancedness of the detail texture.
  
  
Line 26: Line 24:
 ===== The Solution ===== ===== The Solution =====
  
-First, observe that E is easily found by blurring a copy of D! Any paint program can easily do that! I used The Gimp to apply a Gaussian blur filter to the detail map, creating test images with filter widths of 5, 20, 40 and 60 pixels respectively. The left image below shows my so obtained "​E",​ which is the original detail-map blurred with a 60 pixel width Gauss filter!+First, observe that E is easily found by blurring a copy of D! Any paint program can easily do that! I used The Gimp to apply a Gaussian blur filter to the detail map, creating test images with filter widths of 5, 20, 40 and 60 pixels respectively. The left image below shows my so obtained "​E",​ which is the original detail-map blurred with a 60 pixels ​width Gauss filter!
  
 The next problem is that computing the above D - E + 128 has a tendency to produce intermediate values that are less than 0 or greater than 255. The next problem is that computing the above D - E + 128 has a tendency to produce intermediate values that are less than 0 or greater than 255.
 Therefore, this operation can **not** be done with layer techniques in PhotoShop, PaintShop, Gimp, etc.! Therefore, this operation can **not** be done with layer techniques in PhotoShop, PaintShop, Gimp, etc.!
  
-In order to get correct results easily, I just wrote a small C++ program that reads E and D from disk, computes D - E + 128, +In order to get correct results easily, I just wrote a small C++ program that reads E and D from two images files on disk, computes D - E + 128, and writes the result back into a third file.
-and writes the result back to disk into a third file.+
 Please send me an email if you're interested in the exe file for Windows! Please send me an email if you're interested in the exe file for Windows!
  
-And yes, that's all!  I applied my program to the above detail-map D and it'​s ​blurred version ​E (left image below). The center image below shows the result. //Notice how beautifully the dark spot is gone!// In the right image you see a screenshot of the same scene as above, ​not now with the new detail-map applied. Note that the pattern is (almost) entirely gone! +And yes, that's all!  I applied my program to the above detail-map D and it'​s ​error-map ​E (left image below). The center image below shows the result. //Notice how beautifully the dark spot is gone!// In the right image you see a screenshot of the same scene as above, now with the new detail-map ​being applied. Note that the pattern is (almost) entirely gone! 
-Also please ​not that you now see another ​"​pattern"​ at the mountains -- this is a not-so-good base texture that is showing now that the broken pattern of the detail-map ​is fixed. This is not related to the detail-map ​though, and is just fixed by using a better base texture.+ 
 +Also please ​note that now you see a new "​pattern"​ at the mountains -- this is the result of a not-so-good base texture that is showing ​up now that the broken pattern of the detail-map ​has been fixed and does not any longer distract from it. This matter ​is not related to detail-map ​issues, and is just fixed by using a better base texture.
  
 {{textures:​perfectdetailmap-blurred60.png?​200x200}} {{textures:​perfectdetailmap-result60.png?​200x200}} {{textures:​perfectdetailmap-result60screen.jpg?​200x200}} {{textures:​perfectdetailmap-blurred60.png?​200x200}} {{textures:​perfectdetailmap-result60.png?​200x200}} {{textures:​perfectdetailmap-result60screen.jpg?​200x200}}
Line 43: Line 41:
 =====Discussion and Results===== =====Discussion and Results=====
  
-One open question is how much D should be blurred in order to obtain E. This is easily answered: As much as possible! In the above text, I used a blur filter of 60 pixels width, and the pattern as (almost) completely gone. Using smaller filter sizes reduces the rests even further. Blurring not at all obviously yields the 128 planar detail map that has no visual impact at all.+One open question is how much D should be blurred in order to obtain E. This is easily answered: As much as possible! In the above example, I used a blur filter of 60 pixels width, and the pattern as (almost) completely gone. 
 +Using smaller filter sizes reduces the rests even further. ​For example, I also made tests with blur filters of 5, 20 and 40 pixels width. The smaller the filter kernel width was, the more homogeneous became the end result. (Blurring not at all obviously yields the 128 planar detail map (because then E=D, and D-D+128 = 128) and has no visual impact at all!) 
 + 
 +Therefore, the recommended strategy is to start with a really big amount of blurring, and only reduce it if that amount was not sufficient to remove the most significant non-balancedness of the original detail-map. 
 + 
 + 
 +===== High-Pass Filters in PhotoShop =====
  
 +After I had completed this article, Kai sent me a link to this Gamasutra site: http://​www.gamasutra.com/​features/​20010523/​hajba_01.htm
 +It deals with the same problem and is a lot more detailed than this text -- definitively a recommended read!
 +As the solution, High-Pass Filters are presented which achieve exactly the same results and which are -- contrary to my above statements -- well built into PhotoShop and possibly other paint programs, too. So if you're a dedicated user of your favourite paint program, you'll probably want to give the built-in high-pass filter a try before trying my home-grown solution. ​ ;-)
textures/perfect_detail_maps.1143835375.txt.gz · Last modified: 2013-01-07 12:07 (external edit)