3 self.inline_data = True
5 def export_texture(self, texture):
6 from .datafile import Resource, Statement, Token
7 tex_res = Resource(texture.name+".tex2d")
9 if texture.use_interpolation:
10 if texture.use_mipmap:
11 tex_res.statements.append(Statement("min_filter", Token('LINEAR_MIPMAP_LINEAR')))
12 tex_res.statements.append(Statement("generate_mipmap", True))
14 tex_res.statements.append(Statement("min_filter", Token('LINEAR')))
15 tex_res.statements.append(Statement("max_anisotropy", texture.filter_eccentricity))
17 if texture.use_mipmap:
18 tex_res.statements.append(Statement("min_filter", Token('NEAREST_MIPMAP_NEAREST')))
19 tex_res.statements.append(Statement("generate_mipmap", True))
21 tex_res.statements.append(Statement("min_filter", Token('NEAREST')))
23 if not self.inline_data:
24 from .util import image_name
25 tex_res.statements.append(Statement("external_image", image_name(texture.image)))
28 colorspace = texture.image.colorspace_settings.name
30 fmt = 'SRGB_ALPHA' if colorspace=='sRGB' else 'RGBA'
31 for p in texture.image.pixels:
32 texdata += "\\x{:02X}".format(int(p*255))
34 fmt = 'SRGB' if colorspace=='sRGB' else 'RGB'
35 for i in range(0, len(texture.image.pixels), 4):
37 texdata += "\\x{:02X}".format(int(texture.image.pixels[i+j]*255))
38 tex_res.statements.append(Statement("storage", Token(fmt), texture.image.size[0], texture.image.size[1]))
39 tex_res.statements.append(Statement("raw_data", texdata))