GIMP Spherical Mapper Helper Script

Fencepost52Fencepost52 Posts: 498
edited February 2015 in Bryce Discussion

I'm not sure how much use this script will be to anyone, but I thought I'd make it available to any GIMP users that want to convert textures to spherically mapped textures as described by David Brinnen here:

Setup for SM Texture Capture Cubic, Using the Texture Capture Cubic Setup Example, Spherical Mapper, Practical Bryce Volume 1

Unlike Paint Shop Pro that David uses, the various GIMP/Photoshop plugins that GIMP can use, do not map the images properly. This script solves that problem. Essentially, the spherical mapper needs an additional two images to be mapped as top/bottom kaleidoscopes in order to work correctly. The example image shows the problem with the tiling, with the cube/sphere on left being un-tiled, and the cube/sphere on the right being tiled properly using spherical mapping mode.

Copy the code below into a text document and save it to your GIMP scripts folder with a ".scm" extension in the path similar to this: C:\Users\user_name\.gimp-2.8\scripts (Not sure why the script code is colored).

Open the desired image in GIMP and go to Filters > Render > Kaleidoscope SM and the script will create the top and bottom images needed. Export the images and apply them to the top and bottom cubes, respectively as described in David's tutorials. Render the spherically mapped image and your image can now be seamlessly spherically mapped to your object.

Let me know if you have any questions or issues with the script.

; Uses image to creates a top/bottom kaleidoscope for the ; purpose of spherical mapping textures as described in David; Brinnen's tutorials here: ; <a href="; <a href="; <a href="http://www.daz3d.com/practical-bryce-7-1-pro-volume-1">http://www.daz3d.com/practical-bryce-7-1-pro-volume-1</a>;; <a href="http://www.daz3d.com/bryce-7-pro-spherical-mapper">http://www.daz3d.com/bryce-7-pro-spherical-mapper</a>;(define (kaleidoscope-sm image drw)  (let* (        (*points* (cons-array 6 'double))        (originalLayer (car (gimp-image-get-active-layer     image)))    (copyLayer 0)  (top 0)  (bottom 0)    (width (car (gimp-drawable-width originalLayer)))         (height (car (gimp-drawable-height originalLayer)))    (cX (/ width 2))    (cY (/ height 2))     )(gimp-undo-push-group-start image)(gimp-layer-add-alpha originalLayer)(gimp-selection-none image)(set! top (car (gimp-layer-copy originalLayer TRUE)))(set! bottom (car (gimp-layer-copy originalLayer TRUE)))(gimp-item-set-name originalLayer "Original"); Create the bottom image(aset *points* 0 0)(aset *points* 1 height)(aset *points* 2 cX)(aset *points* 3 cY)(aset *points* 4 width)(aset *points* 5 height)(gimp-image-add-layer image bottom -1)(gimp-item-set-name bottom "Bottom")(set! copyLayer (car (gimp-layer-copy bottom TRUE)))(gimp-image-add-layer image copyLayer -1)(gimp-free-select image 6 *points* CHANNEL-OP-ADD TRUE FALSE 0)(gimp-selection-grow image 1)(gimp-selection-invert image)(gimp-edit-clear copyLayer)(gimp-selection-none image)(gimp-item-transform-rotate copyLayer (/ *pi* -2) 1 cX cY)(gimp-item-transform-flip-simple copyLayer 1 1 0)(set! copyLayer (car (gimp-layer-copy copyLayer TRUE)))(gimp-image-add-layer image copyLayer -1)(gimp-item-transform-rotate copyLayer (/ *pi* -2) 1 cX cY)(gimp-item-transform-flip-simple copyLayer 0 1 0)(set! copyLayer (car (gimp-layer-copy copyLayer TRUE)))(gimp-image-add-layer image copyLayer -1)(gimp-item-transform-rotate copyLayer (/ *pi* -2) 1 cX cY)(gimp-item-transform-flip-simple copyLayer 1 1 0)(gimp-image-merge-down image copyLayer 1)(set! copyLayer (car (gimp-image-get-active-layer image)))(gimp-image-merge-down image copyLayer 1)(set! copyLayer (car (gimp-image-get-active-layer image)))(gimp-image-merge-down image copyLayer 1); Create the top image(aset *points* 0 0)(aset *points* 1 0)(aset *points* 2 cX)(aset *points* 3 cY)(aset *points* 4 width)(aset *points* 5 0)(gimp-image-add-layer image top -1)(gimp-item-set-name top "Top")(set! copyLayer (car (gimp-layer-copy top TRUE)))(gimp-image-add-layer image copyLayer -1)(gimp-free-select image 6 *points* CHANNEL-OP-ADD TRUE FALSE 0)(gimp-selection-grow image 1)(gimp-selection-invert image)(gimp-edit-clear copyLayer)(gimp-selection-none image)(gimp-item-transform-rotate copyLayer (/ *pi* -2) 1 cX cY)(gimp-item-transform-flip-simple copyLayer 1 1 0)(set! copyLayer (car (gimp-layer-copy copyLayer TRUE)))(gimp-image-add-layer image copyLayer -1)(gimp-item-transform-rotate copyLayer (/ *pi* -2) 1 cX cY)(gimp-item-transform-flip-simple copyLayer 0 1 0)(set! copyLayer (car (gimp-layer-copy copyLayer TRUE)))(gimp-image-add-layer image copyLayer -1)(gimp-item-transform-rotate copyLayer (/ *pi* -2) 1 cX cY)(gimp-item-transform-flip-simple copyLayer 1 1 0)(gimp-image-merge-down image copyLayer 1)(set! copyLayer (car (gimp-image-get-active-layer image)))(gimp-image-merge-down image copyLayer 1)(set! copyLayer (car (gimp-image-get-active-layer image)))(gimp-image-merge-down image copyLayer 1); Allow for the GIMP settings to be restored prior to running the script(gimp-context-push) (gimp-displays-flush) (gimp-image-undo-group-end image); Return GIMP settings back to those used prior to script(gimp-context-pop)      ))(script-fu-register "kaleidoscope-sm"  "<Image>/Filters/Render/Kaleidoscope Spherical Map..."  ""  "Art Wade"  "Art Wade"  "February 18, 2015"  "*"  SF-IMAGE       "Image"               0  SF-DRAWABLE    "Drawable"            0  )             
HelperScript.jpg
1080 x 607 - 139K
Post edited by Fencepost52 on

Comments

Sign In or Register to comment.