Repair styles.

This commit is contained in:
jmsgrogan 2017-10-25 12:53:00 +01:00
parent 7925c4b926
commit 25f03af0e2
20 changed files with 58 additions and 51 deletions

View file

@ -4,10 +4,12 @@ import bpy
import product_gen.generate_lamp import product_gen.generate_lamp
import rendering.setup_scene import rendering.setup_scene
import rendering.setup_renderer import rendering.setup_renderer
from shapes.shape_description import _styles
def generate(shape_parameters, output_prefix, is_final=False): def generate(shape_parameters, output_prefix, is_final=False):
rendering.setup_renderer.setup_renderer(shape_parameters) rendering.setup_renderer.setup_renderer(shape_parameters,
is_final)
rendering.setup_scene.initialize_scene(shape_parameters) rendering.setup_scene.initialize_scene(shape_parameters)
@ -18,19 +20,13 @@ def generate(shape_parameters, output_prefix, is_final=False):
product_gen.generate_lamp.optimize_for_render(models) product_gen.generate_lamp.optimize_for_render(models)
# Set up materials and textures # Set up materials and textures
color = (0.1, 0.1, 0.1) style = _styles[shape_parameters["style"]]
colors = [(0.1, 0.1, 0.1),
(0.68, 0.68, 0.68),
(0.033, 0.065, 0.376),
(0.019, 0.202, 0.032)]
color = random.choice(colors)
if "bio" not in shape_parameters["shape"]: if "bio" not in shape_parameters["shape"]:
colormap = {"shade": color, colormap = {"shade": style["shade"],
"base": (132.0/255.0, 64.0/255.0, 11.0/255.0), "base": style["base"],
"chord": (5.0/255.0, 5.0/255.0, 5.0/255.0)} "chord": style["chord"]}
else: else:
colormap = {"shade": color} colormap = {"shade": style["shade"]}
product_gen.generate_lamp.apply_textures(colormap, models) product_gen.generate_lamp.apply_textures(colormap, models)
@ -39,15 +35,8 @@ def generate(shape_parameters, output_prefix, is_final=False):
# Do rendering # Do rendering
prefix = os.getcwd() + "/" + output_prefix + "/" + output_prefix prefix = os.getcwd() + "/" + output_prefix + "/" + output_prefix
if is_final: if is_final:
bpy.context.scene.render.filepath = prefix + "_kitchen.png" bpy.context.scene.render.filepath = prefix + "_highres.png"
bpy.ops.render.render(write_still=True) bpy.ops.render.render(write_still=True)
bpy.context.scene.render.filepath = prefix + "_hall.png"
bpy.ops.render.render(write_still=True)
bpy.context.scene.render.filepath = prefix + "_landing.png"
bpy.ops.render.render(write_still=True)
else: else:
bpy.context.scene.render.filepath = prefix + ".png" bpy.context.scene.render.filepath = prefix + ".png"
bpy.ops.render.render(write_still=True) bpy.ops.render.render(write_still=True)

View file

@ -122,7 +122,6 @@ def generate_mesh_shade(shape_parameters):
radius1-shape_parameters["fixture_radius"], radius1-shape_parameters["fixture_radius"],
morph_type=shape_parameters["division_pattern"]) morph_type=shape_parameters["division_pattern"])
rad += shape_parameters["fixture_radius"] rad += shape_parameters["fixture_radius"]
print(radius1, rad, shape_parameters["fixture_radius"])
vert.co.x += rad vert.co.x += rad
if vert.co.x>max_rad: if vert.co.x>max_rad:
max_rad = vert.co.x max_rad = vert.co.x

View file

