Author Topic: In search of possible unknown TXI command  (Read 584 times)

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« on: January 15, 2015, 02:33:20 pm »


               

Hey guys, I'm trying to animate a texture, but the whole of the sprite set has a number of frames not equal to a shape you can represent well using the standard binary numbers for tga/dds image files. For instance, I have 80 frames at 128 px square each. What I want to do is animate from frame 0 to frame 80 without animating through any blank space. As an example, my file would be 1024x1280 if I simply stacked the frames in a grid 8x10, but we can't use that texture size, so I have to enlarge to 1024x2048, or otherwise lose quality by shrinking or growing the frames to fit that area.


 


In playing with emitters, we have the ability to define the start and end frames in any given sprite sheet animation. Does anybody know of a TXI command which can deliver the same power? If so, I could add a related sprite combination into the remaining space.


 


My other option is to resize the image, and I don't really want to waste space by stretching the useable image to 1024x2048, and I refuse to lose quality by shrinking the usable image to 1024x1024.


 


Any help is appreciated.


 


I already checked here to see if the KotOR guys had located any new commands, but I didn't see any.


 


Also something useful would be to potentially use the filerange command to load in multiple files for the animation. Not sure if other functions than cube mapping are linked to that. Probably not.



               
               

               
            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #1 on: January 15, 2015, 06:44:41 pm »


               

What is that "filerange command" you are talking about ? Does it mean you can specify another texture for an animation like ..example :


I want to create a waterfall using 4 separate textures where each one of them represents one frame of the whole event ! Does that sounds like what you are mentioning with that command ?


I´m always looking for new ways of simulating things... for new TXI commands... cant help.



               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #2 on: January 15, 2015, 07:08:45 pm »


               

OTR was just showing how the filerange works over in his cube mapping discussion. Instead of supplying a single file, you supply X files, tell it a file range, and it collects x files starting with the specified txi filename and ending with that given index -1. So filerange 6 listed in a txi file looks for <filename>0.tga/dds through <filename>5.tga/dds. Using that with the cube mapping, it appears that it queues up the 6 images needed to make the panels of a cube.


 


I was thinking that if there was any possibility that filerange might be linked to other txi commands, I might be able to make flowing water without having to put all the images in a single file. Or you could make a sign that has letters that change in order.


 


Or not in order! I was hoping all the emitter functions might be inside the txi system. They seem to be the same in many other aspects, such as blending mode, and the ability to display tiled images or sprite sheets.


 


However, unlike txi, emitter graphics are at least displayed in the correct order. The trick with using sprite sheets as animated textures via txi is that you want a sprite sheet only a single row high. Additional rows are read in a strange order. It reads first row, then last row, then all rows in between starting with the second to last row. Emitter animated textures read rows from the top down and left to right as expected.


 


One of the main reasons I asked for this knowledge this morning, was that I was displaying 80, 90, and 250 sprite animations. If I were to import diablo 2 animations, many of those would be 114. That odd number makes bounding them in a multi-row file difficult, since we have to adhere to a strict set of file shapes. 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, and up. 


 


Even if I were to align all the sprites in a row, I still have to adhere to those numbers in both dimensions. So say I have 128 pixel images, and I lined 80 of them up. That would give me a pixel width of 10240. This is not in that range of powers of 2. This comes with the definite issue of having black space at the end of the strip.


 


Two work arounds for this issue exist, but they have issues of their own. In either case, you adjust the size of the image, not the image canvas, to one of those power of two numbers. So say I take 10240 up to 16384. That would make my sprites slightly wider, but if I tell the txi that my count of frames per row (numx) is 80, then it will divide 16384 by 80 to determine where to collect my images. Likewise I could shrink my image width down to 8192, losing a little detail. Again numx set to 80 would tell the engine where to cut out graphics for display.


 


Both of these work arounds have a simple flaw: 16384/80 is 204.8, and 8192/80 is 102.4, both fractions. The engine does not handle fractions well. In fact, it seems to drop the fractional part. But it is worse than that...


 


This morning I created a 80 frame long strip, as mentioned above. When I run it in game, every frame it cut slightly offset from the next. After 80 frames, or 80*0.8, you are 64 pixels offset from your intended cut point. So the engine not only drops fractions, but it also stores a single number as to what it thinks the offset is. In doing so, it will lose a lot of texture with a strip that wide. 64 pixels is half a frame in my 128 pixel frame scenario.


 


Since the frames are not intended to be seamless with the adjacent frame, a line develops and shifts across the texture. After the 80th frame plays, it jerks back to cutting from 0,0 and has no offset visible, and no line. This lets people see the loop very well, and makes things generally ugly. At 32 frames per second, that loop is fairly fast. At 8 fps, the animation is sluggish, but it at least takes a long time to loop and jerk.


 


In conclusion: if I could simply specify the start frame and stop frame, or firstframe lastframe combination, just like in emitter works, I could prevent all that mess.



               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #3 on: January 15, 2015, 07:13:45 pm »


               

I know I can simply emit a single particle with the emitter, and that would be just fine in many intended uses, but particles and placeables accept different envmap data, and are restricted by different space rules.



               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #4 on: January 15, 2015, 07:36:19 pm »


               

You might want to take a look at the fnt_*.txi files and their corresponding textures.  Those guys also use filerange but if you kind of look over them there's some commands like fontheight, fontwidth, etc. (especially goody-rich is fnt_dbcs.txi) that you might be able to twist to do your bidding. 


 


However, the thing about the the power of 2 size for a texture isn't just a NWN thing, it's a video card thing.  With "non-standard" sized textures you potentially run the risk of people not being able to see your textures because their video card can't deal with the non-power-of-two or whatever the right word is for the sizing.  A little more information here and you could probably also dig up more on the web.  Now, how many people playing NWN would that actually cause a problem for?  Anyone's guess.  I personally try to steer clear of it, myself, just because.  Even if it means I have to go larger on something.


 


I don't think you can use DDS for proceduretype cycle stuff because the mipmaps mess with how the game slices the textures up and I don't think you can use RLE compression on your TGA (i.e. the extra space being black would be compressed by the RLE algorithm) but you might try it just for grins.  The reason why I bring this up is that I discovered that NWN can display Run Length Encoded TGA's for a texture type or two.  Maybe...portraits?  I dunno for sure.  I've done ginormous animated textures before but I always played within the power-of-two bounds.



               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #5 on: January 16, 2015, 05:05:42 pm »


               

Without the command I was looking for, what I ended up doing was this:


 


80-64 is 16, and 80/16 is 5, so I took out every 5th frame, which turned out to be 4, 9, 14, etc. That gave me exactly 16 frames to remove, reducing the count to exactly 64. I then put all 64 images in a strip 8192x128, which fits the power of two rule. It plays wonderfully as a texture now.


 


I was able to do the same with 90 and 96 count animations.


 


I then took those textures and made animated placeable waters using textures from Torchlight 2.


 


Here are the texture files if you'd like to play with them: https://www.dropbox....2Waters.7z?dl=0


 


And here is the txi contents. This will be the same for every txi file needed for these textures:



candownsample 0
downsamplescale 0
proceduretype cycle
numx 64
numy 1
fps 20

Now you can use them as textures on tiles without issue, just like other water textures. To get them to work on placeables without being envmapped with the local envmap, you have to edit the 2da line in placeables.2da where it says "Reflection". Set that to **** instead of default. In addition, you have to set the placeable model type to "Tile" instead of "Character". Here is an example placeables line:



865        "Animated Water: 01"        ****     plc_animwater01     ****         ****           ****           ****           17             1            0         ****      ****      1

Here's the file code for my "Animated Water: 01" placeable:



# Exported from NWmax 0.8 b60 at 1/16/2015 12:01:54 PM
# mdl file
#
#NWmax MODEL ASCII
# model: plc_animwater01
#local file: C:\gmax\Scenes\Animated Water Test 12.gmax
filedependancy Animated Water Test 12.gmax
newmodel plc_animwater01
setsupermodel plc_animwater01 NULL
classification Tile
#NWmax GEOM  ASCII
beginmodelgeom plc_animwater01
node dummy plc_animwater01
  parent NULL
endnode
#Tile trimesh node
node trimesh Plane01
  parent plc_animwater01
  position 0.0 0.0 1.0
  orientation  0.0 0.0 0.0  0.0
  wirecolor 0.831373 0.603922 0.894118
  tilefade 0
  scale 1.0
  render 1
  Shadow 0
  beaming 0
  inheritcolor 0
  rotatetexture 0
  alpha 0.5
  transparencyhint 0
  selfillumcolor 0.0 0.0 0.0
  ambient 1.0 1.0 1.0
  diffuse 1.0 1.0 1.0
  specular 0.0 0.0 0.0
  shininess 0
  center 0.0 0.0 0.0
  bitmap tx_wateranim01
  verts 4
    -5.0 -5.0 0.0
    5.0 -5.0 0.0
    -5.0 5.0 0.0
    5.0 5.0 0.0
  faces 2
    2 0 3  1  2 0 3  1
    1 3 0  1  1 3 0  1
  tverts 4
    -2.38419e-007 1.78814e-007 0
    2.0 -2.38419e-007 0
    1.78814e-007 2.0 0
    2.0 2.0 0
endnode
endmodelgeom plc_animwater01
donemodel plc_animwater01


               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #6 on: January 16, 2015, 05:17:10 pm »


               

This placeable comes out looking, up close, exactly like 4 emitters in a square, using the same or similar texture, and with the start and stop keys listed. On my machine, I cannot give the emitter-based version an alpha layer, or the whole thing flickers and flashes. But with the placeable version, I can give it any alpha layer I want. Both options can use opacity values. The emitter can make use of its inherent alphastart and alphaend values and it works just fine. The placeable can make use of the on-model alpha value (as shown as 0.5 above). Both can play at the same speed without jumping.


 


