Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18

Thread: 16 Patch Tile

  1. #1
    Join Date
    Aug 2004
    Location
    Wichita, Kansas, USA.
    Posts
    525

    Question 16 Patch Tile

    I have been trying to achieve the 1 patch tile, so I could load a 2048x2048 terrtex, instead of 256 128x128 terrtexs, mainly to save time on creation and loading. As I got closer and closer, I began to think, perhaps, this isnt mathematically possible in MSTS. So, I eventually got it down to a 4x4 patch tile, meaning, there are 16 patches on the tile. Here is the decompiled terrain file:
    Code:
    [email protected]@@@@@@@@@JINX0txt______
    
    terrain (
    	terrain_samples (
    		terrain_nsamples ( 16 )
    		terrain_sample_floor ( -63 )
    		terrain_sample_scale ( 0.00195313 )
    		terrain_sample_size ( 8 )
    		terrain_sample_ybuffer ( "-0707559c_y.raw" )
    		terrain_sample_ebuffer ( "-0707559c_e.raw" )
    		terrain_sample_nbuffer ( "-0707559c_n.raw" )
    	)
    	terrain_shaders ( 2
    		terrain_shader ( DetailTerrain
    			terrain_texslots ( 2
    				terrain_texslot ( "terrain.ace" 1 0 )
    				terrain_texslot ( "microtex.ace" 1 1 )
    			)
    			terrain_uvcalcs ( 2
    				terrain_uvcalc ( 1 0 0 0 )
    				terrain_uvcalc ( 2 0 1 32 )
    			)
    		)
    		terrain_shader ( AlphaTerrain
    			terrain_texslots ( 1
    				terrain_texslot ( "terrain.ace" 1 0 )
    			)
    			terrain_uvcalcs ( 1
    				terrain_uvcalc ( 1 0 0 0 )
    			)
    		)
    	)
    	terrain_patches (
    		terrain_patchsets ( 1
    			terrain_patchset (
    				terrain_patchset_distance ( 0 )
    				terrain_patchset_npatches ( 4 )
    				terrain_patchset_patches (
    					terrain_patchset_patch ( 00000000 64 1 -64 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 576 1 -64 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1088 1 -64 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1600 1 -64 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 64 1 -576 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 576 1 -576 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1088 1 -576 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1600 1 -576 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 64 1 -1088 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 576 1 -1088 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1088 1 -1088 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1600 1 -1088 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 64 1 -1600 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 576 1 -1600 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1088 1 -1600 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    					terrain_patchset_patch ( 00000000 1600 1 -1600 99.48125 0 256 0 0.0001 0.0001 0.0625 0 0 0.0625 1 )
    				)
    			)
    		)
    	)
    )
    I quickly found out that MSTS and Mosaic will not load ASCII terrain files, and if I didnt delete the compiled file, each time I clicked compile, it would append to the already existing file.

    Well this is all great. It loads into Mosaic, and I can edit and save, but MSTS will NOT load the terrain file. Is it just not possible, or did I screw up the coding? I found out that the terrain file has to be mathematically square (). I'm thinking that it has to be a specific size, like the lowest size being 2048 pixels. Your thoughts?



  2. #2

    Default single terrtex

    I tried this but could not get it to work. As far as I know, we are stuck with the standard 16x16 patches for MSTS.

    Alternatively, it is possible to map a 2048x2048 terrtex to a tile by applying the relevant part of the terrtex to each patch. This is done by editing the numbers in the "terrain_patchset_patch" lines. Each of these lines represents one patch on the tile, starting top left on the tile and proceding in rows down to the bottom right.

    Editing all 256 "terrain_patchset_patch" lines is tedious, but you should only have to do it once. When complete, just copy them to any other terrain files you want map a single terrtex on.

    The 11th to 14th numbers in the "terrain_patchset_patch" line represent the size of the portion of the texture that will be appilied to the patch. Change 0.0625 to 0.003906 to get the required portion of 1/256 of total texture area.

    Now the tedious part, the 9th and 10th numbers in the line specify which part of the terrtex to map to the patch, or more specifically, the position of the top left of the terrtex portion in relation to the top left of the texture. Top left of the terrtex is 0,0, bottom right is 1,1.

    For example, the first row of patches start,
    ....0,0....
    ....0.0625,0...
    ....0.125,0...
    ....0.1875,0... and so on.
    The second row,
    ....0,0.0625....
    ....0.0625,0.0625...
    ....0.125,0.0625...
    ....0.1875,0.0625... and so on.

    This should give you a seamless terrtex across all 256 patches.

    It is some time since I did this, if I can find one of these terrain files I will post it.

  3. #3
    Join Date
    Aug 2004
    Location
    Wichita, Kansas, USA.
    Posts
    525

    Default 16 Patch Tile

    Holy crap dude, it worked! You are the man! Would you mind If I reposted the code? I hate to take without giving.
    Cody



  4. #4
    Join Date
    Nov 1999
    Location
    Another Planet
    Posts
    8,558

    Default

    Quote Originally Posted by septic08 View Post
    This should give you a seamless terrtex across all 256 patches.
    There's a problem with texture bleed when viewing the tile from a low angle (mipmapping). You can either use Mosaic to add a buffer automatically, or rescale and shift the textures to suit. One big texture will always bleed, however, so it would be better to cut the large texture into smaller squares, and then add a small buffer area - about 16 pixels for a 256 x 256 texture - around its edges. This will give a usable texture area of 224 x 224. Double these values for 512 x 512 textures.
    Cheers!
    Marc - 3DTrains - Home of the Feather River and Sherman Hill routes for MSTS

    Signature

  5. #5

    Default 16 patch tile

    Hi grunge69, no problem with reposting, you are welcome.

    I have attached a terrain file which does the job for a 2048x2048 texture including rescaling and shifting to reduce tile edge bleed as Marc suggested. I forgot about that! - it can spoil the view but there are ways round it, I used to hide the effect with scenery before I'd heard of mipmapping. I have not allowed for as many pixels as Marc suggested, it is probably best to experiment for yourself.

    Please note that I have also changed "terrain_uvcalc ( 2 0 1 32 )" to "terrain_uvcalc ( 2 0 1 512 )". This maintains the original microtex bump mapping scale.

    Derek.
    Attached Files Attached Files

  6. #6

    Default 16 Patch Tile

    I my last post, I included an example of a terrain file that maps a single texture over an entire tile. For anyone wishing to do this, I thought I should give some instructions on how to use it. Please note, you will need Route Riter and I have assumed that you already have the ".ace" texture file in your TERRTEX folder.

    Don't use the file attached to my previous message as I have since found some errors in it. Use the one attached to this post.

    This is what you do,

    1. Unzip the file and open in Wordpad. Look for the texture file (testterrtex.ace) and change the name to to your ace file. You will find that it occurs in two places near the begining of the file in the terrain_shaders section.

    2. Save the file as Unicode text (or just click the Save button) and close Wordpad.

    3. In Windows Explorer rename the file to your terrain file.

    4. Backup your original terrain file in your TILES folder, just in case.

    5. Run Route Riter and under the "MSTS File Utils" tab, compress the new terrain file to your TILES folder. Finally view the results in Route Editor.


    This approach can also be used to texture LO_TILES. MSTS normally textures a LO_TILE in a 4x4 repeating pattern making it difficult to represent a coastline or snow on a mountain summit for example. I can post a LO_TILE if anyone wants to try it.

    Derek.
    Attached Files Attached Files

  7. #7
    Join Date
    Aug 2004
    Location
    Wichita, Kansas, USA.
    Posts
    525

    Default Terrtex pointers

    Also, you have to change your raw files:
    Code:
    		terrain_sample_ybuffer ( "-0707559c_y.raw" )
    		terrain_sample_ebuffer ( "-0707559c_e.raw" )
    		terrain_sample_nbuffer ( "-0707559c_n.raw" )
    You HAVE to change your RAW buffers to the same filename as the file you are working in. Otherwise, I imagine, you make a change in one tile, and it changes in all other tiles.
    Codeman



  8. #8

    Default

    Good point! Also, it is worth mentioning that the file will work with other texture sizes, it doesn't have to be 2048x2048.

    Strictly speaking rescaling and shifting should be adjusted according to the texture size, but it is no big deal. Looking at my earlier attempts, I didn't bother with it at all and the terrain looked OK when running the sim.

    Not sure about this but I guess texture bleed is more of an issue if there are contrasting colours on opposite edges of the texture.

  9. #9
    Join Date
    Nov 1999
    Location
    ny, usa.
    Posts
    530

    Default I clicked on the link...

    but nothing happened. Is there another way I can get this file?
    I've started experimenting with terrain textures.

    Don't tell mommy, okay?

  10. #10
    Join Date
    Nov 1999
    Location
    ny, usa.
    Posts
    530

    Default 1 big texture

    I tried it, it worked, BUT it messed up the terrain.
    So, I'm cutting and pasting from the posted file
    to a decompiled file. I hope I won't have to edit
    all 256 lines, but it looks like some of the numbers
    are different in columns other than 9..14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •