Genesis
Policy: 9ff102...100a
Owner:
Metadata:
{
"name": "Genesis",
"files": [
{
"src": "ipfs://QmXS1iD8jjeXuEPZguRbbQWU8dnEcymigJpDdyGQ7Wa1nc",
"name": "Genesis",
"mediaType": "model/gltf-binary"
},
{
"src": [
"{'index': '0000', 'name': 'Genesis', 'composition': 'horizontal",
"', 'textures': {'front': {'index': 0, 'num_props': 0, 'properti",
"es': {'multipliers': [], 'colors': [], 'distributions': [], 'ro",
"tations': []}}, 'right': {'index': 0, 'num_props': 0, 'properti",
"es': {'multipliers': [], 'colors': [], 'distributions': [], 'ro",
"tations': []}}, 'rear': {'index': 0, 'num_props': 0, 'propertie",
"s': {'multipliers': [], 'colors': [], 'distributions': [], 'rot",
"ations': []}}, 'left': {'index': 0, 'num_props': 0, 'properties",
"': {'multipliers': [], 'colors': [], 'distributions': [], 'rota",
"tions': []}}, 'top': {'index': 0, 'num_props': 0, 'properties':",
" {'multipliers': [], 'colors': [], 'distributions': [], 'rotati",
"ons': []}}, 'bottom': {'index': 0, 'num_props': 0, 'properties'",
": {'multipliers': [], 'colors': [], 'distributions': [], 'rotat",
"ions': []}}}}"
],
"name": "Genesis",
"mediaType": "text/json"
},
{
"src": [
"# unspins.qoob v1.1",
"import bpy",
"from bpy import context, data, ops",
"import numpy as np",
"import math",
"import json",
"from PIL import Image, ImageDraw",
"",
"# Set texture dimensions",
"dim = 1024",
"",
"# Provide JSON file name with metadata",
"qoob_json = 'qoob.json'",
"",
"with open(qoob_json) as f:",
" qoob = json.load(f)",
"",
"def norm(x , mean , std):",
" p = (np.pi*std) * np.exp(-0.5*((x-mean)/std)**2)",
" return p",
"",
"def scale_make2d(s,res):",
" u_range = 4294967293",
" scaled = np.interp(s, (s.min(), s.max()), (0, u_range))",
" two_d = np.tile(scaled, (res, 1))",
" return two_d",
"",
"def gen_face(face,res):",
" x = list(range(res))",
" u_range = 4294967293",
" mean = np.mean(x)",
" std = res /6",
" r = list(range(0,int(res/2)))",
" ramp = r + r[::-1]",
" p_1d = np.array(ramp)",
" c_1d = np.array(range(0,res))",
"",
"",
" p_2d = scale_make2d(p_1d,res)",
" c_2d = scale_make2d(c_1d,res)",
" dists = {'Normal': p_2d, 'CDF': c_2d}",
" channels = {'Red': 0, 'Green': 1, 'Blue': 2}",
" idx = face['index']",
" props = face['properties']",
" n = np.zeros((res, res, 3)).astype(np.uint32)",
" print(' - Generating texture: ' + str(idx).zfill(4))",
"",
" for i in range(face['num_props']):",
" mult = props['multipliers'][i]",
" col = props['colors'][i]",
" dist = props['distributions'][i]",
" rot = props['rotations'][i]",
" c = channels[col]",
" buffer = mult * np.rot90(dists[dist], k=(rot / 90))",
" n[ :, :, c ] = n[ :, :, c ] + buffer",
"",
" n = np.interp(n, (0, u_range), (0, 255)).astype(np.uint8)",
" pil_texture = Image.fromarray(n)",
"",
" return pil_texture",
"",
"def gen_texture(qoob):",
" xm = int(dim / 2)",
" bg = Image.new('RGBA', (dim * 4, dim * 4), (0,0,0,0))",
" draw = ImageDraw.Draw(bg)",
" ftop = gen_face(qoob['textures']['top'],dim+2)",
" ffront = gen_face(qoob['textures']['front'],dim)",
" fbottom = gen_face(qoob['textures']['bottom'],dim+2)",
" fleft = gen_face(qoob['textures']['left'],dim+2)",
" fright = gen_face(qoob['textures']['right'],dim+2)",
" frear = gen_face(qoob['textures']['rear'],dim+2)",
"",
"",
" bg.paste(im=ftop,box=(xm+dim-1, 0))",
" bg.paste(im=ffront,box=(xm+dim, dim))",
" bg.paste(im=fbottom,box=(xm+dim-1, dim * 2))",
" bg.paste(im=fleft,box=(xm-1, dim-1))",
" bg.paste(im=fright,box=(xm-1 + dim * 2, dim-1))",
"",
" if qoob['composition'] == 'vertical':",
" bg.paste(im=frear,box=(xm+dim-1, dim * 3))",
" if qoob['composition'] == 'horizontal':",
" frear = frear.transpose(Image.ROTATE_180)",
" bg.paste(im=frear,box=(xm+dim-1, dim * 3))",
"",
" bg = bg.transpose(Image.FLIP_TOP_BOTTOM)",
" bn = 1.0 / 255.0",
" bt = bpy.data.images.new('uvmap', ",
" width=dim*4,",
" height=dim*4,",
" alpha=True)",
" bg = bg.convert('RGBA')",
" bt.pixels.foreach_set((np.asarray(bg,",
" dtype=np.float32)",
" *bn).ravel())",
" bt.pack()",
" return bt",
"",
"if __name__ == '__main__':",
" ",
" qbid = qoob['index']",
" print('- Creating qoob'+qbid)",
" ",
" for item in bpy.data.objects:",
" bpy.data.objects.remove(item)",
"",
"",
" hig = dim/1000",
" lev = dim/10000",
" alt = hig*math.sqrt(3)/2",
" mesh = bpy.ops.mesh",
" mesh.primitive_cube_add(location=(0,0,0),size=hig)",
" bpy.context.object.name = 'qoob'",
" bpy.context.object.data.name = 'qoob'",
"",
" for m in bpy.data.materials:",
" bpy.data.materials.remove(m)",
" bpy.ops.object.material_slot_remove()",
"",
" scene = bpy.data.scenes['Scene']",
" bpy.data.objects['qoob'].select_set(True)",
" mat = bpy.data.materials.new(name='Material')",
" mat.use_nodes = True",
" bsdf = mat.node_tree.nodes['Principled BSDF']",
" ti = mat.node_tree.nodes.new('ShaderNodeTexImage')",
" ti.image = gen_texture(qoob)",
" mlinks = mat.node_tree.links",
" mlinks.new(bsdf.inputs['Base Color'], ti.outputs['Color'])",
" mlinks.new(bsdf.inputs['Emission'], ti.outputs['Color'])",
" mat.blend_method = 'BLEND'",
" ctx = context.view_layer.objects.active",
" ctx.data.materials.append(mat)",
" bsdf.inputs['Metallic'].default_value=0.3",
" bsdf.inputs['Specular'].default_value=0.5",
" bsdf.inputs['Roughness'].default_value=0.25",
" bsdf.inputs['Sheen Tint'].default_value=0.5",
" bsdf.inputs['IOR'].default_value=1.87",
" bsdf.inputs['Emission Strength'].default_value=0.7",
" bsdf.inputs['Alpha'].default_value= 0.9",
" scene.render.engine = 'BLENDER_EEVEE'",
"",
"",
" scene.frame_start = 0",
" scene.frame_end = 960",
" obj = bpy.context.active_object",
" obj.rotation_euler[0] = math.radians(45)",
" obj.rotation_euler[1] = math.radians(35.26)",
" obj.rotation_euler[2] = math.radians(-90)",
" obj.keyframe_insert(data_path='rotation_euler', frame=0)",
"",
" obj.rotation_euler[0] = math.radians(45)",
" obj.rotation_euler[1] = math.radians(395.26)",
" obj.rotation_euler[2] = math.radians(630)",
" obj.keyframe_insert(data_path='rotation_euler', frame=960)",
"",
" for i in range(30,961,60):",
" obj.location = 0, 0, alt + lev/2",
" obj.keyframe_insert(data_path='location', frame=i)",
"",
" for i in range(60,961,120):",
" obj.location = 0, 0, alt + lev",
" obj.keyframe_insert(data_path='location', frame=i)",
"",
" for i in range(0,961,120):",
" obj.location = 0, 0, alt",
" obj.keyframe_insert(data_path='location', frame=i)",
" ",
" fco = obj.animation_data.action.fcurves",
" fcc = len(fco.items())",
" for i in range(fcc):",
" fc = fco[i]",
" for mod in fc.modifiers:",
" try:",
" fc.modifiers.remove(mod)",
" except:",
" pass",
"",
"",
" modifier = fc.modifiers.new(type='CYCLES')",
" modifier.mode_before = 'REPEAT'",
" modifier.mode_after = 'REPEAT'",
"",
" mesh = bpy.ops.mesh",
" mesh.primitive_uv_sphere_add(radius=0.000000001,",
" enter_editmode=False,",
" align='WORLD',",
" location=(0,0,alt+lev))",
" bpy.context.object.name = 'dome'",
" bpy.context.object.data.name = 'dome'",
" ",
" ctx= bpy.context.copy()",
" ctx['active_object'] = None",
"",
" print('- Exporting ' + 'qoob'+qbid+'.glb')",
" bpy.ops.export_scene.gltf(",
" ctx,",
" export_format='GLB', ",
" export_image_format='AUTO', ",
" export_texcoords=True, ",
" export_materials='EXPORT', ",
" export_colors=True, ",
" export_cameras=False,",
" export_apply=False, ",
" export_animations=True, ",
" export_frame_range=True, ",
" export_frame_step=1, ",
" export_lights=False, ",
" filepath='qoob'+qbid, ",
" filter_glob='*.glb'",
" )"
],
"code": "qoob.py",
"mediaType": "text/python"
},
{
"env": "qoob.yml",
"src": [
"name: qoob",
"channels:",
" - defaults",
"dependencies:",
" - python=3.8.8",
" - numpy=1.21.2",
" - pillow=8.4.0",
" - json=2.0.9",
" - bpy=3.0.1"
],
"mediaType": "text/yaml"
}
],
"image": "ipfs://QmNWYE1c6sJvwvvJHNFKWKU4CDzHoUXmjSfi5jRVxvNhii",
"index": "0000",
"Creator": "WooH",
"Project": "unspins.qoob",
"Website": "https://unspins.io/",
"mediaType": "image/png",
"Properties": {
"Sum": 0,
"Textures": {
"top": "0000",
"left": "0000",
"rear": "0000",
"front": "0000",
"right": "0000",
"bottom": "0000"
},
"Composition": "Horizontal",
"Occurrences": 6
},
"Description": "Algorithmic 3D Art"
}








