LOD texture fix script

From the Oblivion ConstructionSet Wiki
Revision as of 22:24, 5 August 2006 by imported>GhanBuriGhan (typos - it's late)
Jump to navigation Jump to search

By GhanBuriGhan

This is an applet that replaces the texture assembly routine for LOD landscape textures, which is buggy for some users, resulting in half-black LOD textures. This rough-around the edges solution is based on a script by shaja, to whom I am deeply indebted. I am not a great programmer, and this is my first time messing with Phyotn. Nevertheless, I will try to get an executable verion soon.

What you need

Walkthrough

  1. Install DDS converter, Phyton and PIL, these are standard windows installs.
  2. Create a directory C:\obwrk
  3. Create the partial textures as usual in the CS. See Landscape_LOD_Tutorial
  4. Start the DDS converter
    1. In the DDS converter, navigate to C:\obwrk
    2. Select all files
    3. Select DDS as the input format
    4. Select TGA as the output format
    5. Select C:\obwrk as the output folder
  5. Start IDLE - the Phyton shell
    1. In the menu choose File->New window
    2. Copy the code below into the new window
    3. Save it
    4. Select Run->Run module
    5. You now have to enter the ID / Hashcode for your textures: Its the first long number in the filename of your partials.
    6. Also enter the Cell coordinates of the upper right hand cell in each of your quads. E.g. 32,32 or 0,32 or 32,0 or 0,0 for the central four quads, respectively.

The script will then execute and create a png file with your assembled texture. Repeat this for each quad.

  1. Go back to DDS converter, and convert the png files back to DDS, using the data/textures/landscapelod/generated folder as the output folder
  2. You are done!

I hope this will help people until Bethesda fixes this little bug


Code:

import os, Image, ImageOps

WRKDIR = 'c:/obwrk'
name = raw_input ('Enter hashcode ID of texture set ')
TRX = raw_input('Enter this quads upper right cell x coordinate ')
TRY = raw_input('Enter this quads upper right cell y coordinate ')

name = int(name)
TRX = int(TRX) + 1
TRY = int(TRY) + 1
BLX = TRX-32
BLY = TRY-32

BL = (BLX,BLY)
TR = (TRX,TRY) # actually +1 (fencepost)
TILESIZE = 64


os.chdir(WRKDIR)

outim = Image.new('RGB', (1024, 1024))
xoffset = 0
yoffset = 0
xrange = range(BL[0],TR[0], 2)
yrange = range(BL[1], TR[1], 2)
yrange.reverse()
for x in xrange:
    for y in yrange:
        print "%d.%d.%d.64.tga (%d,%d)" % (name, x, y, xoffset, yoffset)
        inim = Image.open("%d.%d.%d.64.tga" % (name,x,y))
        outim.paste(inim, (xoffset, yoffset))
        yoffset += TILESIZE
    xoffset += TILESIZE
    yoffset = 0
outim = ImageOps.flip(outim)
BLX = BLX-1
BLY = BLY-1
outim.save("%d.%02d.%02d.32.png" % (name, BLX, BLY))