@ -1,13 +1,12 @@
import bpy import bpy
def setup_renderer(shape_parameters, engine="CYCLES"): def setup_renderer(shape_parameters, is_final=False, engine="CYCLES"):
# Set up and do the render # Set up and do the render
this_scene = bpy.context.scene this_scene = bpy.context.scene
if engine=="CYCLES": if engine=="CYCLES":
this_scene.render.engine = 'CYCLES' this_scene.render.engine = 'CYCLES'
this_scene.cycles.device = 'CPU' this_scene.cycles.samples = 100.0
this_scene.cycles.samples = 12.0
this_scene.cycles.caustics_reflective = False this_scene.cycles.caustics_reflective = False
this_scene.cycles.caustics_refractive = False this_scene.cycles.caustics_refractive = False
this_scene.cycles.max_bounces = 0.0 this_scene.cycles.max_bounces = 0.0
@ -17,9 +16,17 @@ def setup_renderer(shape_parameters, engine="CYCLES"):
this_scene.render.border_min_y = 0.33 this_scene.render.border_min_y = 0.33
this_scene.render.border_min_x = 0.25 this_scene.render.border_min_x = 0.25
this_scene.render.border_max_x = 0.65 this_scene.render.border_max_x = 0.65
if is_final:
this_scene.render.resolution_x = 1200.0
this_scene.render.resolution_y = 1200.0
else:
this_scene.render.resolution_x = 600.0 this_scene.render.resolution_x = 600.0
this_scene.render.resolution_y = 600.0 this_scene.render.resolution_y = 600.0
this_scene.render.tile_x = 32 this_scene.render.tile_x = 32
this_scene.render.tile_y = 32 this_scene.render.tile_y = 32
this_scene.render.resolution_percentage = 50.0
if is_final:
this_scene.render.resolution_percentage = 70.0
else:
this_scene.render.resolution_percentage = 100.0
this_scene.render.image_settings.compression = 60.0 this_scene.render.image_settings.compression = 60.0

View file

@ -43,6 +43,9 @@ def setup_scene(shape_parameters):
xloc = 1.5 + (3.0*radius + height)/2.0 xloc = 1.5 + (3.0*radius + height)/2.0
zloc = -0.4 - height zloc = -0.4 - height
if shape_parameters["shape"] == "bio" or shape_parameters["shape"] == "led":
bpy.data.objects["Camera"].location = (13, 0.0000, -3.0)
else:
bpy.data.objects["Camera"].location = (xloc, 0.0000, zloc) bpy.data.objects["Camera"].location = (xloc, 0.0000, zloc)
fov = 65.0 fov = 65.0

View file

