-
Notifications
You must be signed in to change notification settings - Fork 0
/
RenderAllMaterials.py
52 lines (36 loc) · 1.44 KB
/
RenderAllMaterials.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import bpy
import os
path_dir = bpy.context.scene.render.filepath #save for restore
basedir = os.path.dirname(bpy.data.filepath)
basedir = basedir + "/_Export_Tiles2/"
#for cam in [obj for obj in bpy.data.objects if obj.type == 'CAMERA']:
# print("AAAAAA")
# bpy.context.scene.camera = cam
#
# fn = os.path.join(basedir, cam.name)
# print(fn)
# bpy.context.scene.render.filepath = fn
# bpy.ops.render.render(write_still=True)
TextureSphere = bpy.data.objects["TextureSphere"]
#NewMaterial = bpy.data.materials.get("Grass_01")
#if NewMaterial is not None:
# TextureSphere.data.materials[0] = NewMaterial
renderAllCams = False
shouldRender = True
for material in bpy.data.materials:
print(material.name)
TextureSphere.data.materials[0] = material
for cam in [obj for obj in bpy.data.objects if obj.type == 'CAMERA']:
print("AAAAAA ddddddd")
shouldRender = True
if renderAllCams == False and cam.name == "closeup":
shouldRender = False
if material.name == "_ExampleMaterial":
shouldRender = False
if shouldRender:
bpy.context.scene.camera = cam
fn = os.path.join(basedir, material.name + "_" + cam.name)
print(fn)
bpy.context.scene.render.filepath = fn
bpy.ops.render.render(write_still=True)
print("Rendered", material.name, cam.name)