Add glossy material for shade.

This commit is contained in:
jmsgrogan 2017-10-24 20:52:45 +01:00
parent 9035f01f2d
commit d440ff4d8f
10 changed files with 40 additions and 22 deletions

View file

@ -48,23 +48,42 @@ def optimize_for_render(models):
def apply_textures(colormap, models):
for eachName in colormap.keys():
mat = bpy.data.materials.get(eachName + "-material")
if mat is None:
mat = bpy.data.materials.new(name=eachName + "-material")
mat.diffuse_color = colormap[eachName]
mat.specular_color = colormap[eachName]
mat.diffuse_intensity = 1.0
mat.specular_intensity = 1.0
if "shade" in eachName:
mat.emit = 0.0
mat.translucency = 10
mat.use_transparency = True
mat = bpy.data.materials.get("shade-material")
if mat is None:
mat = bpy.data.materials.new("shade-material")
mat.use_nodes = True
mat.node_tree.nodes.new('ShaderNodeBsdfGlossy')
inp = mat.node_tree.nodes["Material Output"].inputs["Surface"]
outp = mat.node_tree.nodes["Glossy BSDF"].outputs["BSDF"]
mat.node_tree.nodes['Glossy BSDF'].inputs[0].default_value = (colormap[eachName][0],
colormap[eachName][1],
colormap[eachName][2]
,1)
mat.node_tree.links.new(inp, outp)
bpy.context.scene.objects.active = bpy.data.objects[eachName]
if bpy.context.active_object.data.materials:
# assign to 1st material slot
bpy.context.active_object.data.materials[0] = mat
else:
# no slots
bpy.context.active_object.data.materials.append(mat)
bpy.context.scene.objects.active = models[eachName]
if bpy.context.active_object.data.materials:
# assign to 1st material slot
bpy.context.active_object.data.materials[0] = mat
else:
# no slots
bpy.context.active_object.data.materials.append(mat)
mat = bpy.data.materials.get(eachName + "-material")
if mat is None:
mat = bpy.data.materials.new(name=eachName + "-material")
mat.diffuse_color = colormap[eachName]
mat.specular_color = colormap[eachName]
mat.diffuse_intensity = 1.0
mat.specular_intensity = 1.0
bpy.context.scene.objects.active = models[eachName]
if bpy.context.active_object.data.materials:
# assign to 1st material slot
bpy.context.active_object.data.materials[0] = mat
else:
# no slots
bpy.context.active_object.data.materials.append(mat)

View file

@ -35,13 +35,12 @@ def setup_scene(shape_parameters):
bpy.context.active_object.data.materials.append(mat)
# Set up cameras
bpy.data.objects["Camera"].location = (10.0, 0.0, -1)
bpy.data.objects["Camera"].location = (10.0, 0.0, -4)
fov = 65.0
bpy.data.objects["Camera"].data.angle = fov*(math.pi/180.0)
bpy.data.objects["Camera"].rotation_mode = 'XYZ'
bpy.data.objects["Camera"].rotation_euler[0] = math.pi/2.0
bpy.data.objects["Camera"].rotation_euler[1] = 0.0
# todo tilt down further for light render
bpy.data.objects["Camera"].rotation_euler[2] = math.pi/2.0
# Lamps

View file

@ -23,8 +23,8 @@ if __name__ == "__main__":
os.makedirs(os.getcwd() + "/" + output)
# Global bounding box
bbox_xmax = 2.2
bbox_ymax = 20.0
bbox_xmax = 4.0
bbox_ymax = 5.0
# Minimum feature sizes
feature_xmin = 0.4

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"division_offsets": [0.25, 0.25, 0.25, 0.25], "radius": 1.0601818200308606, "shape": "pendant", "height": 4.455460011829081, "style": "billard", "division_patterns": ["sine", "square", "sine", "inv_ramp"], "fixture_radius": 0.3, "division_radii": [0.5868447602079319, 0.596539544538136, 0.7007834420344027, 0.87385109148988]}
{"division_offsets": [0.25, 0.25, 0.25, 0.25], "radius": 0.5151794595751276, "height": 4.115548193330971, "division_patterns": ["inv_square", "inv_square", "square", "inv_sine"], "shape": "pendant", "style": "light", "division_radii": [0.9221841829622927, 0.9489520915432629, 0.9897309968469092, 0.994921834206689], "fixture_radius": 0.3}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 118 KiB