# $p0 - Amount (0-100) of the effect

&rfx_sendmsg (
  qq{        
    (let* ((input-file (string-append "$curtmpdir" DIR-SEPARATOR "$in"))
           (image (car (gimp-file-load RUN-NONINTERACTIVE input-file input-file)))
           (layer (car (gimp-image-get-active-layer image))) )
      (gimp-image-undo-disable image)
      (let ((red-matte (car (gimp-layer-copy layer TRUE)))
            (green-matte (car (gimp-layer-copy layer TRUE)))
            (blue-matte (car (gimp-layer-copy layer TRUE)))
            (technicolor-layer 0) )
        (gimp-image-add-layer image red-matte 0)   
        (plug-in-colors-channel-mixer RUN-NONINTERACTIVE
                                    image
                                    red-matte
                                    FALSE
                                     1.0 -0.5 -0.5
                                     1.0 -0.5 -0.5
                                     1.0 -0.5 -0.5 )
        (gimp-invert red-matte)
        (gimp-image-add-layer image green-matte -1)
        (plug-in-colors-channel-mixer RUN-NONINTERACTIVE
                                      image
                                      green-matte
                                      FALSE
                                      -0.5  1.0 -0.5
                                      -0.5  1.0 -0.5
                                      -0.5  1.0 -0.5 )
        (gimp-invert green-matte)
        (gimp-image-add-layer image blue-matte -1)
        (plug-in-colors-channel-mixer RUN-NONINTERACTIVE
                                      image
                                      blue-matte
                                      FALSE
                                      -0.5 -0.5  1.0
                                      -0.5 -0.5  1.0
                                      -0.5 -0.5  1.0 )
        (gimp-invert blue-matte)
        (let* ((red   (multiply-layers image (list layer green-matte blue-matte)))
               (green (multiply-layers image (list layer red-matte   blue-matte)))
               (blue  (multiply-layers image (list layer red-matte   green-matte))) )
          (plug-in-colors-channel-mixer RUN-NONINTERACTIVE
                                        image
                                        red
                                        FALSE
                                         1.0  0.0  0.0
                                         0.0  0.0  0.0
                                         0.0  0.0  0.0 )
          (plug-in-colors-channel-mixer RUN-NONINTERACTIVE
                                        image
                                        green
                                        FALSE
                                         0.0  0.0  0.0
                                         0.0  1.0  0.0
                                         0.0  0.0  0.0 )
          (gimp-layer-set-mode green ADDITION-MODE)
          (gimp-image-merge-down image green EXPAND-AS-NECESSARY)
          (plug-in-colors-channel-mixer RUN-NONINTERACTIVE
                                        image
                                        blue
                                        FALSE
                                         0.0  0.0  0.0
                                         0.0  0.0  0.0
                                         0.0  0.0  1.0 )
          (gimp-layer-set-mode blue ADDITION-MODE)
          (set! technicolor-layer (car (gimp-image-merge-down image blue EXPAND-AS-NECESSARY)))
          )
        (gimp-image-remove-layer image red-matte)
        (gimp-image-remove-layer image green-matte)
        (gimp-image-remove-layer image blue-matte)
        (gimp-layer-set-opacity technicolor-layer $p0)
        (gimp-image-merge-down image technicolor-layer EXPAND-AS-NECESSARY)
        )
      (rfx-save-frame image "$out") 
      )
    }
  );
