virtualtex script help

Tips for creating and manipulating planet textures for Celestia.
Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #21by Ozark » 13.07.2007, 21:37

That did the trick! :D :D Thank you t00fri! It seems I was experiencing whatever iincompatability there was with version 1.04.

also instead of copying the text to notepad I dropped it straight into nano and saved it with no file extension(I don't know if that made a difference or not).

Thanks to all who helped me with this issue. And all your patience with me. Hopefully others will see this thread and solve similar issues they may have had or have. I am grateful to you all. :D

Ozark
OZARK

Celestia 1.5.0
Windows XP Home Edition
Pentium 3.4 ghz E.E
2GB ddr Ram
Radeon 9550 AGP 256 mb

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 7 months
Location: Hamburg, Germany

Post #22by t00fri » 13.07.2007, 22:34

Good...

Actually, virtualtex 1.04 rests more on particular features of ImageMagick tools than 1.03. Since I definitely know of some bugs in various IM versions, virtualtex 1.0.4 can be totally blocked if one is unlucky.

I have completely rewritten versions 1.05 and 1.06...but they are now becoming outdated because of my much more powerful 'txtools' written in C++ and working for any OS.

Bye Fridger
Image

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #23by John Van Vliet » 14.07.2007, 08:06

and if using image magic is way to slow ( my old - win-xp box would take 2 to 3 hours to cut up a 16k map
so i converted it ( VertTex) to use the vips lib

http://www.vips.ecs.soton.ac.uk/index.php?title=VIPS

Code: Select all

#! /bin/bash
function min () {
         if(( $1 < $2 )); then
                  echo $1
         else
                  echo $2
         fi
}

if [ $# -lt 3 -o "$1" = " --help" ] ; then
 echo
 echo ' Usage: vipsvt [--help | <texture name><tile size><tile format>] [e|E|w|W]'
 echo
else
block_width=$2;
block_height=$2;

dir=`dirname $1`
file=`basename $1`
fileformat=$3
copy=$$_$file.v
 echo making local copy of image as $copy ...
 
vips im_copy $1 $copy

width=`vips im_header_int Xsize $copy`
height=`vips im_header_int Ysize $copy`

j=0

while (( j * block_width + block_width <= height ));do
      ((top = j * block_width ))
  if [ $# -eq 4 ]; then
     if [ "$4" = "e" -o "$4" = "E" ]; then
          ioff=$(( width/block_width ))
     elif ["$4" = "w" -o "$4" = "W" ]; then
          ioff=0
      else
       echo
       echo "*** Incorrect 4th paramenter! **"
       echo
      return
    fi
 fi
 
i=0

    while (( i * block_width + block_width <= width )); do
          ((left = i * block_width))
          toname=$dir/tx_$((i + ioff))_${j}.$fileformat
         
          ((right = $width - $left))
          ((bottom = $height - $top))
         
          tile_width=`min $block_width $right`
          tile_height=`min $block_height $bottom`
         
     echo extracting tile $left $top as $toname
          vips im_extract_area $copy $toname \
              $left $top $tile_width $tile_height

   
   ((i++))
   done
   ((j++))
  done
 
   rm $$_$file.v
  # rm $copy
   rm $$_$file.desc
fi


this bash script dose work in MinGW and cuts up the 16k map in 5 min

also here is one for cutting up a vips format image without making a new copy of it

Code: Select all

#! /bin/bash
function min () {
         if(( $1 < $2 )); then
                  echo $1
         else
                  echo $2
         fi
}

if [ $# -lt 3 -o "$1" = " --help" ] ; then
 echo
 echo ' Usage: vipsvt [--help | <texture name><tile size><tile format>] [e|E|w|W]'
 echo
else
block_width=$2;
block_height=$2;

dir=`dirname $1`
file=`basename $1`
fileformat=$3
#copy=$$_$file.v
 #echo making local copy of image as $copy ...
 
#vips im_copy $1 $copy

width=`vips im_header_int Xsize $file`
height=`vips im_header_int Ysize $file`

j=0

while (( j * block_width + block_width <= height ));do
      ((top = j * block_width ))
  if [ $# -eq 4 ]; then
     if [ "$4" = "e" -o "$4" = "E" ]; then
          ioff=$(( width/block_width ))
     elif ["$4" = "w" -o "$4" = "W" ]; then
          ioff=0
      else
       echo
       echo "*** Incorrect 4th paramenter! **"
       echo
      return
    fi
 fi
 
i=0

    while (( i * block_width + block_width <= width )); do
          ((left = i * block_width))
          toname=$dir/tx_$((i + ioff))_${j}.$fileformat
         
          ((right = $width - $left))
          ((bottom = $height - $top))
         
          tile_width=`min $block_width $right`
          tile_height=`min $block_height $bottom`
         
     echo extracting tile $left $top as $toname
          vips im_extract_area $file $toname \
              $left $top $tile_width $tile_height

   
   ((i++))
   done
   ((j++))
  done
 
  # rm $$_$file.v
  # rm $copy
   #rm $$_$file.desc
fi

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #24by Ozark » 24.07.2007, 03:47

Hi all,

I notice alot of readers are checking out this thread! I just thought i would "throw" this out there too :wink:

Recently my system crashed hard and I had to start over from scratch! :cry: Reformat and all, any how when it came time to install the necessary utilities for virtualtex all went smoothly until i ran the script. I got more errors. I had tried everything I could think of before asking for help AGAIN for the same issue. Finally after 2 days of messing with it I was about to request help because i was again stumped, When I thought I would try one more thing:

First I brought up the page the Virtualtex script is on http://www.celestiaproject.net/~t00fri/virtualtex

Then I copied the text by selecting Edit , select all, copy. I copied directly to the Nano Editor which can be found in C:\Cygwin\Bin (that is if you installed Cygwin correctly) I should note that when you get an error with Virtualtex an error with a line number comes up like this:


Ozark@home ~
$ virtualtex test2k.png 256 png

tilesize = 2562048
/usr/local/bin/virtualtex:51: bad math expression: illegal character: ^M

Ozark@home ~
$


Notice how it says /usr/local/bin/virtualtex:51:
Well i'm no expert but I thought I would go down to line 51 and see what was going on. So I looked at the script that i had saved in the Cygwin/usr/local/bin folder and didn't notice anything UNTIL :wink: I compared the script I had save in Nano and the script at the above link. They were different. So I went about making the script in Nano look EXACTLY the same as the script from T00fri's site. It turned out only to be 2 or 3 lines that needed to be spaced correctly. Once I was sure it was exactly the same I saved the file, ran the script, and lo and behold it now works beautifully!!

P.S Once you paste the Script to Nano and have made any necessary changes press Ctrl O and name the file Virtualtex (with no extension) Hit enter then close Nano, and try the script again. :D

Hope this helps

Ozark
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #25by John Van Vliet » 24.07.2007, 08:21

it is the difference in the " enter" button / CR from Windows and Linux
on windows i use SciTE as my text editor
http://www.scintilla.org/SciTE.html
and it can convert a text doc./ bash script from win to Linux
also why are you using Cygwin instead of MinGW witch is much faster

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #26by Ozark » 24.07.2007, 21:44

John,

Thanks for the tip on sciTE and MinGW. :)



also why are you using Cygwin instead of MinGW witch is much faster


I am using Cygwin because the Dummies PDF is the only method I know of. I am not a linux user and most things having to do with command lines and scripts and such, I am not privy to. :( I wish i was though so I could help others with thier questions rather than asking my own.) However When I go to a site that is offering these programs I am quite intimidated because they seem so complex. So I have to come back here and ask those of you who are familiar with them what to do.
So with that in mind could you be a little more specific on what to do to use these programs for Celestial purposes. (more specifically VT's) Also if you know of any good websites to direct me too to learn the very basics of Command line computing? (I'm not even sure if thats the right term :lol: )


Thanks

Ozark
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Avatar
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #27by cartrite » 24.07.2007, 23:36

Ozark,
Try running

Code: Select all

identify -format %x%h test2k.png
and see what it says. I think it should say 2048x2048 png or something like that. Anyhow post the output of the command. Identify is a program from ImageMagik.
cartrite
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #28by Ozark » 25.07.2007, 02:37

Hi Cartrite,


here is the result of that command


ozark@Home ~
$ identify -format %x%h test2k.png
117.72 PixelsPerCentimeter1024

ozark@Home ~
$


Ozark
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Avatar
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #29by cartrite » 25.07.2007, 07:44

Your problem is probably Image Magik. You need a different version, probably an older one. The virtualtex script runs identify and uses the output to run the script. It is expecting the output to be

Code: Select all

2048x1024
not

Code: Select all

117.72 PixelsPerCentimeter1024
. The reason the script is failing is that it trying to perform math on characters. The older ImageMagik's would output the line the script expects.
cartrite
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #30by John Van Vliet » 25.07.2007, 20:23

hi Ozark I gave up on using Image Magik and converted VertTex
( http://www.celestiamotherlode.net/creat ... ips_vt.zip ) to use Vips
http://www.vips.ecs.soton.ac.uk/index.php?title=VIPS

Image Magik was giving me a 3 hour time on cutting up a 16384x8192.png map
using vips dose it in 8 min

1 ) install Vips and maybe Nip2 I like Nip and use it all the time .
and add C:\\path to nip2 \bin to your system path ie . C:\\Nip2\bin or C:\\Program Files\Nip2\bin or for a VIPS only install, install it in C:\\WINDOWS
2) READ and REREAD the MinGW home page
http://www.mingw.org/
3) install Mingw and MSys , MinGW has a gui for installing and requires you to select a DL mirror , this may take a few tries to get a fast DL . I installed them in C:\\GnuWin32/MSys and C:\\GnuWin32/MinGW .extra programs ( GnuWin32 ) can be found at
http://sourceforge.net/project/showfile ... p_id=23617
4) after mingw and msys are installed you will nead to add
C:\\GnuWin32/MinGW;C:\\GnuWin32/MinGW \bin;
C:\\GnuWin32/MinGW\lib;C:\\GnuWin32/MinGW\include;
C:\\GnuWin32/MSys;C:\\GnuWin32/MSys\bin;
C:\\GnuWin32/MSys\lib;C:\\GnuWin32/MSys\include;

to the system path ( right know i am running fedora and not windows so if if you need help editing the system path i will edit this post from win xp )
5) unzip vips_vt.zip into C:\\GnuWin32/MinGW \bin
I use 7-zip on Windows ( http://www.7-zip.org/ )
6 ) install "Open Command Window Here" from Micorsoft
http://www.microsoft.com/windowsxp/down ... rtoys.mspx
7) make a new folder ex. test
copy a 2 or 4 k map into test
8) from the left Payne in explorer right click on test and select "Open Command Window Here"
type in sh then hit the enter button
or
on your desktop open MSys and type in cd C:\\Path to test and hit enter
then type sh vipsvt.sh *.png 512 png and hit enter
and see what happens

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #31by Ozark » 25.07.2007, 22:49

