LOD texture fix script

From the Oblivion ConstructionSet Wiki
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 Python. Nevertheless, I will try to get an executable version soon.

What you need[edit | edit source]

Walkthrough[edit | edit source]

  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 your data/textures/landscapelod/generated/partial folder, which holds the generated partial DDS textures.
    2. Select DDS as the input format
    3. Select all files
    4. Select TGA as the output format
    5. Select C:\obwrk as the output folder
    6. Click the Convert button
  5. Start IDLE - the Python shell. It should be in your windows start menu.
    1. In the IDLE 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.
  6. Go back to DDS converter, and convert the png files back to DDS, using the data/textures/landscapelod/generated folder as the output folder
  7. 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))