5 self.inline_data = True
7 def export_texture(self, texture):
8 from .datafile import Resource, Statement, Token
9 tex_res = Resource(texture.name+".tex2d")
11 if texture.use_interpolation:
12 if texture.use_mipmap:
13 tex_res.statements.append(Statement("min_filter", Token('LINEAR_MIPMAP_LINEAR')))
14 tex_res.statements.append(Statement("generate_mipmap", True))
16 tex_res.statements.append(Statement("min_filter", Token('LINEAR')))
17 tex_res.statements.append(Statement("max_anisotropy", texture.filter_eccentricity))
19 if texture.use_mipmap:
20 tex_res.statements.append(Statement("min_filter", Token('NEAREST_MIPMAP_NEAREST')))
21 tex_res.statements.append(Statement("generate_mipmap", True))
23 tex_res.statements.append(Statement("min_filter", Token('NEAREST')))
25 if not self.inline_data and texture.image.filepath:
26 from .util import image_name
27 tex_res.statements.append(Statement("external_image", os.path.basename(texture.image.filepath)))
30 colorspace = texture.image.colorspace_settings.name
32 fmt = 'SRGB_ALPHA' if colorspace=='sRGB' else 'RGBA'
33 for p in texture.image.pixels:
34 texdata += "\\x{:02X}".format(int(p*255))
36 fmt = 'SRGB' if colorspace=='sRGB' else 'RGB'
37 for i in range(0, len(texture.image.pixels), 4):
39 texdata += "\\x{:02X}".format(int(texture.image.pixels[i+j]*255))
40 tex_res.statements.append(Statement("storage", Token(fmt), texture.image.size[0], texture.image.size[1]))
41 tex_res.statements.append(Statement("raw_data", texdata))