generateTextures.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. # Script to precalculate dir and plane values, as this keeps them in sync
  2. # However, this means no dynamic adjustments of the FOV,
  3. # as this is determined by the ratio between dir and plane vectors
  4. # currently resulting in an FOV of 2*atan(0.66/1.0)=66°
  5. from math import cos, sin, pi, pow
  6. import numpy as np
  7. from PIL import Image
  8. TEXTURE_NAME = "colorstone"
  9. rmap = [0,36,72,109,145,182,218,255]
  10. gmap = [0,36,72,109,145,182,218,255]
  11. bmap = [0,85,170,255]
  12. # print(str(doubleToFP16(planeY)) + ", ", end='')
  13. im = Image.open("Textures/" + TEXTURE_NAME + ".png")
  14. tex_array = np.array(im)
  15. print("{")
  16. for x in range(tex_array.shape[0]):
  17. for y in range(tex_array.shape[1]):
  18. r = tex_array[x][y][0]
  19. g = tex_array[x][y][1]
  20. b = tex_array[x][y][2]
  21. rval = min(range(len(rmap)), key=lambda i: abs(rmap[i]-r))
  22. gval = min(range(len(gmap)), key=lambda i: abs(gmap[i]-g))
  23. bval = min(range(len(bmap)), key=lambda i: abs(bmap[i]-b))
  24. print(str(rval*32+gval*4+bval) + ", ", end='')
  25. print()
  26. print("},")