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