Skip to content

Instantly share code, notes, and snippets.

@Tiefseetauchner
Last active June 28, 2022 10:34
Show Gist options
  • Save Tiefseetauchner/384d9b2a04ffec15e461e96bbc6bf956 to your computer and use it in GitHub Desktop.
Save Tiefseetauchner/384d9b2a04ffec15e461e96bbc6bf956 to your computer and use it in GitHub Desktop.
Blender: Create Minecraft Panorama Renders
"""Create cameras for the Minecraft title screen panorama"""
import bpy
import math
bpy.ops.object.empty_add(type='PLAIN_AXES', align='CURSOR')
camera_controller = bpy.context.object
camera_data = bpy.data.cameras.new(name='panoCam')
camera_data.angle = math.pi / 2
# North Camera
camera_object = bpy.data.objects.new('panorama_0', camera_data)
camera_object.rotation_euler = (math.pi / 2, 0.0, 0.0)
bpy.context.scene.collection.objects.link(camera_object)
camera_object.select_set(True)
# East Camera
camera_object = bpy.data.objects.new('panorama_1', camera_data)
camera_object.rotation_euler = (math.pi / 2, 0.0, -math.pi / 2)
bpy.context.scene.collection.objects.link(camera_object)
camera_object.select_set(True)
# South Camera
camera_object = bpy.data.objects.new('panorama_2', camera_data)
camera_object.rotation_euler = (math.pi / 2, 0.0, -math.pi)
bpy.context.scene.collection.objects.link(camera_object)
camera_object.select_set(True)
# West Camera
camera_object = bpy.data.objects.new('panorama_3', camera_data)
camera_object.rotation_euler = (math.pi / 2, 0.0, -math.pi * 1.5)
bpy.context.scene.collection.objects.link(camera_object)
camera_object.select_set(True)
# Up Camera
camera_object = bpy.data.objects.new('panorama_4', camera_data)
camera_object.rotation_euler = (math.pi, 0.0, 0.0)
bpy.context.scene.collection.objects.link(camera_object)
camera_object.select_set(True)
# Down Camera
camera_object = bpy.data.objects.new('panorama_5', camera_data)
camera_object.rotation_euler = (0.0, 0.0, 0.0)
bpy.context.scene.collection.objects.link(camera_object)
camera_object.select_set(True)
# Link Cameras
bpy.ops.object.parent_no_inverse_set(keep_transform=False)
# Select only the null cuz I know that people will get confused somehow
bpy.ops.object.select_all(action='DESELECT')
camera_controller.select_set(True)
{
"pack": {
"pack_format": 9,
"description": "Change the description to whatever you want or don't I don't care\nTiefseetauchner is pretty cool btw"
}
}

Usage

Running the script (for those who don't know, everyone else can skip this)

Copy the code above or download the file or do whatever. Just get the code, open your Blender Project you want to get a Pano of.

Go to the Scripting Tab at the top1 and make a new file with the "New" button, or execute bpy.ops.text.new() (/j)

Paste the code in there and press the ▶ button, it'll create a null object (axis thingi) and cameras parented to that. It creates it at the Cursor position, so keep that in mind. To move the cameras, move the axis (don't move the cameras, only select the axis, it'll be the only thing selected when you ran the script, don't move the cameras independently, it'll break everything and be no fun)

The important parts, settings to change

Set your render resolution to a square, it doesn't matter what resolution, I wouldn't go under 512, cuz then it'll look horrible.

Rendering it has two possibilities I can think of: either render each image seperately and save it, or use render burst (I hope you know how to install an addon)

Vanilla Blender

  1. Go to the outliner and select the first camera
  2. Press F12
  3. Save the render as the name of the camera, so panorama_x.png or save them as whatever and rename them later, but don't come asking for help when the stitching doesn't work correctly
  4. Repeat for all cameras
  5. Continue with Making the Resourcepack

Render Burst

  1. Go into the output properties and change the file path in output to wherever you want your renders to end up
  2. Go into the Render Properties, scroll down to the Render Burst section and press the "Render!" button
  3. Continue with Making the Resourcepack

Making the Resourcepack

  1. Make a folder for your resourcepack
  2. Add a pack.mcmeta file (see example above, and change the pack_format to whatever is in whenever you read this, or whatever version you need, go research I'm not here to guide you through making a texture pack)
  3. (Optional) Add a pack.png (idk what the restrictions are, I always make mine 64x64)
  4. Create the following folder structure:
yourCoolTexturePackFolder/
├─ assets/
│  ├─ minecraft/
│  │  ├─ textures/
│  │  │  ├─ gui/
│  │  │  │  ├─ title/
│  │  │  │  │  ├─ background/
│  │  │  │  │  │  ├─ panorama_0.png
│  │  │  │  │  │  ├─ panorama_1.png
│  │  │  │  │  │  ├─ panorama_2.png
│  │  │  │  │  │  ├─ panorama_3.png
│  │  │  │  │  │  ├─ panorama_4.png
│  │  │  │  │  │  ├─ panorama_5.png
├─ pack.png
├─ pack.mcmeta
  1. If it's not obvious, move the panorama images into the background folder
  2. Install the resource pack like any other
  3. Profit

Also please don't just copy paste my code into an addon, not cuz I don't want it to be used or smtg, but cuz it's horrible, I'll ask at mcprep if they want the functionality, and then I'll make the code, yk, not garbage

Footnotes

  1. If you're using pre 2.8 Blender, please upgrade, if you can't, the dropdown I think should have a tab, haven't touched an old version of Blender in years

@Tiefseetauchner
Copy link
Author

Btw an example

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment