Blend modes with translucency - odd behavior
Leland
Global Mapper User
I'm having some frustration using blend modes, specifically the "Multiple" blend mode with translucency. I'm hesitant to say the computation is "wrong," since it's not exactly intuitive to define what Multiple should mean with a translucent overlay (more on this below). But I think we can agree that the blend mode should at least have the following properties:
1. When the translucency of the top layer = 100% (totally opaque), we know what Multiple should do. The result is formed from the product of the color values, and is always at least as dark as either layer. Overlaying black produces black, overlaying white produces the base layer unaltered, and overlaying gray darkens the base layer. This all works correctly.
2. When the translucency of the top layer = 0% (totally transparent), the bottom layer should show through unaltered. This works correctly.
3. The result should change gradually with translucency, so that a small change in translucency always produces a small change in the result. So 99% translucent (almost opaque) should be almost the same as 100% (opaque); this works correctly. And 1% translucent should be almost the same as 0% (transparent). This does NOT work - there's a significant difference between 0% and 1%.
4. Since Multiple always darkens, then as we make the top layer more transparent, it has less influence and so the result should get somewhat lighter. At least, making it more transparent should never make the result darker. This does NOT work - making the top layer more transparent sometimes darkens the result!
These issues are subtle, but they're preventing me from getting the results I'm trying to achieve with overlaying layers. I tend to get images that are darker (or more saturated?) than I expect, and I haven't been able to produce the effect I want using translucency.
As I said, it's not obvious what a Multiple blend should mean when combined with translucency (except that it should probably have the properties above). But the World Wide Web Consortium has a document explaining their interpretation of it, complete with equations: http://dev.w3.org/SVG/modules/compositing/master/SVGCompositingPrimer.html. Their idea is simple, satisfies the 4 properties, and even lends itself to a way of understanding it intuitively. My own explanation of it is this: Imagine each pixel is composed of tiny subpixels - call them "grains." Then if a layer is 60% opaque (40% transparent), we compute the normal (opaque) blending for that pixel, and 60% of the grains use that value, while 40% are transparent and let the base color show through. So the final result is a weighted average of 60% of the fully-blended result and 40% of the base layer. (If you're combining two layers that are both semi-transparent it's a bit more complicated, but it follows from similar logic.)
I've attached some files with test patterns to illustrate the problems. Here are the steps to use them:
1. Load the file "test_elev.flt". Choose Global Shader, and disable hill shading. You should see a range of colors from reddish brown at the top to green at the bottom.
2. Load the file "test_gray.bsq". You should see vertical bands of black, gray, and white covering the left part of the map.
3. Open Control Center, select test_gray.bsq and Options.
4. Set the Blend Mode to Multiple and click Apply. As expected, the black band is still black, the gray band shows the base colors but darker, and the white band is totally transparent, showing the base colors.
5. Slide the Translucency bar to Transparent (0%) and Apply. As expected, the top layer disappears, showing only the base colors layer.
6. Slide the Translucency bar just slightly, to 0.8% and Apply. The entire left side of the map is noticeable darker - especially in the reds and greens, less so in the yellow area. The effect is different than in the gray band with opaque Multiple (from step 4).
7. Slide the Translucency back to Opaque (100%) and Apply, then try successively lower Translucency values (75%, 50%, 25%). Notice that the third band (where the top layer is white) becomes darker each time as the slider is moved toward transparent. In particular, notice that when the slider is all the way to 0% or 100% this band is transparent, but anywhere between 0% and 100% it's darker, to varying degrees.
I hope you'll agree that this behavior is not desirable.
I realize that changing the blend mode behavior could annoy current users by changing the look of their existing maps. If this is of concern, I hope you'll consider, for instance, adding a check box for "use old blend method," in order to make us all happy :-)
Thanks for taking the time to look into this.
-- Leland
1. When the translucency of the top layer = 100% (totally opaque), we know what Multiple should do. The result is formed from the product of the color values, and is always at least as dark as either layer. Overlaying black produces black, overlaying white produces the base layer unaltered, and overlaying gray darkens the base layer. This all works correctly.
2. When the translucency of the top layer = 0% (totally transparent), the bottom layer should show through unaltered. This works correctly.
3. The result should change gradually with translucency, so that a small change in translucency always produces a small change in the result. So 99% translucent (almost opaque) should be almost the same as 100% (opaque); this works correctly. And 1% translucent should be almost the same as 0% (transparent). This does NOT work - there's a significant difference between 0% and 1%.
4. Since Multiple always darkens, then as we make the top layer more transparent, it has less influence and so the result should get somewhat lighter. At least, making it more transparent should never make the result darker. This does NOT work - making the top layer more transparent sometimes darkens the result!
These issues are subtle, but they're preventing me from getting the results I'm trying to achieve with overlaying layers. I tend to get images that are darker (or more saturated?) than I expect, and I haven't been able to produce the effect I want using translucency.
As I said, it's not obvious what a Multiple blend should mean when combined with translucency (except that it should probably have the properties above). But the World Wide Web Consortium has a document explaining their interpretation of it, complete with equations: http://dev.w3.org/SVG/modules/compositing/master/SVGCompositingPrimer.html. Their idea is simple, satisfies the 4 properties, and even lends itself to a way of understanding it intuitively. My own explanation of it is this: Imagine each pixel is composed of tiny subpixels - call them "grains." Then if a layer is 60% opaque (40% transparent), we compute the normal (opaque) blending for that pixel, and 60% of the grains use that value, while 40% are transparent and let the base color show through. So the final result is a weighted average of 60% of the fully-blended result and 40% of the base layer. (If you're combining two layers that are both semi-transparent it's a bit more complicated, but it follows from similar logic.)
I've attached some files with test patterns to illustrate the problems. Here are the steps to use them:
1. Load the file "test_elev.flt". Choose Global Shader, and disable hill shading. You should see a range of colors from reddish brown at the top to green at the bottom.
2. Load the file "test_gray.bsq". You should see vertical bands of black, gray, and white covering the left part of the map.
3. Open Control Center, select test_gray.bsq and Options.
4. Set the Blend Mode to Multiple and click Apply. As expected, the black band is still black, the gray band shows the base colors but darker, and the white band is totally transparent, showing the base colors.
5. Slide the Translucency bar to Transparent (0%) and Apply. As expected, the top layer disappears, showing only the base colors layer.
6. Slide the Translucency bar just slightly, to 0.8% and Apply. The entire left side of the map is noticeable darker - especially in the reds and greens, less so in the yellow area. The effect is different than in the gray band with opaque Multiple (from step 4).
7. Slide the Translucency back to Opaque (100%) and Apply, then try successively lower Translucency values (75%, 50%, 25%). Notice that the third band (where the top layer is white) becomes darker each time as the slider is moved toward transparent. In particular, notice that when the slider is all the way to 0% or 100% this band is transparent, but anywhere between 0% and 100% it's darker, to varying degrees.
I hope you'll agree that this behavior is not desirable.
I realize that changing the blend mode behavior could annoy current users by changing the look of their existing maps. If this is of concern, I hope you'll consider, for instance, adding a check box for "use old blend method," in order to make us all happy :-)
Thanks for taking the time to look into this.
-- Leland
Comments
-
Leland,
I agree things get somewhat confusing when dealing with multiple kinds of layer combination, like blend modes and translucency. I have updated the rendering so if the multiple blend mode is used then blending is done first, then translucency applied to that, rather than the reverse order, which then generates what you want. I have placed a new build at http://www.globalmapper.com/global_mapper12.zip with the change for you to try. Simply download that file and extract the contents into your existing v12.xx installation folder to give it a try. If you are using the 64-bit v12 version there is a new build at http://www.globalmapper.com/global_mapper12_64bit.zip .
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
Fantastic! The new version produces exactly the effect I was looking for. Thanks again for your prompt response! You're awesome.
I have one more minor issue left, which I'll post in another thread.
Also I'm wondering, what is your time scale for merging these kinds of changes into version 13? (I currently only have version 12, but I'm thinking of upgrading to the beta version.)
-- Leland -
Leland,
These changes are in v13 as well, so all future v13 builds will have them. The official v13 release will likely be early next week.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com
Categories
- 12.9K All Categories
- 5.8K Features Discussion
- 349 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 651 GM Script Language
- 55 User Scripts
- 115 GPS Features
- 420 Projection Questions
- 834 Raster Data
- 1.4K Vector Data
- 6.6K Support
- 181 Announcement and News
- 934 Bug Report
- 561 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 578 Other Discussion
- 132 GIS Data Sources
- 27 Global Mapper Showcase
- 244 How I use Global Mapper
- 109 Global Mapper Forum Website
