Ticket #157 (closed enhancement: fixed)

Opened 21 months ago

Last modified 17 months ago

Add transfer mode & opacity to RasterSymbolizer

Reported by: migurski Owned by: artem
Priority: normal Milestone: 0.6.0
Component: Raster Input Driver Version: 0.5.1
Severity: Normal Keywords:
Cc: numenor@…, cmarqu Patch Needs Improvement: no
Needs Docmentation: no Has Patch?: no
Design Decision Needed: no

Description

wiki:RasterSymbolizer would be more useful if it were possible to apply raster images with a transfer mode similar to those found in Photoshop. Currently, images are opaque, and can only be tinted by layering translucent polygons over them. For applications like hill shading it's desirable for there to be more interaction between the raster image and rendered mapnik cartography underneath. Attached is a number of example files showing the four transfer modes that are especially relevant here: multiply, screen, hard light, linear light, and luminosity.

Multiply darkens a base image, by multiplying together each pixel with white = 1.0 and black = 0.0. Where the overlaid image is white, there is no change to the base image. Where the overlaid image is black, the output image is also black.

Screen lightens a base image, and is the opposite of multiply. Where the overlaid image is black, there is no change to the base image. Where the overlaid image is white, the output image is also white.

Hard Light is a combination of screen and multiply. Where the overlaid image is 50% gray, there is no change to the base image. Where the overlaid image is white, the output image is also white. Where the overlaid image is black, the output image is also black.

Linear Light is similar to hard light, but the grays are handled slightly differently, added together instead of multiplied. The visual effect is like a harsher hard light.

Luminosity replaces the lightness values of the base image entirely with those of the overlaid image. Only hue and saturation remain from the base image.

Attachments

multiply.100.jpg (17.5 kB) - added by migurski 21 months ago.
SImple gradients showing multiply transfer at 100% opacity
multiply.30.jpg (17.8 kB) - added by migurski 21 months ago.
Simple gradients showing multiply transfer at 30% opacity
screen.100.jpg (17.5 kB) - added by migurski 21 months ago.
Simple gradients showing screen transfer at 100% opacity
screen.30.jpg (17.8 kB) - added by migurski 21 months ago.
Simple gradients showing screen transfer at 30% opacity
hardlight.100.jpg (18.0 kB) - added by migurski 21 months ago.
Simple gradients showing hard light transfer at 100% opacity
hardlight.30.jpg (18.0 kB) - added by migurski 21 months ago.
Simple gradients showing hard light transfer at 30% opacity
linearlight.100.jpg (18.1 kB) - added by migurski 21 months ago.
Simple gradients showing linear light transfer at 100% opacity
linearlight.30.jpg (19.0 kB) - added by migurski 21 months ago.
Simple gradients showing linear light transfer at 30% opacity
luminosity.100.jpg (17.0 kB) - added by migurski 21 months ago.
Simple gradients showing luminosity transfer at 100% opacity
luminosity.30.jpg (18.8 kB) - added by migurski 21 months ago.
Simple gradients showing luminosity transfer at 30% opacity
multiply.100.2.jpg (102.0 kB) - added by migurski 21 months ago.
Map and hills showing multiply transfer at 100% opacity
multiply.30.2.jpg (84.9 kB) - added by migurski 21 months ago.
Map and hills showing multiply transfer at 30% opacity
screen.100.2.jpg (70.5 kB) - added by migurski 21 months ago.
Map and hills showing screen transfer at 100% opacity
screen.30.2.jpg (61.9 kB) - added by migurski 21 months ago.
Map and hills showing screen transfer at 30% opacity
hardlight.100.2.jpg (73.2 kB) - added by migurski 21 months ago.
Map and hills showing hard light transfer at 100% opacity
hardlight.30.2.jpg (60.3 kB) - added by migurski 21 months ago.
Map and hills showing hard light transfer at 30% opacity
luminosity.100.2.jpg (68.2 kB) - added by migurski 21 months ago.
Map and hills showing luminosity transfer at 100% opacity
luminosity.30.2.jpg (58.3 kB) - added by migurski 21 months ago.
Map and hills showing linear light transfer at 30% opacity
linearlight.100.2.jpg (80.1 kB) - added by migurski 21 months ago.
Map and hills showing linear light transfer at 100% opacity
linearlight.30.2.jpg (64.0 kB) - added by migurski 21 months ago.
Map and hills showing linear light transfer at 30% opacity

Change History

Changed 21 months ago by migurski

SImple gradients showing multiply transfer at 100% opacity

Changed 21 months ago by migurski

Simple gradients showing multiply transfer at 30% opacity

Changed 21 months ago by migurski

Simple gradients showing screen transfer at 100% opacity

Changed 21 months ago by migurski

Simple gradients showing screen transfer at 30% opacity

Changed 21 months ago by migurski

Simple gradients showing hard light transfer at 100% opacity

Changed 21 months ago by migurski

Simple gradients showing hard light transfer at 30% opacity

Changed 21 months ago by migurski

Simple gradients showing linear light transfer at 100% opacity

Changed 21 months ago by migurski

Simple gradients showing linear light transfer at 30% opacity

Changed 21 months ago by migurski

Simple gradients showing luminosity transfer at 100% opacity

Changed 21 months ago by migurski

Simple gradients showing luminosity transfer at 30% opacity

Changed 21 months ago by migurski

Map and hills showing multiply transfer at 100% opacity

Changed 21 months ago by migurski

Map and hills showing multiply transfer at 30% opacity

Changed 21 months ago by migurski

Map and hills showing screen transfer at 100% opacity

Changed 21 months ago by migurski

Map and hills showing screen transfer at 30% opacity

Changed 21 months ago by migurski

Map and hills showing hard light transfer at 100% opacity

Changed 21 months ago by migurski

Map and hills showing hard light transfer at 30% opacity

Changed 21 months ago by migurski

Map and hills showing luminosity transfer at 100% opacity

Changed 21 months ago by migurski

Map and hills showing linear light transfer at 30% opacity

Changed 21 months ago by migurski

Map and hills showing linear light transfer at 100% opacity

Changed 21 months ago by migurski

Map and hills showing linear light transfer at 30% opacity

Changed 21 months ago by migurski

Calculating some of the effects above, for black=0.0, white=1.0, foreground=fg, background=bg, output=out:

  • Multiply out = bg * fg
  • Screen out = 1 - ((1 - bg) * (1 - fg))
  • Linear light out = bg + (2 * fg) - 1, clipped to (0 ... 1)
  • Hard light where fg < .5: out = bg * 2 * fg; where fg >= .5: out = 1 - ((1 - bg) * 2 * (1 - fg))

Changed 20 months ago by springmeyer

  • milestone set to 0.6.0

Changed 20 months ago by numenor

  • cc numenor@… added

Changed 20 months ago by cmarqu

  • cc cmarqu added

Changed 17 months ago by artem

  • status changed from new to closed
  • resolution set to fixed

Marcin Rudowski's patch applied in r1027 adds support for opacity and compositing modes in RasterSymbolizer. See #259 for more details.

Currently supported modes are:

  • grain_merge
  • grain_merge2
  • multiply
  • multiply2
  • divide
  • divide2
  • screen
  • hard_light

TODO:

  • Add support for other modes.
  • Normalise naming to be compatible with SVG 1.2 spec ?
  • Consider more generic implementation (agg) ?

Note: See TracTickets for help on using tickets.