Hi Cartrite,


Thanks for the tip But I think you misread my post


Once I was sure it was exactly the same I saved the file, ran the script, and lo and behold it now works beautifully!!


As you can see I have gotten the script to run. :) It works great but quite slow(not complaining) :wink:


Ozark
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #32by Ozark » 25.07.2007, 23:00

Hi John, thanks for all the info I'll get right on it and let you know how it goes :D


Ozark
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #33by Ozark » 26.07.2007, 02:43

John,

Well I got minGW and Msys and vips . I think i installed them correctly.

I couldn't get the latest version of minGW but i got ver 5.0 Msys was quite easy and vips was extracted to a folder called vips in c:\windows. the vipsvt was extracted to c:\Gnuwin32\minGW\bin. This is the result of what you asked me to type in:


ozark@Home~
$cd c:\Documents_and_Settings\ozark\Desktop\ex.test\
> sh vipsvt moon.jpg 512 jpg
sh: cd: c:Documents_and_SettingsozarkDesktopex.testsh: No such file or directory :(

ozark@Home~
$


Do you know what went wrong? All Paths that you specified were set in environmental variables minGW and Msys are in afolder called Gnuwin32 in the c: directory(seemed like as good a place as any ):)
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #34by John Van Vliet » 26.07.2007, 06:38