@ -10,24 +10,28 @@ _shape_description = {"shape": "pendant",
"fixture_radius": 0.3, "fixture_radius": 0.3,
"fixture_length": 0.3, "fixture_length": 0.3,
"stem_length": 0.5, "stem_length": 0.5,
"style": "dark"} "style": "initial"}
_styles = {"dark" : {"shade": (0.1, 0.1, 0.1), _styles = { "dark" : {"shade": (0.68, 0.68, 0.6),
"chord": (0.05, 0.05, 0.05), "chord": (5.0/255.0, 5.0/255.0, 5.0/255.0),
"base": (0.05, 0.05, 0.05), "base": (132.0/255.0, 64.0/255.0, 11.0/255.0),
"use_wall": True, "use_wall": True,
"wall": (0.9, 0.9, 0.9)}, "wall": (0.9, 0.9, 0.9)},
"billard": {"shade": (0.1, 0.1, 0.1), "initial" : {"shade": (0.1, 0.1, 0.1),
"chord": (0.05, 0.05, 0.05), "chord": (5.0/255.0, 5.0/255.0, 5.0/255.0),
"base": (0.05, 0.05, 0.05), "base": (132.0/255.0, 64.0/255.0, 11.0/255.0),
"use_wall": True, "use_wall": True,
"wall": (0.9, 0.9, 0.9)}, "wall": (0.9, 0.9, 0.9)},
"light": {"shade": (0.1, 0.1, 0.1), "billard": {"shade": (0.033, 0.065, 0.376),
"chord": (0.05, 0.05, 0.05), "chord": (5.0/255.0, 5.0/255.0, 5.0/255.0),
"base": (0.05, 0.05, 0.05), "base": (132.0/255.0, 64.0/255.0, 11.0/255.0),
"use_wall": True, "use_wall": True,
"wall": (0.9, 0.9, 0.9)}, "wall": (0.9, 0.9, 0.9)},
} "light": {"shade": (0.019, 0.202, 0.032),
"chord": (5.0/255.0, 5.0/255.0, 5.0/255.0),
"base": (132.0/255.0, 64.0/255.0, 11.0/255.0),
"use_wall": True,
"wall": (0.9, 0.9, 0.9)}, }
_division_types = ["linear", _division_types = ["linear",
"logistic", "logistic",
@ -44,11 +48,10 @@ def get_random_shape_description(shape, bbox, feature_min):
shape_description = copy.deepcopy(_shape_description) shape_description = copy.deepcopy(_shape_description)
shape_description["shape"] = shape shape_description["shape"] = shape
feature_radius = feature_min[0] + random.random()*(bbox[0]-feature_min[0]) feature_radius = feature_min[0] + random.random()*(bbox[0]-feature_min[0])
#feature_height = 0.8*feature_radius
feature_height = feature_min[1] + random.random()*(bbox[1]-feature_min[1]) feature_height = feature_min[1] + random.random()*(bbox[1]-feature_min[1])
shape_description["height"] = feature_height shape_description["height"] = feature_height
shape_description["radius"] = feature_radius shape_description["radius"] = feature_radius
shape_description["division_pattern"] = random.choice(_division_types) shape_description["division_pattern"] = random.choice(_division_types)
shape_description["style"] = random.choice(list(_styles.keys())) shape_description["style"] = "initial"
return shape_description return shape_description

View file

@ -4,6 +4,7 @@ import ast
import random import random
import json import json
import product_gen.generate_product import product_gen.generate_product
from shapes.shape_description import _styles
from argparse import ArgumentParser from argparse import ArgumentParser
@ -24,10 +25,12 @@ if __name__ == "__main__":
shape_parameters["height"] = float(shape_params["height"]) shape_parameters["height"] = float(shape_params["height"])
shape_parameters["radius"] = float(shape_params["radius"]) shape_parameters["radius"] = float(shape_params["radius"])
shape_parameters["fixture_radius"] = float(shape_params["fixture_radius"]) shape_parameters["fixture_radius"] = float(shape_params["fixture_radius"])
shape_parameters["division_offsets"] = [float(x) for x in shape_params["division_offsets"]] shape_parameters["fixture_length"] = float(shape_params["fixture_length"])
shape_parameters["style"] = shape_params["style"] shape_parameters["stem_length"] = float(shape_params["stem_length"])
shape_parameters["division_patterns"] = shape_params["division_patterns"] shape_parameters["style"] = random.choice(list(_styles.keys()))
shape_parameters["division_radii"] = [float(x) for x in shape_params["division_radii"]] shape_parameters["division_pattern"] = shape_params["division_pattern"]
shape_parameters["division_param1"] = float(shape_params["division_param1"])
shape_parameters["division_param2"] = float(shape_params["division_param2"])
product_gen.generate_product.generate(shape_parameters, output) product_gen.generate_product.generate(shape_parameters, output)

View file

@ -24,9 +24,11 @@ if __name__ == "__main__":
shape_parameters["height"] = float(shape_params["height"]) shape_parameters["height"] = float(shape_params["height"])
shape_parameters["radius"] = float(shape_params["radius"]) shape_parameters["radius"] = float(shape_params["radius"])
shape_parameters["fixture_radius"] = float(shape_params["fixture_radius"]) shape_parameters["fixture_radius"] = float(shape_params["fixture_radius"])
shape_parameters["division_offsets"] = [float(x) for x in shape_params["division_offsets"]] shape_parameters["fixture_length"] = float(shape_params["fixture_length"])
shape_parameters["stem_length"] = float(shape_params["stem_length"])
shape_parameters["style"] = shape_params["style"] shape_parameters["style"] = shape_params["style"]
shape_parameters["division_patterns"] = shape_params["division_patterns"] shape_parameters["division_pattern"] = shape_params["division_pattern"]
shape_parameters["division_radii"] = [float(x) for x in shape_params["division_radii"]] shape_parameters["division_param1"] = float(shape_params["division_param1"])
shape_parameters["division_param2"] = float(shape_params["division_param2"])
product_gen.generate_product.generate(shape_parameters, output, is_final=True) product_gen.generate_product.generate(shape_parameters, output, is_final=True)

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"shape": "cone", "fixture_length": 0.3, "stem_length": 0.5, "style": "billard", "radius": 1.298856337538413, "division_pattern": "logistic", "division_param1": 1.0, "division_param2": 1.0, "output": "test789", "height": 2.2653976569924654, "fixture_radius": 0.3} {"division_param2": 1.0, "radius": 1.8509219558134604, "stem_length": 0.5, "division_param1": 1.0, "division_pattern": "hyperbolic_tan", "output": "test789", "shape": "bio", "style": "dark", "height": 1.3296018884322776, "fixture_radius": 0.3, "fixture_length": 0.3}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
{"stem_length": 0.5, "division_param1": 1.0, "fixture_length": 0.3, "output": "test91011", "height": 2.3703425509577607, "division_pattern": "sinusoid", "division_param2": 1.0, "style": "light", "shape": "cone", "radius": 1.1040660329988414, "fixture_radius": 0.3}

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB