Author Topic: Install Terragen 3 on Ubuntu 14.10  (Read 4339 times)

Offline nooby

  • Member
  • *
  • Posts: 7
Install Terragen 3 on Ubuntu 14.10
« on: December 18, 2014, 12:19:33 PM »
1. Download Terragen package from terragen site and unzip it
Code: [Select]
unzip terragen-package.zipRemember to copy and paste license file to folder with Terragen

2. Install required packages:
Code: [Select]
sudo apt-get update && sudo apt-get install freeglut3 && sudo apt-get install libjpeg62
3. Export terragen path
Code: [Select]
export TERRAGEN_PATH=~/
4.To open and render project.tgd and save result as test.tif file and exit terragen:
Code: [Select]
./terragen -p project.tgd -exit -r -o test.tif
5. I connect to my headless machine remotely, so I always run project within screen:
If you don't have screen install it by typing:
Code: [Select]
sudo apt-get install screen
So let's start new screen session:
Code: [Select]
screen -S mysession
6. If you want to shutdown your machine after work has been finished simply create script:

Code: [Select]
logfile="/var/log/terragen.log"
! /bin/bash

case "$(pidof terragen | wc -w)" in

0)  echo "Terragen not running, shutting down HP Workstation:     $(date)" >> $logfile
     /usr/bin/wget http://my-domain.com/terragen/stop.php
    rm terragen-stop.php
    sudo init 0
    ;;
1)  echo "Terragen is running, all OK:  $(date)" >> $logfile
    echo "Terragen is running OK"
    ;;

esac

I used second line of zero status for sending me email with date about status so I know that it has been finished.

7. I like to pipe output from terragen to log file, so I always run project like this:
Create screen session named 'mysession':
Code: [Select]
screen -S mysessionRun terragen project with output to log file:
Code: [Select]
./terragen -p project.tgd -exit -r -o test.tif > terragen.log
Leave screen session:
Code: [Select]
Ctrl + a  and ctr + d
And now you can exit terminal and process is still running on rendering machine.

If you want go back to session just, when you login again:
Code: [Select]
screen -D -r 'mysession'
This is very usefull because it helps me to view logs and rendering progress without logging to my machine, which is usually very overloaded.
I have my Terragen rendering machine in my room, and I don't have access to it from outside so I send my logs to another machine which is hosting my web page. If you don't have any server from where you can send emails or host your logs you can obtain very cheap VPS for 4-5$ per month or even less (BudgetVM  should be fine).

Let's start on your rendering machine:
- create script which will be invoked every 3 minutes
Code: [Select]
sudo nano terragen-status.sh Copy and paste this, and modify it to your needs:

Code: [Select]
#! /bin/bash
scp -P 6172 /home/user/Terragen/terragen.log root@my-remote-machine-address:/var/www/my-domain.com/terragen/
Save file and add privileges to file:
Code: [Select]
sudo chmod a+x terragen-status.sh
To make it works you would need to exchange ssh keys with the remote machine you're going to send your logs - this is a machine where you'll will be able to preview your logs for instance using your smartphone while walking with your dog.

You can exchange ssh keys by simply running:
Code: [Select]
ssh-keygenPress enter after every prompt. Next you will have to send it to remote machine:
Code: [Select]
ssh-copy-id -i ~/.ssh/id_rsa.pub root@my-domain-ip -p 22And starting from now your rendering machine will have free access to machine which we will use to display logs.

To invoke script every 3 minutes you need to create new cron operation:
Code: [Select]
crontab -eAnd copy & paste this:
Code: [Select]
*/3 * * * * /home/user/scripts/terragen-status.sh > /dev/null 2>&1Save and exit.