good question ??? did you reboot after installing and editing the sys. path
open MSys on your desktop and type in
echo $PATH
and hit enter that will show where mingw is searching for files

also MinGW DOSE NOT LIKE A SPACE IN THE PATH
retry it in C:\\test
and use a .png format image that way you will not be adding .jpg artifacts to the new image
jpg saved at 75% ( 25% of image data is lost,gone,finetio ,forever)
then re saved at 75% ( only 56.25% of the original data is left )
and again at 75% = 42.18 of the original image is left

P.S.
ex. means " for example "
the folder name should be test

a folder called ex.test is considered to be some type of file
Last edited by John Van Vliet on 26.07.2007, 06:53, edited 1 time in total.

Avatar
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #35by cartrite » 26.07.2007, 06:50

Hi Cartrite,


Thanks for the tip But I think you misread my post


Quote:
Once I was sure it was exactly the same I saved the file, ran the script, and lo and behold it now works beautifully!!


As you can see I have gotten the script to run. Smile It works great but quite slow(not complaining) Wink


I did read that a little too quick and missed some of what you posted. Sorry.
It seems you have links to 2 different virtualtex scripts. The one provided by Fridger http://www.celestiaproject.net/forum/viewtopic ... 0754#90754

and the one from post

http://www.celestiaproject.net/forum/viewtopic ... 1105#91105 .
The version provided by Fridger has a few lines changed that seems to deal with the problems with Image Magik's output. It looks like you corrected the version that you downloaded to match Fridger's version 1.03.
Anyhow, good luck.
cartrite
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #36by Ozark » 26.07.2007, 23:19

