From 1d2d97b2491485a145d1df3704055c24f7b32cc7 Mon Sep 17 00:00:00 2001 From: Trololp <71960487+Trololp@users.noreply.github.com> Date: Sat, 8 May 2021 12:51:45 +0500 Subject: [PATCH] Add files via upload --- post_process_normals.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 post_process_normals.py diff --git a/post_process_normals.py b/post_process_normals.py new file mode 100644 index 0000000..8bea015 --- /dev/null +++ b/post_process_normals.py @@ -0,0 +1,28 @@ +from PIL import Image +import math +import sys + + +im = Image.open(sys.argv[1]) +im = im.convert('RGBA') + +sizex, sizey = im.size[0], im.size[1] + +print(sizex, sizey) + +#this is bad way to do this but it work. It so slow... +for x in range(sizex): + for y in range(sizey): + pixel = im.getpixel((x, y)) + #if (255*255*4 - pixel[3]*pixel[3] - pixel[1]*pixel[1] >= 0): + # + #else: + # new_pixel = (0,0,255,255) + new_pixel = (pixel[3], pixel[1], int(math.sqrt(255*255*4 - pixel[3]*pixel[3] - pixel[1]*pixel[1])), 255)#maybe incorrect !!! + im.putpixel((x, y), new_pixel) + +im.show() + +#assume that it is .tga or .dds + +im.save(sys.argv[1][:-4] + '_processed.tga', 'TGA') \ No newline at end of file