home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilst / texturgdn / !TexturGdn / Docs / Technical < prev    next >
Encoding:
Text File  |  1996-09-28  |  17.9 KB  |  352 lines

  1.  
  2.                          Technical details
  3.                          =================
  4.  
  5. Topics : 01 Alternative animation viewers
  6.          02 Exporting textures as JPEGs
  7.          03 Creating 16 and 24 bpp files
  8.          04 Menu tree conventions
  9.          05 Animation Types - details
  10.          06 Animation Types - file format
  11.          07 The Mutator
  12.          08 Breeding
  13.          09 Three dimensional sculpting
  14.          10 Dithering
  15.          11 Resizing
  16.          12 Batch processing
  17.          13 Using !ChangeFSI
  18.          
  19. 01 Alternative animation viewers
  20. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21. A word about alternatives to the animation viewing facilities provided.
  22.  
  23. Among the available Freeware on the platform are "!Picture" (written by mz
  24. Sophie Wilson and available from Acorn's FTP site) and "!Player" (Version
  25. 1.00 by Emmet Spier in 1990).  "!Picture" does not cache sprites, but is
  26. simple and neat.
  27.  
  28. "!Player" works well.  It is slightly faster than my own player due to its
  29. use of optimised plotting routines, it can scale plotted sprites and it has
  30. several other nifty widgets.  It needs to be fed a single sprite file, and it
  31. takes its palette from the first sprite in the file.  This means you will
  32. probably need to load the first sprite of an animation into !Paint, give it a
  33. palette, and then drag in all the other sprites, before saving the result.
  34.  
  35. "!Picture" too uses the default mode palette if none is specified by the
  36. sprite files.  One way of getting around this is to use the !ChangeFSI
  37. post-processing provided by Texture Garden which automatically adds the
  38. current desktop palette to the file.  Simpler, perhaps is to edit
  39. "!Picture"'s !RunImage program as follows:
  40.  
  41. 3250 spx%=-1:FOR Q%=0TO255:IFpixtrans%?Q%<>Q% spx%=pixtrans%
  42.  
  43. needs to be changed to:
  44.  
  45. 3250 spx%=-1:FOR Q%=0TO255:REMIFpixtrans%?Q%<>Q% spx%=pixtrans%
  46.  
  47. or similar (spx% should wind up as -1).
  48.  
  49. 02 Exporting textures as JPEGs
  50. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  51. The fact that the program has a back-end interface to !ChangeFSI enables
  52. textures to be exported as JPEGs.  This is useful for use with World Wide Web
  53. pages.  JPEGs are usually to be preferred to GIFs for backgrounds as they
  54. have excellent colour depth and can be compressed very well.  Browsers
  55. lacking JPEG support are now rare.  Some synergy between the Fourier
  56. Transforms used by Textures Garden and the Discrete Cosine Transform used by
  57. JPEG may be partly responsible for this.  Compression is especially important
  58. for backgrounds as they are usually drawn first and must be downloaded before
  59. any navigation of the page can occur.  This is not true of other images as long
  60. as "width=" and "height=" are specified in the <img> tags.
  61.  
  62. There is explicit support for exporting JPEGs in the program.  Usually the user
  63. can just set the !ChangeFSI option and then select which JPEG options are
  64. required.  These options are overridden by any JPEG output commands specified
  65. in the options string.  For further documentation on the "JPEG" and "JPEGMONO"
  66. options, information is available inside !ChangeFSI.
  67.  
  68. Unfortunately, although the Computer Concepts "Colour Card Gold" graphics
  69. hardware is fully supported by Texture Garden, !ChangeFSI (v.1.15) does not
  70. recognise the CC-style 16bpp sprites and consequently fails to convert them
  71. to JPEGs correctly.  It seems to be confused about the aspect-ratio and the
  72. colour-depth.  The aspect-ratio problem can be overcome using some of
  73. !ChangeFSI's resizing options, but colour-depth problem seems insoluble and
  74. the resulting washed out images are of little use.  Fortunately, a solution is
  75. at hand.  Texture Garden has options for forcing output to be in 16 or 24 bit
  76. colour.  When using these options, the output format follows Acorn's format,
  77. and consequently, !ChangeFSI can deal with the sprites.
  78.  
  79. When outputting images as JPEGs, it is important to make sure that you generate
  80. them at a high colour depth in the first place.  Using the force 24bpp option is
  81. recommended.  This is because JPEGs are 24 bit images, and using less than 24
  82. bits in the source image actually generates larger files because the colour
  83. quantization is seen as sharp edges which do not compress well.
  84.  
  85. 03 Creating 16 and 24 bpp files
  86. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. Texture Garden allows the export of 16 or 24 bit colour sprites from any display
  88. mode.  Old machines will have difficulty displaying these sprites, but they are
  89. recognised by !ChangeFSI.  Versions of RISC OS prior to version 3.5 are too
  90. primitive to display these "deep" sprites.  Fortunately, a patch for the
  91. operating system is available to allow them to be viewed as dithered images on
  92. older hardware.  This is called "Deeper" and is written by Sanjay Pattni.
  93. This patch is a module, and it was distributed recently on September's Acorn
  94. User cover disc.
  95.  
  96. The versions of the DragASprite module currently in existence do not seem to
  97. operate correctly on these deep images.  If this does not look as though it 
  98. will be rectified, reverting to dash boxes may be implemented.
  99.  
  100. Note that palette images are always created in the current mode, and are always
  101. displayed without any dithering.  In modes with low colour depths they may
  102. often look like broad bands of colour.  This is deliberate, so that the may be
  103. distinguished from palettes with dithering or high-frequency noise in them.
  104.  
  105. 04 Menu tree conventions
  106. ~~~~~~~~~~~~~~~~~~~~~~~~
  107. When navigating through the palettes directory or the directory of animation
  108. types using the menu structures provided, some conventions are used for the
  109. sprites that are displayed on the left-hand side of the menus.
  110.  
  111. Normally the sprite naming conventions are as follows:
  112.  
  113.          File(S)    File(L)   Directory(S) Directory(L) App(S)  App(L) 
  114. Plain   :small_abc  file_abc  *name        #name        sm!xyz  !xyz 
  115. Selected:small_abc² file_abc² *name²       #name        sm!xyz² !xyz² 
  116. NoName  :small_xxx  file_xxx  small_dir    directory    sm_app  application 
  117. NoNameS :small_xxx² file_xxx² small_diro   directoryo   sm_appo applicationo
  118.  
  119. Small sprites are used when they are available; otherwise the large sprite is
  120. scaled.  If the selected version of the sprite is not available then the base
  121. sprite is inverted.  Conventions taken from !FilerPtch are also used.  In
  122. particular, "hidden" files are not displayed, to support the local directory
  123. display options of that program.
  124.  
  125. When selecting items from the menus, pressing SHIFT or ALT will alter the
  126. effect produced.  Generally SHIFT-clicking will load the file into a text
  127. editor, and ALT-clicking will open a Filer window onto the directory
  128. containing the selected item.  In the case of directories, clicking usually
  129. opens the parent of the directory clicked on.  SHIFT-clicking instead will
  130. open the selected directory itself.
  131.  
  132. 05 Animation Types - details
  133. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  134. Animations are generated mainly by altering the phase of the pseudo-random
  135. noise which is used in conjunction with filters when performing
  136. fast-fourier-transforms.  Different frequencies are affected differently and
  137. the "Animation Type" specifies the way in which different frequencies are
  138. affected.  Animation Types consist of a series of 1024 signed 4-bit values
  139. which are used as multipliers of the "animation phase" of different
  140. frequencies.  The animation phase is considered as coung from &0 - &FFFF, ie
  141. through one complete cycle in any animation.  If the phase multipliers are
  142. large then the animation will be violent and rapid.  If the multipliers are
  143. zero for all low frequencies then the animation will appear as a series of
  144. small ripples distorting a largely static display.  If the multipliers are
  145. zero for all high frequencies then the animation may look like big waves
  146. distorting an intricately patterned tapestry.  Many different types of
  147. animation are possible using this method.
  148.  
  149. The "Texture Programmer" may design his own type of animation by using the
  150. "AnimationFrameNumber" variable which changes from &0 to &FFFF during the
  151. animation's course.
  152.  
  153. Two textures which look exactly the same may animate in different ways even
  154. if the same animation type is chosen; how they animate depends on their
  155. constitution, not on their appearance.
  156.  
  157. 06 Animation Types - file format
  158. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  159. Animation Types are stored as 512 byte files in the "Animatons" directory
  160. within Texture Garden.  Source for an example file is contained in the
  161. "Library.Source.Animations" directory.
  162.  
  163. The files are made up of 1024 signed 4-bit values.  Low frequency multipliers
  164. are stored first within each byte the lower frequency is in the lower bits
  165. (little endian).
  166.  
  167. 07 The Mutator
  168. ~~~~~~~~~~~~~~
  169. When texture Garden mutates a texture into another one, its operation is
  170. quite simple.  It goes through the file and alters some of the numbers in the
  171. texture generation file.  The numbers are chosen according to the "mutation
  172. options" of the last command or function of the program.  These mutation
  173. options are specified by the programmer of the function.  Their possible
  174. values are listed in the "Extensions" file.
  175.  
  176. 08 Breeding
  177. ~~~~~~~~~~~
  178. When two textures are mated with one another the program examines the code of
  179. the two textures for the "CreateTwoDimensionalTransform" and
  180. "CreateOneDimensionalTransform" commands.  Breeding mainly affects this type
  181. of command.  If one of the textures lacks both of these commands, then the
  182. two textures will be unable to breed.  For a texture to be fertile, it
  183. follows that it should always contain some such command.
  184.  
  185. For each occurrence of one of these commands in the "Mother" texture (paying
  186. heed to the "Mutate Colours" and "Mutate Textures" options) a random
  187. parameter of the command is chosen and deleted.  If this parameter is a
  188. function, then all its arguments are also deleted.  A chunk of code is taken
  189. at random from a "Create...Transform" in the "father" code.  This is then
  190. spliced along with any relevant parameters into the mother code at the chosen
  191. point.
  192.  
  193. The above mechanism allows textures to be of both sexes.  Note that almost
  194. the entire code comes from the "mother" texture, with the father donating a
  195. tiny quantity of code.  At the end of the breeding, the offspring is always
  196. given a new seed (for the pseudo-random number generator).
  197.  
  198. 09 Three dimensional sculpting
  199. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  200. Support is provided for the production of three dimensional textures.  These
  201. are of use when textures need to be moulded to the surfaces of solid objects. 
  202. The most frequent application of this is when a texture is required that can
  203. be moulded around the surface of a sphere.
  204.  
  205. The two commands "DefineSolidBlock(Block_Description)" and
  206. "Sculpture(Path_of_X,Path_of_Y,Path_of_Z)" are used to perform this type of
  207. action.
  208.  
  209. The "DefineSolidBlock" command defines a solid block of texture in three
  210. dimensions.  "Block_Description" is a function of X,Y, and Z which usually
  211. refers to various buffers using the "Point"-type commands.
  212.  
  213. The "Sculpture(Path_of_X,Path_of_Y,Path_of_Z)" command sculpts a solid shape
  214. from the solid block of texture described in the last "DefineSolidBlock"
  215. command encountered.  The parameters, "Path_of_X", "Path_of_Y", "Path_of_Z",
  216. define a mapping between X and Y and the three dimensional space.  They are
  217. functions of X and Y.  The resulting shape is stored in the main two
  218. dimensional buffer.  It is usually best to enclose these commands inside the
  219. "StopMutating" and "StartMutating" pair.
  220.  
  221. One version of the command that defines a sphere is:
  222.  
  223. Sculpture(
  224. ScaledSignedMultiply(SignedCos(X),Absolute(SignedCos(LogicalShiftRight(Y,&1)))),
  225. SignedCos(LogicalShiftRight(Y,&1)),
  226. ScaledSignedMultiply(SignedSin(X),Absolute(SignedCos(LogicalShiftRight(Y,&1)))))
  227.  
  228. This is written on three lines to reveal its structure.  It is still quite a
  229. mouthful.  The advantage of specifying the shape explicitly is one of
  230. flexibility.  Smaller and larger spheres are possible, as are different
  231. shapes.
  232.  
  233. 10 Dithering
  234. ~~~~~~~~~~~~
  235. The dithering patterns used by the program involve a number of types of
  236. simple random dithering.  The dithering used means that the same degree of
  237. dithering is used in all screen modes.  It you use a lot of dithering to make
  238. a grey image look good in a sixteen colour mode, then it will not look much
  239. better when changing to a sixteen million colour mode.  A command such as:
  240. "If IsLessThanOrEqualTo(LogBitsPerPixel,&2) Then Dithering(&4000) Else If
  241. IsEqualTo(LogBitsPerPixel,&3) Then Dithering(&2000) Else Dithering(&0)" may
  242. be used where this is inappropriate.  I may implement a "ScaledDithering()"
  243. command to replace the above contraption, but for the moment, it provides
  244. maximum flexibility.
  245.  
  246. The dithering technique used also means things can appear with slightly
  247. different tints in 16 and 256 colour modes.  Using the command
  248. "Dithering(FloydSteinberg)" should make the program use Floyd-Steinberg
  249. dithering, but this is a feature that does not yet work.
  250.  
  251. For users who must have Floyd-Steinberg dithering, it is currently possible
  252. to implement this by generating the texture using no dithering in a mode with
  253. deep colour and then using the interface to !ChangeFSI to do post-processing
  254. in a mode with limited colour depth.
  255.  
  256. 11 Resizing
  257. ~~~~~~~~~~~
  258. There is something fundamentally square (literally) about the way in which 
  259. Texture Garden produces its extures.  The reason for this is the technical one
  260. that it is often faster to calculate FFTs at a size which is a power of two and
  261. then resize the result, than to do a FFT at the desired size.  If you want
  262. textures that are not square then there are several options available:
  263.  
  264. If the resized image needs to be displayed for selection in the Texture Garden,
  265. then using the built in resizing commands is strongly recommended.  This is
  266. most easily performed by using the "Resize" command an conjunction with the
  267. "ResizeSprite" command which are provided specifically for the purpose of
  268. resizing textures.  This is the recommended method of resizing textures, and it
  269. is the one used by the front-end provided for this purpose.
  270.  
  271. If a resize by XFactor and YFactor is required where
  272. (0 < XFactor < &10000, 0 < YFactor < &10000) then a...
  273. "Resize(XFactor, YFactor)" may be issued immediately before any "MakeSprite"
  274. commands are encountered, and a... 
  275. "ResizeSprite(XFactor, YFactor)" needs to occur just before the texture program
  276. terminates.
  277.  
  278. For the very technically minded the "ResizeSprite" command merely calls the
  279. "TruncateSpriteVertically(Y1,Y2)" and "TruncateSpriteHorizontally(X1,X2)"
  280. commands with their first parameter as zero.  These commands operate on the
  281. sprite generated by the program, chopping off its edges.  Note that although
  282. X1, X2, Y1 and Y2 range from 0 to &FFFF, X = 0, Y = 0 is at the bottom
  283. left-hand corner of the sprite and not, as usual, in the middle of the texture.
  284.  
  285. Equally technical: when the "Resize" command is issued three commands are built
  286. and issued.  They are roughly as follows
  287. "TwoDimensionalShift(&8000,&8000,Overwrite)"
  288. "TwoDimensionalProcess(0,0,XFactor,YFactor,TwoDimensionalPoint(
  289.    Combine(Multiplication,&40000 DIV XFactor,LogicalShiftRight(X,&6)),
  290.    Combine(Multiplication,&40000 DIV YFactor,LogicalShiftRight(Y,&6))),
  291.    Overwrite)".
  292. "TwoDimensionalShift(&8000,&8000,Overwrite)"
  293. This is close to what is actually used to resize the texture.
  294. When corresponding  "TruncateSpriteHorizontally(&0,XFactor)" and 
  295. "TruncateSpriteVertically(&0,YFactor)" are issued, the resulting image should
  296. tessellate, be the right shape and size and breed properly.  It will also
  297. be faster than if the resizing was done using !ChangeFSI, and will have had
  298. anti-aliasing techniques applied to it before translation to the current
  299. colour depth (better).
  300.  
  301. There are alternative methods available for resizing textures.  It is possible
  302. to resize manually by loading the generated sprite into a bitmap package and
  303. then trim it or resize it to the required size.  Trimming will clearly
  304. prevent seamless tesselation.  Resizing will preserve this, but may introduce
  305. some distortion.  One of the better ways to resize a resulting image is to
  306. use the scaling options of the !ChangeFSI post-processing available.  Using
  307. something like: "**#r 13:16 11:16 -nomode" would produce the desired effect.
  308.  
  309.  
  310. 12 Batch processing
  311. ~~~~~~~~~~~~~~~~~~~
  312. Batch processing is supported by Texture Garden.  If a textfile is dragged to
  313. the icon bar with the appropriate syntax, then it is used as a list of
  314. textures to be processed.  The syntax required for each line is as follows:
  315.  
  316. <infile> <outfile> <size>
  317.  
  318. where infile is the path of a texture generation file, outfile is where the
  319. resulting sprite should be written to, and size is the desired size of the
  320. texture to be output.  This should always be a power of two.  Comments are
  321. allowed in batch files and they are taken to be any line starting with a "|".
  322.  
  323. The reason this has been supported is to allow maximum flexibility for those
  324. wishing to animate their textures.  It is in principle possible for users to
  325. machine generate a whole series of textures and then process them in bulk. 
  326. Users who want to animate their textures in time with music (for example) may
  327. take a series of parameters from a MIDI source, a tracker file, or directly
  328. from the frequency spectrum of music sample and then use these as parameters
  329. when generating an appropriate texture.  If you are engaged in this type of
  330. activity, the author would be very pleased to hear from you.
  331.  
  332. 13 Using !ChangeFSI
  333. ~~~~~~~~~~~~~~~~~~~         
  334. Post-processing of saved sprites and animations may be controlled by ticking
  335. the "Use !ChangeFSI" option.  
  336. Two system variables are defined when using !ChangeFSI post processing of saved
  337. sprites: "<TextureGdn$File>" which contains the path of the existing sprite
  338. file and "<TextureGdn$Leaf>" which contains the leaf name from the same file. 
  339.  
  340. The !ChangeFSI-associated string provided contains the command line options
  341. required by this program.  Two special characters are used: "*" and "#". 
  342. Using "*" inserts "<TextureGdn$File> " into the command line string at that
  343. point and "#" inserts a string corresponding to the current mode.
  344.  
  345. The default setting for the string is "**#r -nomode".  This means that the
  346. existing sprite is overwritten and that processing is performed in the current
  347. screen mode.
  348.  
  349. For further documentation on the options available, information is available
  350. from inside !ChangeFSI.
  351.  
  352.