Git Product home page Git Product logo

cube2sphere's Introduction

cube2sphere PyPI version PyPI

cube2sphere is a Python script to map 6 cube (cubemap, skybox) faces into an equirectangular (cylindrical projection, skysphere) map. See also sphere2cube.

Usage

$ cube2sphere -h
usage: cube2sphere [-h] [-v] [-r <width> <height>] [-R <rx> <ry> <rz>]
               [-o <path>] [-f <name>] [-b <path>] [-t <count>] [-V]
               <front> <back> <right> <left> <top> <bottom>

Maps 6 cube (cubemap, skybox) faces into an equirectangular (cylindrical
projection, skysphere) map.

positional arguments:
  <front>               source front cube face filename
  <back>                source back cube face filename
  <right>               source right cube face filename
  <left>                source left cube face filename
  <top>                 source top cube face filename
  <bottom>              source bottom cube face filename

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -r <width> <height>, --resolution <width> <height>
                        resolution for rendered map (defaults to 1024x512)
  -R <rx> <ry> <rz>, --rotation <rx> <ry> <rz>
                        rotation in degrees to apply before rendering map (z
                        is up)
  -o <path>, --output <path>
                        filename for rendered map (defaults to "out")
  -f <name>, --format <name>
                        format to use when saving map, i.e. "PNG" or "TGA"
  -b <path>, --blender-path <path>
                        filename of the Blender executable (defaults to
                        "blender")
  -t <count>, --threads <count>
                        number of threads to use when rendering (1-64)
  -V, --verbose         enable verbose logging

Supported output formats depend on the Blender installation, but will generally include TGA, IRIS, JPEG, MOVIE, IRIZ, RAWTGA, AVIRAW, AVIJPEG, PNG, BMP, and FRAMESERVER.

cube2sphere can be run in a headless environment (e.g., a server).

Examples

If we wanted to stitch 6 cube faces named ${face}.jpg into a 2048x1024 TGA equirectangular map, we could use the following command:

$ cube2sphere front.jpg back.jpg right.jpg left.jpg top.jpg bottom.jpg -r 2048 1024 -fTGA -ostitched

This would generate stitched.tga in the working directory.

Installation

cube2sphere can be easily installed with pip. It requires a Python 3 installation.

It assumes that Blender is installed and the blender executable is listed in the system PATH environment variable. If it is not possible for PATH to be edited (as in the case of an unprivileged user), the path to the blender executable may instead be passed through the -b flag.

Windows

Install Blender, and add blender.exe to PATH. Finally,

pip install cube2sphere

Linux

$ apt-get install blender
$ pip install cube2sphere

Mac OS X

Similar to Windows, install Blender, and add the blender executable to $PATH. Then,

$ pip install cube2sphere

cube2sphere's People

Contributors

borischumichev avatar wouterla avatar xyene avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cube2sphere's Issues

It doesnt utilize my GPU

add this code to blender_init.py seem to solve the issue

def enable_gpus(device_type, use_cpus=False):
    preferences = bpy.context.preferences
    cycles_preferences = preferences.addons["cycles"].preferences
    cycles_preferences.refresh_devices()
    devices = cycles_preferences.devices

    if not devices:
        raise RuntimeError("Unsupported device type")

    activated_gpus = []
    for device in devices:
        if device.type == "CPU":
            device.use = use_cpus
        else:
            device.use = True
            activated_gpus.append(device.name)
            print('activated gpu', device.name)

    cycles_preferences.compute_device_type = device_type
    bpy.context.scene.cycles.device = "GPU"

    return activated_gpus


enable_gpus("CUDA")

pip install

Hello Xyene, thank you for providing this awesome tool.

When trying to install (on OSX) using
pip install cube2sphere
I get the following error
Could not find a version that satisfies the requirement cube2sphere (from versions: ) No matching distribution found for cube2sphere
Is this a Python error on my end? Or something that needs to be updated in the project?
I am running Python 5.3.1 with pip 8.1.1

Thanks,
Adam

Getting pink output

When I try to stitch together images I've generated from sphere2cube I just get pink output. I'm using blender 3.4. There was a similar issue listed in sphere2cube that seemed to be fixed when i applied this workaround posted by wk39:

workaround

edit
~/.local/bin/pythonXXX/site-packages/sphere2cube/blender_init.py
(installation directory may differ. you can check by 'pip show sphere2cube')

comment out below line

bpy.data.textures[0].image = bpy.data.images.load("%s" % sys.argv[-6])

add new line

bpy.data.images['test.jpg'].filepath = "%s" % sys.argv[-6]

Anyone find a workaround for cube2sphere as well? Should I just try an older version of blender?

pip install

Blender 2.81a
Python 3.7.4
windows 10

Hello Xyene,
thanks a lot for your script

I am trying to install using pip install cube2sphere but get this

C:\WINDOWS\system32>pip install cube2sphere
Collecting cube2sphere
Using cached cube2sphere-0.1.8.zip (150 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\alejandro\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\ALEJAN1\AppData\Local\Temp\pip-install-am3kkxig\cube2sphere\setup.py'"'"'; file='"'"'C:\Users\ALEJAN1\AppData\Local\Temp\pip-install-am3kkxig\cube2sphere\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\ALEJAN1\AppData\Local\Temp\pip-install-am3kkxig\cube2sphere\pip-egg-info'
cwd: C:\Users\ALEJAN
1\AppData\Local\Temp\pip-install-am3kkxig\cube2sphere
Complete output (8 lines):
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\ALEJAN1\AppData\Local\Temp\pip-install-am3kkxig\cube2sphere\setup.py", line 4, in
import ez_setup
File "C:\Users\ALEJAN
1\AppData\Local\Temp\pip-install-am3kkxig\cube2sphere\ez_setup.py", line 106
except pkg_resources.VersionConflict, e:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I´m not the most efficient user with coding but will try my best to fix this if there would be a solution

Thanks in advance

cube2sphere is simply launch blender

On my Ubuntu 20 machine, running cube2sphere seems to open up the blender app, and then doesn't do anything..

Strangely, on my other Ubuntu 20 machine, running cube2sphere works fine..

Any ideas on what the problem might be?

Output is always 2048x1024

  • Ubuntu 16.04
  • Blender 2.76b
  • cube2sphere from pip

Works perfect! Except the output resolution is always 2048x1024. I checked the projector.blend file and saw that's the default image size. The settings aren't being transferred to Blender correctly. Manually changing the render resolution to 8192x4096@50% worked for my project.

Transparency.

When I provide Transparent PNG files as the 6 face sources. The output does not keep the transparency, it as a black background.

I tried adding "scene.render.film_transparent = True" to the blender_init.py script but it did not do the trick.

Any suggestions ?

Having trouble running

When I run the command cube2sphere windows just complains there is no command, script, batch file, etc. It installed just fine with pip but apparently didn't register to any globals to use it anywhere. What do I do from here?

I tried both on Windows and Linux now, and both OS's don't recognize "cube2sphere" as a command, and it's not located in default location where pip instals site or dist packages.

The setup appears to be correct unless there is something I'm not seeing:

pip install cube2sphere
Collecting cube2sphere
  Downloading https://files.pythonhosted.org/packages/5e/f6/2ce7f7417029b80f69ef40901ad244d80b81ec97f6343b0743fe1cd24312/cube2sphere-0.2.1.tar.gz (150kB)
    100% |████████████████████████████████| 153kB 477kB/s
Building wheels for collected packages: cube2sphere
  Running setup.py bdist_wheel for cube2sphere ... done
  Stored in directory: /home/was/.cache/pip/wheels/91/f9/62/828fd60e067066a7075dd00e57d34f7a41f1ba260763d4f1e5
Successfully built cube2sphere
Installing collected packages: cube2sphere
Successfully installed cube2sphere-0.2.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.