The only difference is that the placeable version has no seam lines. Tiled textures on the single node are smoothed and/or match up with the adjacent "tile". The emitter has a definite line between nodes where the texture boundary can be seen. I believe this is because the emitter does not fire every single particle at the exact same time. Some of the particles may be a frame off from the other. They seem to keep pace with each other once started, but the line is more visible the further you walk away from the emitter plane.


 


I'll be releasing a test module later to show exactly what I mean.



               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #7 on: January 16, 2015, 06:53:33 pm »


               

http://neverwinterva...ater-placeables



               
               

               
            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #8 on: January 16, 2015, 07:49:43 pm »


               

Awesome stuff. That is realy realy cool. There is even a flowing type of a stream in it. Thats just great for other effects as well!


Thanks a lot MD '<img'>



               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #9 on: January 16, 2015, 07:54:05 pm »


               

I am pulling apart torchlight 2 mod packs now in search of more high quality flowing water. I found one with rapids



               
               

               
            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #10 on: January 16, 2015, 07:59:07 pm »


               

If you know the old game vietcong they have terrific water and waterfall textures too. I guess it´s somewhere on my HD hidden..... i always loved their streams and with your new way of designing water in general just awesome '<img'>


Heh, i just thought about a thing for a sec. we have 2015 and now a new way of doing water... 10 years or so later '<img'>


 


oh and a cool idea maybe. You could now do a pretty cool texture for a bubbling cauldron. Just paint the bubbles and splashes in the soup itself and there you go!



               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #11 on: January 16, 2015, 09:59:41 pm »


               

I've pretty much exhausted TL2 now, so I am moving on to patching gimp scripts together so we can do animated water/lava/cauldrons that way



               
               

               
            

Legacy_Sheldomar

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #12 on: January 17, 2015, 12:25:50 am »


               

I haven't really gotten chance to dig into all your work on this yet, but it looks great so far. If I'm not mistaken, I think Senemenalas' Terria tileset has animated flowing streams in it... I'm not sure if he used the same method though. I used the same kind of animated texture for a few tiles of my own forest addon as well - the fountain in the screenshot linked below uses one I cobbled together in Photoshop. It's not perfect by any means, but I prefer it to emitter based water.


 


http://imgur.com/TXAdwmd



               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #13 on: January 18, 2015, 08:41:18 am »


               

Hey MD, for what it's worth, I just wanted to pass on that using a filerange .txi does appear to work to load textures which you then can proceduretype cycle with.  I've only done it for a filerange of two textures but I still thought it was worth mentioning.  My experience is pretty limited but it might actually be a way to get around the size of large animations because, IIRC, you can use DDS (and thus, compression) for the individual files you're loading in the filerange.


 


Because of the particular textures I was using and the mesh I was applying them to, there's a small chance this observation is in error.  But I don't think so.  The .txi can be as simple as to just contain filerange 2 and proceduretype cycle.


 


Cheers!



               
               

               
            

Legacy_MerricksDad

  • Hero Member
  • *****
  • Posts: 2105
  • Karma: +0/-0
In search of possible unknown TXI command
« Reply #14 on: January 18, 2015, 09:42:31 pm »


               

1310650820313.jpgjizz3.jpg


 


OTR is on to something! I just tried it with fps 8, proceduretype cycle, filerange 4, and I input 4 64x64 images. It accepted my images and built a single image from them, positioning each individual along the y axis. Basically it does the opposite of what I did, which was along the x axis. To get it to actually animate, I had to then supply numy 4, numx 1. Seems flawless. Just be sure you have an image ending with 0, or it will crash both the game and the toolset pretty hard. Remember, indexes for this input starts with 0, not 1 (yup, I forgot).


 


I also tried it on larger images, and had less success. I supplied 10 512 images with a single 256 image, and while they loaded in the toolset, it crashes the game instantly. This is where I first noticed that the internal workings takes all images and makes a frame strip. Without animation, all I saw was 10 lines that vaguely represented my 10 input images. I was unsure if they were x or y axis since they were so messed up. Turns out after guessing X, it was Y.


 


I'll definitely be playing with this some more, mostly because I want to know the exact limits. Not sure if it was the combination of image sizes, or the overall image size. Technically 10 images at 512 height is NOT a valid image size in game for my video card. Perhaps that is the culprit. Maybe 16 would work? The included 256 image seemed to be stretched to fit, but I wasn't entirely sure what I was seeing, so I could be wrong on that point.


 


More testing. More fun!


 


Edit:


 


I take back the flawless part. Both in game and in the toolset, there is a definite multicolored line at one of the cut points. Something in the math is wrong internally when it cuts the internally made strip apart. Perhaps it could be a simple downscale issue. Maybe some of those functions would help keep the quality.