Compiling & Running Lithosphere 4


So I got interested into terrain editing software. Of the little free stuff I tried, I was marveled by lithosphere.

However it lacked some important UX enhancements (like undo/redo, saving to PNG, or a useful open/save file dialog).

It’s Open Source written in Python, so I tried to give it a shot myself. Problem is, it doesn’t come with instructions, and some of its dependencies are quite old. To run from source, you’ll need:

  • Clone lithosphere.
  • Clone halogen and use commit 22b876641fc0.
  • Clone gletools and use commit 5d9354d78633.
  • Get pyglet (more on this later)
  • Setuptools 0.6c11-py2.6 (more on this later)
  • Fresh installation of Python 2.6. I used Windows 10. On Ubuntu 14.04 I had Python2.7 installed and it didn’t want to run. I don’t know if this is because of python 2.7, or some other incompatibility. It sounds like the app is trying to seek in egg files and seek operation for egg files may have been removed from Python 2.7 (egg is just a renamed zip). Just a guess.

 

Getting pyglet

You could try cloning pyglet’s forked version of the author or the official pyglet version. But you’ll still have to figure which version he used. Luckily, the on lithosphere’s repo the binary egg files are included (btw. the egg files include both binary and source) inside lithosphere/dist/lithosphere.zip/lithosphere/pyglet-1.2dev-py2.6.egg

Copy-paste pyglet-1.2dev-py2.6.egg into C:\Python26\Lib\site-packages\pyglet-1.2dev-py2.6.egg

You’re done.

 

Getting setuptools

You don’t actually need setuptools, but it comes handy. You could try to download the latest version from the internet (setuptools-20.9.0-py2.6 at the time of writing), which works halogen and gletools, but it won’t work on lithosphere because of a missing “app” directive.

Like pyglet, just copy paste lithosphere/dist/lithosphere.zip/lithosphere/setuptools-0.6c11-py2.6.egg into C:\Python26\Lib\site-packages\setuptools-0.6c11-py2.6.egg

 

Building halogen & gletools

Go to halogen root dir and type:

C:\Python26\Python.exe setup.py install

Then repeat the same on gletools’ root dir.

This should create “halogen-0.1.1-py2.6.egg” and “gletools-0.1.0-py2.6.egg” in C:\Python26\Lib\site-packages

You can also use the binaries from /dist/lithosphere.zip; but it’s nice at least to be able to build this from the right source rather than magical solutions.

 

Running lithosphere

I don’t use setuptools here; since I’m intending to work very often on the program to do modifications, then run again. So a packaging step gets in the way. You’re going to need some modifications to get it to run:

 

1. Comment “#version” in all of the shader files (they’re on repo/lithosphere/shaders). They all say either “#version 120 core” or “#version 130 core” and this is causing GLSL compiler errors on AMD drivers. Dunno about other vendors. So just comment them. It’s a lot of files, so you may want to use Find & Replace in files.

 

2. Open lithosphere/main.py and add the following lines:

At line 2:

import sys, os, traceback
sys.path.append( '../' ) #<--- new line
from pyglet.gl import *

This will cause the “import lithosphere” to work as expected.

At the end of file:

main()

Without this the app will only load some python code, then exist right away.

Now go to lithosphere’s root folder and type:

cd lithosphere
C:\Python26\Python.exe main.py

And it should be running!

View post on imgur.com

 

Avoid installing halogen & gletools

If you plan on working on these two as well, you can avoid installation by adding their paths to sys.path:

import sys, os, traceback
sys.path.append( '../' ) #Add lithosphere
sys.path.append( 'G:/path_to/halogen' ) #Path to halogen's repo
sys.path.append( 'G:/path_to/gletools' ) #Path to gletools' repo
from pyglet.gl import *

After doing this, you may run into a few errors but those are easy to solve (missing module imports which are solved by opening the python file with the error, and adding the import line)
This trick is needed if you didn’t want to use setuptools.

As an interesting remark, the code provided in lithosphere 0.1.2 Alpha does not match any of the commits from the lithosphere repo. This version has ambient occlusion, which the repo lacks. This leads me to believe the binary version is a little more recent than the repo’s.

However the repo contains #version 130 in some of its files, while the binary only contains commented #version 120; which leads me to believe the repo version is more recent.

Anyway, you can open the egg file from lithosphere’s “binary” distribution, and copy paste the py files into the ones from the repo; and it will run and you’ll have the Ambient Occlusion feature.

Now back to studying this code so I can add some features.


Leave a comment

Your email address will not be published. Required fields are marked *

4 thoughts on “Compiling & Running Lithosphere

  • Stephan

    Man, this is awesome tool, but it crashes a lot.
    As regular user I want to work with it, but i cant. I made a scene for procedural rock wall http://i.imgur.com/caEoxCb.png but could not save it. The program just crashes when i hit obj save, or save heights

    Could you create some sort of exe or msi installer?

    • Matias Post author

      I won’t be creating some sort of exe or msi installer. I’m sorry.

      As for your crash, I did notice that if you double click in order to save it will crash; but if you single click on Save -> select folder and filename -> then click save; it will work.
      I also tried it on C:\lithosphere; rather than D:\lithosphere.
      I noticed the application doesn’t handle directories living in partitions other than C:\ very well.

      I was looking into using the regular system open and save dialog but I’m onto something else right now. I don’t think I will be touching it soon.