And You need to place some php file on you machine where you will read logs - I reversed log lines so latest operations are always at beginning.
So within your /var/www/my-domain.com/terragen/ directory on remote machine create index.php file with content:
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>HDRI environment maps and hdri skies</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes"/>
    <meta name="HandheldFriendly" content="true" />
    <meta name="apple-touch-fullscreen" content="YES" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="robots" content="NOINDEX,NOFOLLOW" />
    <title>Terragen rendering status check</title>
    <style type="text/css">
        body {background:#222;color:#666;}
    </style>
</head>
<body>
<?php
$file 
'terragen.log';
if(
file_exists($file))
{
    
$lines file($file);
    
$lines array_reverse($lines);
    foreach(
$lines as $line)
    {
        echo 
$line '<br />';
    }

} else {
    
print_r('<h2 style="color:red">No log file found !</h2>');
}
?>

</body>
</html>

That should be all.


Learn more at http://planetside.co.uk/wiki/index.php?title=Linux_Command_Line_Reference
« Last Edit: December 21, 2014, 03:22:45 PM by nooby »

Offline WASasquatch

  • Member
  • *
  • Posts: 806
  • to = ( be ) ? be : not;
Re: Install Terragen 3 on Ubuntu 14.10
« Reply #1 on: December 20, 2014, 07:39:18 PM »
Question, is this geared more towards a render farm? I'm wondering why you'd use Apache when you are on ubuntu and have built in resources to read the log files. It's a bit redundant and a strain on resources best saved for TG.

If this is for a Farm, I would also add how to remove redundant Ubuntu packages not ever needed, or should be running, with a Server. Desktop, GUI related applications and runtimes, etc. Ubuntu is not a good server when you need all the resources you can get, I'd definitely go with Debian or FreeBSD.
« Last Edit: December 20, 2014, 07:41:48 PM by WASasquatch »
Art can be a window into the soul

Offline Oshyan

  • Planetside Staff
  • *
  • Posts: 11745
  • Holy snagging ducks!
Re: Install Terragen 3 on Ubuntu 14.10
« Reply #2 on: December 20, 2014, 11:59:40 PM »
As is indicated in the sticky post at the top of this forum, we're really wanting people to put all new contents into the Wiki and not the forums.

- Oshyan

Offline nooby

  • Member
  • *
  • Posts: 7
Re: Install Terragen 3 on Ubuntu 14.10
« Reply #3 on: December 21, 2014, 03:14:11 PM »
Question, is this geared more towards a render farm? I'm wondering why you'd use Apache when you are on ubuntu and have built in resources to read the log files. It's a bit redundant and a strain on resources best saved for TG.

If this is for a Farm, I would also add how to remove redundant Ubuntu packages not ever needed, or should be running, with a Server. Desktop, GUI related applications and runtimes, etc. Ubuntu is not a good server when you need all the resources you can get, I'd definitely go with Debian or FreeBSD.

It is not a farm, it is just my extra Workstation I have in my room - I use it for rendering only while working on my primary computer.
And there is no Apache or any www server software installed - yes it has Unity, because I need it for other software, but if you want to make it for Terragen only you should go with Ubuntu Server edition  (I still preffer it over Debian or FreeBSD as it has larger community and newer packages).

Offline WASasquatch

  • Member
  • *
  • Posts: 806
  • to = ( be ) ? be : not;
Re: Install Terragen 3 on Ubuntu 14.10
« Reply #4 on: December 21, 2014, 06:30:34 PM »
Question, is this geared more towards a render farm? I'm wondering why you'd use Apache when you are on ubuntu and have built in resources to read the log files. It's a bit redundant and a strain on resources best saved for TG.

If this is for a Farm, I would also add how to remove redundant Ubuntu packages not ever needed, or should be running, with a Server. Desktop, GUI related applications and runtimes, etc. Ubuntu is not a good server when you need all the resources you can get, I'd definitely go with Debian or FreeBSD.

It is not a farm, it is just my extra Workstation I have in my room - I use it for rendering only while working on my primary computer.
And there is no Apache or any www server software installed - yes it has Unity, because I need it for other software, but if you want to make it for Terragen only you should go with Ubuntu Server edition  (I still preffer it over Debian or FreeBSD as it has larger community and newer packages).

Ubuntu does not have newer packages... they all usually run the universal, and generic versions of applications except Ubuntu who need to have customized packages for the dependent desktop environment. For example, try running a Ubuntu version of a app on Debian and watch the dependencies fly, install the same generic version and watch it ask for a couple things (if not already installed) I think you are mistaking Ubuntu's bloated system full of redundant dependencies you may or may not even need for being "new and easier". Which is why it's best, for rendering, to use a base system with only what you need installed.

In your tutorial you ask users to use PHP, and HTML, both cannot serve remotely without Apache.  You already ask users to install screen, and have SSH. So all you need to do is write a script like the others you wrote and cron in the logs on a screen to show logs via a terminal remotely, or locally. Then logs, local paths, etc, are not publicly available for sniffers and bots. Just having Apache without a well secured system is asking for a user to be targeted.

Then, you have private logs, which are for the most part live (depending on how you setup the script) and can simply run something like
Code: [Select]
screen -R tglogsOr by a script in some folder
Code: [Select]
tglogs.shOr whatever name/method you'd like. Remotely, or locally.

Additionally you can setup the script to run at startup with a initiate script.
« Last Edit: December 22, 2014, 06:37:20 AM by WASasquatch »
Art can be a window into the soul

Offline nooby

  • Member
  • *
  • Posts: 7
Re: Install Terragen 3 on Ubuntu 14.10
« Reply #5 on: December 23, 2014, 08:26:45 PM »
I reinstalled my OS and now running Debian without GUI. I just found bug or maybe I am missing some dependencies - Terragen doesn't save output to .tif
Code: [Select]
Warning: CreateObject: Unrecognised class: image_writer_tiffTried with .exr - the same.
I tried to save it as .bmp and it works but image is 100% black.
« Last Edit: December 23, 2014, 08:34:03 PM by nooby »

Offline nooby

  • Member
  • *
  • Posts: 7
Re: Install Terragen 3 on Ubuntu 14.10
« Reply #6 on: December 23, 2014, 08:41:14 PM »
OK, resolved - I was running it as a root...
« Last Edit: December 23, 2014, 08:42:52 PM by nooby »

Offline WASasquatch

  • Member
  • *
  • Posts: 806
  • to = ( be ) ? be : not;
Re: Install Terragen 3 on Ubuntu 14.10
« Reply #7 on: December 24, 2014, 07:19:10 PM »
OK, resolved - I was running it as a root...

Woops! Haha I doubt Terragen was written to use root and was assuming global vars based on a user account and their allowed assets.
Art can be a window into the soul