Install Terragen 3 on Ubuntu 14.10

Started by nooby, December 18, 2014, 08:19:33 AM

Previous topic - Next topic

nooby

1. Download Terragen package from terragen site and unzip it
unzip terragen-package.zip
Remember to copy and paste license file to folder with Terragen

2. Install required packages:
sudo apt-get update && sudo apt-get install freeglut3 && sudo apt-get install libjpeg62

3. Export terragen path
export TERRAGEN_PATH=~/

4.To open and render project.tgd and save result as test.tif file and exit terragen:
./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:
sudo apt-get install screen

So let's start new screen session:
screen -S mysession

6. If you want to shutdown your machine after work has been finished simply create script:

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':
screen -S mysession
Run terragen project with output to log file:
./terragen -p project.tgd -exit -r -o test.tif > terragen.log

Leave screen session:
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:
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
sudo nano terragen-status.sh
Copy and paste this, and modify it to your needs:

#! /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:
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:
ssh-keygen
Press enter after every prompt. Next you will have to send it to remote machine:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@my-domain-ip -p 22
And 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:
crontab -e
And copy & paste this:
*/3 * * * * /home/user/scripts/terragen-status.sh > /dev/null 2>&1
Save 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:
<!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

WAS

#1
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.

Oshyan

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

nooby

Quote from: WASasquatch on December 20, 2014, 03: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.

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).

WAS

#4
Quote from: nooby on December 21, 2014, 11:14:11 AM
Quote from: WASasquatch on December 20, 2014, 03: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.

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
screen -R tglogs
Or by a script in some folder
tglogs.sh
Or whatever name/method you'd like. Remotely, or locally.

Additionally you can setup the script to run at startup with a initiate script.

nooby

#5
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
Warning: CreateObject: Unrecognised class: image_writer_tiff
Tried with .exr - the same.
I tried to save it as .bmp and it works but image is 100% black.

nooby

#6
OK, resolved - I was running it as a root...

WAS

Quote from: nooby on December 23, 2014, 04:41:14 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.