I have a mesh, with 16 faces, that I ultimately show in Blender Game Engine, and want to apply separate textures to the faces via a script.
The reason behind this is I'm trying to show a detailed astrophysics skymap - currently zooming in shows pixelation, I managed to reduce the level of pixelation by increasing the texture size to 16kx16k, but I ended up using far too much RAM. I discovered that manually splitting the textures into 16 smaller chunks reduced the RAM usage (~25% of the texture is not being shown at one time, reducing RAM usage and pixelation at high zoom.
I tried to split the mesh into 32 individually textured faces and found that the rotation was much smoother and the RAM usage was further reduced.
I would obviously like to turn this workflow into a script. So far I have worked out how to texture an entire object as below, but cannot work out how to apply a different texture per face.
new_mat = bpy.data.materials.get('MaterialName') new_mat.use_nodes = True nodes = new_mat.node_tree.nodes links = new_mat.node_tree.links texture = nodes.new('ShaderNodeTexImage') texture.image = bpy.data.images['Earth.png'] texture.location = 0,0 surface = nodes.new('ShaderNodeBsdfPrincipled') surface.location = 300,0 output = nodes.new('ShaderNodeOutputMaterial') output.location = 600,0 link = links.new( texture.outputs['Color'], surface.inputs['Base Color'] ) link = links.new( surface.outputs['BSDF'], output.inputs['Surface'] )
Does anyone have any tips? Should I create separate objects, texture them individually then merge?