Hello to all,
in my company I have to work with HDRI, I create them.
We upload all of them for our clients in Japan.
I always used Blender like a hobby, I never had to work with it.
I am also not a programmer.
Here I would like to share what I have done so fare and what is my final goal.
I have professional tools, that I can use, but I do as a challenge to myself, prefer to build something that better reflect what I imagine .
The Global goal is to create spheres with a photo texture inside( Hdri ), and export them to Unity.
The second step will be to add other things, like clickable zone or pop up, 3d models inside the sphere.
Since I have not much experience.
what I wrote above may be too fare or too difficult to achieve. I don’t know.
Everyone help an advice will be strongly appreciated.
After the code I will write the issues that I have and also Questions.
# This work is under Open Source Licence. # Simple Public License (SimPL-2.0) # Auther : Tsurubaso # A great thanks to the people that have helped me # AFWS from BlenderArtists. import bpy import os, glob import bmesh path = "C:\\test" outdir = os.path.join(path, "output") if not os.path.exists(outdir): os.mkdir(outdir) # effacer tout ce qui traine, et vlan OBJJ = bpy.ops.object OBJJ.select_by_type(extend=False, type='MESH') OBJJ.delete() OBJJ.select_by_type(extend=False, type='LAMP') OBJJ.delete() for jpg in glob.glob(os.path.join(path, "*.jpg")): imagew = bpy.data.images.load(jpg) # mettre en place Cycle et le node tree bpy.ops.scene.new(type='FULL_COPY') bpy.context.scene.name=imagew.name scn=bpy.context.scene scn.render.engine = 'CYCLES' scn.world.use_nodes = True wd = scn.world # creer une texture y mettre l'image, connectrer tout ca. bpy.ops.texture.new() nt = bpy.data.worlds[wd.name].node_tree # desole pour le naming, c'est de l'emprunt gradNode = nt.nodes.new(type="ShaderNodeTexEnvironment") backNode = nt.nodes['Background'] gradNode.location.x = backNode.location.x-300 gradNode.location.y = backNode.location.y gradColOut = gradNode.outputs['Color'] backColIn = backNode.inputs['Color'] nt.links.new(gradColOut, backColIn) mat = bpy.data.materials['Material'] tex = bpy.data.textures.new("SomeName", 'IMAGE') slot = mat.texture_slots.add() slot.texture = tex # Une image sur mon PC, ref # Use of Import os # Example ---- filepath = os.path.join('C:\\', 'Users', 'User_Name_Here', 'Desktop', 'picture_to_load.jpg') # connecting the image gradNode.image = imagew scn = bpy.context.scene # Create an empty mesh and the object. mesh = bpy.data.meshes.new('Basic_Sphere') basic_sphere = bpy.data.objects.new("Basic_Sphere", mesh) # Add the object into the scene. scn.objects.link(basic_sphere) scn.objects.active = basic_sphere basic_sphere.select = True # Construct the bmesh Sphere and assign it to the blender mesh. bm = bmesh.new() bmesh.ops.create_uvsphere(bm, u_segments=64, v_segments=32, diameter=5) bm.to_mesh(mesh) bm.free() bpy.ops.object.modifier_add(type='SUBSURF') bpy.ops.object.shade_smooth() #add material to sphere matos=bpy.data.materials.new(name=imagew.name) matos.use_nodes= True nodetree = matos.node_tree nodes= matos.node_tree.nodes texture_node = nodes.new(type='ShaderNodeTexImage') bsdf = nodes.get('Diffuse BSDF') texture_node.image = imagew nodetree.links.new(bsdf.inputs['Color'],texture_node.outputs['Color']) basic_sphere.data.materials.append(matos) for area in bpy.context.screen.areas: for space in area.spaces: if space.type == 'VIEW_3D': space.show_world = True space.show_floor = False space.show_axis_x = False space.show_axis_y = False space.show_axis_z = False bpy.ops.wm.save_as_mainfile(filepath='C:\\test\\output\\Work on Script .blend')
The Problems and Questions:
The image on the background is my first try to export to Unity. I will remove it late on.
The texture on the sphere does not look great. I don’t know what is wrong.
I have still to search this point on the web, I will have to switch the normal to have the texture inside the sphere, wright? Then the camera will be inside the sphere, do we need the material to be emitting light to see inside the sphere and to see also the texture itself.
Does all those settings will be properly exportable on Unity???
I will be really pleased if you were to give me some of your time to help me by your advice.
As I said previously I am not a programmer to be precise I am just a photograph,
your help will be mostly apreciated.
Have a nice day,
I need to unwrap the texture. Even sphere unwrap does not look great. How to obtain a clean texture???
Would you do it directly in Unity??