Page 1 of 1

Unable to create virtual texture with Gimp2

Posted: 19.08.2004, 23:24
by Guest
I used Toti's Gimp tool to try to create a virtual texture and I keep getting error messages. I'm using the latest version of Gimp2 and followed the instructions exactly. I tried different size power of two textures and keep getting the same error message. Is Toti's tool only compatible with version 1 of Gimp? Any help would be greatly appreciated. My goal is to create a 64K Mars virtual texture. Is the new Windows version of Image Magic able to create virtual textures without CYGWin?
Thanks!

Posted: 20.08.2004, 00:05
by selden
It would help if you would provide the exact and complete text of the error message. It's not fair asking the experts to try to guess what the error might be.

Posted: 20.08.2004, 08:56
by Guest
Selden, This was the error message in Gimp2,
what do you make of it ?? :?:

Error while executing
(script-fu-map-create-vt "C:\\Celestia\\textures\\phobos2k.jpg"
"C:\\Celestia\\textures\\hires\\earth" 0 1024 0 0 0 0 0)
ERROR: Procedural database execution failed:
(gimp_edit_paste 4 0)

Error while executing
(script-fu-map-create-vt "C:\\Celestia\\textures\\mars_bumples8k.jpg" "C:\\Celestia\\textures\\hires\\Mars64k\\level2\\tx_0_0.tga" 2 1024 0 0 2 0 0)
ERROR: Procedural database execution failed:
(gimp_edit_paste 8 0)

My system has 768 MB ram, AMD 2Gig

Thanks for the help. :roll: :D


[/img][/list]

Posted: 20.08.2004, 11:00
by maxim
I think I remember that script-fu got a substantial change between gimp1.x and gimp2. You should have a look at the gimp.org webpage.

maxim

Posted: 20.08.2004, 18:25
by Guest
This is the VTcreate.scm script file that I used, can it be converted for use with Gimp ver.2 ?? or do I need to download the old ver 1.25 of Gimp?


(define (script-fu-map-create-vt inImageFile inPath inLevel inBaseTileSize inFirstX inFirstY inOrigLevel inHemisphere inSaveFormat)

(set! inPath (string-append inPath "/level" (number->string (+ inLevel inOrigLevel))))
(set! theImage (car (gimp-file-load 1 inImageFile inImageFile)))
(gimp-image-undo-disable theImage)
(set! theDrawable (car (gimp-image-active-drawable theImage)))
(set! theImageWidth (car (gimp-drawable-width theDrawable)))
(set! theImageHeight (car (gimp-drawable-height theDrawable)))
(set! theAspectRatio (/ theImageWidth theImageHeight))
(set! theImageType (car (gimp-image-base-type theImage)))
(set! theMultiplier (pow 2 inLevel))
(set! theNewWidth (* (* inBaseTileSize theMultiplier) theAspectRatio))
(set! theNewHeight (* inBaseTileSize theMultiplier))
(if (= inHemisphere 1)
(set! inFirstX 1)
); if
(set! inFirstX (* inFirstX theMultiplier))
(set! inFirstY (* inFirstY theMultiplier))

(if (<= theNewWidth theImageWidth) ;avoids oversampling
(begin
(if (< theNewWidth theImageWidth) (gimp-image-scale theImage theNewWidth theNewHeight))
(set! j 0)
(set! theInitPosY 0)
(while (<= (+ theInitPosY inBaseTileSize) theNewHeight)
(set! i 0)
(set! theInitPosX 0)
(while (<= (+ theInitPosX inBaseTileSize) theNewWidth)
(gimp-rect-select theImage theInitPosX theInitPosY inBaseTileSize inBaseTileSize 2 FALSE 0)
(gimp-edit-copy theDrawable)
(set! theImage2 (car (gimp-image-new inBaseTileSize inBaseTileSize theImageType)))
(set! theLayer (car (gimp-layer-new theImage2 inBaseTileSize inBaseTileSize theImageType "layer1" 100 0)))
(set! theFloat (car (gimp-edit-paste theLayer 0)))
(gimp-floating-sel-anchor theFloat)
(set! theTileName (string-append "tx_" (number->string (+ i inFirstX)) "_" (number->string (+ j inFirstY))))

;ugly workaround to avoid gimp-file-save internal bug:
(cond
((= inSaveFormat 0)
(set! theFileName (string-append inPath "/" theTileName ".tga"))
(file-tga-save 1 theImage2 theLayer theFileName theFileName 0 0))
((= inSaveFormat 1)
(set! theFileName (string-append inPath "/" theTileName ".jpg"))
(file-jpeg-save 1 theImage2 theLayer theFileName theFileName 0.75 0 0 0 "" 0 0 0 0))
((= inSaveFormat 2)
(set! theFileName (string-append inPath "/" theTileName ".png"))
(file-png-save 1 theImage2 theLayer theFileName theFileName 0 0 0 0 0 0 0))
) ;cond

(gimp-image-delete theImage2)
(set! i (+ i 1))
(set! theInitPosX (* inBaseTileSize i))
) ;inner while
(set! j (+ j 1))
(set! theInitPosY (* inBaseTileSize j))
) ;outer while
(gimp-message (string-append "Level " (number->string inLevel) " succesfully completed"))
) ;begin;
(begin
;this should be an 'if' but this way is shorter to write:
(cond
((> inBaseTileSize theImageWidth ) (gimp-message "'Size of each tile' parameter too high for your texture"))
((<= inBaseTileSize theImageWidth ) (gimp-message "'Level to split...' parameter too high for your texture"))
) ;cond
) ;begin
) ;if
(gimp-selection-none theImage)
(gimp-image-clean-all theImage)
(gimp-image-undo-enable theImage)
(gimp-image-delete theImage)
)

(script-fu-register
"script-fu-map-create-vt"
_"<Toolbox>/Xtns/Script-Fu/Celestia Scripts/Map Create VT"
"creates a specified level of Celestia VT from a source image"
"Toti. Based on Dr. Fridger Schrempp's Virtualtex functionality"
"2004"
"March 2 2004"
"RGB* GRAY* INDEXED*"
SF-FILENAME _"Image file" ""
SF-FILENAME _"Path to save tiles into" ""
SF-VALUE _"Level to split texture into" "0"
SF-VALUE _"Size of each tile (powers of two)" "1024"
SF-VALUE _"First X" "0"
SF-VALUE _"First Y" "0"
SF-VALUE _"Original tile level" "0"
SF-OPTION _"Working Hemisphere" '(_"Whole map/West" _"East")
SF-OPTION _"Format for saved tiles" '(_"tga" _"jpg" _"png")

)

Posted: 20.08.2004, 19:22
by Toti
Guest,

The script only works for Gimp 1.xx. There are some changes in Gimp 2.xx that prevent it from running properly. I haven't found any useful documentation on this changes yet, but it seems to be a pretty common issue (many people have complained about errors when trying to run old scripts).

I advise you to download and install a previous version of the Gimp (1.23 will do, and it is far more stable than 2.xx)

But
Unless you have a system with > 1Gb of RAM and a lot of trust in Gimp's abilities, you shouldn't use it to make a 64K (!) VT.

For your purposes, you should use Virtualtex with ImageMagick and Cygwin instead. ImageMagick's memory handling is much more efficient than Gimp's.

Hope this helps

Posted: 21.08.2004, 19:23
by Guest
Thanks Toti for your help, I tried Gimp V1.25 and it works on a test sample 8k texture. I downloaded Imagemagic & cygwin and have no clue
on how to use them, my system has Win XP-pro. the color 64k Mars texture I made is 8 16x16k bmp tiles and I need to create a virtual tex
as 1k or 2k tiles which do you think would be better? the 2k would be easier to make. the Gimp vtcreate.scm you made only allows East & West but not 1 through 8. I could jest rename the other 7 sets of tiles but is there away to set up vtcreate to do this? or will I have figure out how to use Imagemagic? Thanks again for your help, Mark :D

Posted: 22.08.2004, 04:05
by Toti
Use this ImageMagick commands to create two 32K*32K (8O) hemispheres (I assume the files are png but please use the appropriate file format):

Code: Select all

montage 0_0.png 1_0.png 0_1.png 1_1.png -geometry 16384x16384+0+0 -tile 2x2 +frame +shadow +label western.png


Code: Select all

montage 2_0.png 3_0.png 2_1.png 3_1.png -geometry 16384x16384+0+0 -tile 2x2 +frame +shadow +label eastern.png



I named the files using this scheme:

Code: Select all

 ____________________________
|      |      |      |      |
| 0_0  | 1_0  | 2_0  | 3_0  |
|      |      |      |      |
|______|______|______|______|
|      |      |      |      |
| 0_1  | 1_1  | 2_1  | 3_1  |
|      |      |      |      |
|______|______|______|______|


And then run my script with the western/eastern options. (I don't know if your installed RAM will be enough for this, though)

By the way, tilesize = 1K is quite common.

Hope this helps