Hi John,

from the left Payne in explorer right click on test and select "Open Command Window Here"
type in sh then hit the enter button

Result:


C:\test>sh
sh-2.04$


then type sh vipsvt.sh *.png 512 png and hit enter
and see what happens


result:


C:\test>sh
sh-2.04$ sh vips_vt alien2k.png 512 png
taking local copy of image as 3068_alien2k.png.v ...
vips_vt: /c/WINDOWS/vips: is a directory
vips_vt: /c/WINDOWS/vips: is a directory
vips_vt: /c/WINDOWS/vips: is a directory
rm: cannot remove `3068_alien2k.png.v': No such file or directory
rm: cannot remove `3068_alien2k.png.desc': No such file or directory
done
sh-2.04$


1 question. in your directions you say to type in vipsvt *.png 512 png

When i do this no file or directory error comes up but when i type vips_vt then the above message comes up.

also here is what comes up when i type echo $PATH:


C:\test>sh
sh-2.04$ echo $PATH
/c/Gnuwin32/MinGW/bin:/c/program files/imagemagick-6.3.5-q16:/c/WINDOWS/system32
:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/Program Files/Common Files/Adobe/AGL:/c/
Program Files/NVIDIA Corporation/DDS Utilities:.:/c/Program Files/Nmtools:/c/Pro
gram Files/XnView:/c/Program Files/NVIDIA Corporation/DDS Utilities:/c/Program F
iles/gzip:/c/GnuWin32/MinGW:/c/GnuWin32/MinGW /bin:/c/GnuWin32/MinGW/lib:/c/GnuW
in32/MinGW/include:/usr:/usr/bin:/usr/lib:/usr/include:/c/WINDOWS/Vips/bin
sh-2.04$

Any Ideas what i'm doing wrong now? BTW thanks for taking the time to help me with this. :D


Ozark
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #37by John Van Vliet » 27.07.2007, 02:25

i take it that the script is working

as to the error messages. I though i updated the zip file on the motherload but it is an old one and i have sense fixed it . It is an error that will cause no problems all it is ,is two extra lines of code, there will be 1 or 2 extra files in the folder . 3068_alien2k.png.v' ( the Vips format image )and 3068_alien2k.png.desc ( a description file for the Nip2 GUI ) just delete them
or
Use the one that gives no errors
also be patient in 2000 i started using MinGW and CygWin and there is s steep learning curve and i am still learning Fedora Linux after 2 years

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #38by Ozark » 27.07.2007, 02:49

Hi John

You say the script is working, but where is it putting the files. There is still just one file in the test folder, the original alien2k.png. :?
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #39by John Van Vliet » 27.07.2007, 21:53

in the folder test

that is the folder that you cd to
now you sed that msys was installed but not the latest MinGW
is MinGW installed

Topic author
Ozark
Posts: 44
Joined: 09.07.2007
With us: 17 years 4 months
Location: Plymouth, MN

Post #40by Ozark » 28.07.2007, 01:05

Yes, minGW is installed. Version 5.0
OZARK



Celestia 1.5.0

Windows XP Home Edition

Pentium 3.4 ghz E.E

2GB ddr Ram

Radeon 9550 AGP 256 mb


Return to “Textures”