Sonntag, 14. September 2014

Blender: Change Cycles render seed automatically

Here is a small Blender add-on to change the seed value for the Cycles render engine automatically before rendering a frame.

The seed value determines the noise pattern of a cycles render.

If you only render one image, this is of no concern for you.

If you render an animation, you get the same pattern for each frame which is very obvious for the viewer.

To counter this, you can enter #frame as seed value (creating a so called driver) which returns the frame number as seed value. This gives you a different noise pattern per frame which makes it look like film grain.

This obviously only works if you have an animation to render, but not with a single frame.

After installing the add-on you see an additional checkbox in the render samplig panel where you can switch this feature on or off.



Why to go the trouble to write an add-on for this?

Lately I have used image stacking a lot.

This technique allows you to reduce noise in pictures created by Cycles rendering engine by rendering the same frame multiple times - provided you change the render seed. You then can calculate the "average" of these pictures (e.g. using ImageMagick) cancelling out some noise.

If you want to a clearer version of an image that has just rendered over an hour, you save it and render it again, then stack the images. This is much faster than scrapping the first image and re-rendering it with a larger sample count.

After forgetting to change the seed value a couple of times, the level of suffering was high enough to make an add-on. :-)


Dienstag, 9. September 2014

How to "average" PNG files with ImageMagick

In a recent post on CgCookie Kent Trammell explained that you can improve the quality of a Cycles render by rendering the image multiple times if you use a different value for the sampling seed.


In his case those images were calculated by different computers of his render farm.

But the same is true, if you waited for an hour for a render to finish, and you are pleased with the image except for the noise.  In this case save the image, change the seed value and render it again.  This way the first hour was not in vain.

In any case you will end up with one or more PNG files with look similar except for the noise pattern which changes with the seed value.

If you calculate the mean image of these images the noise level will be reduced.

Kent Trammell showed how this calculation can be achieved with the Blender node editor (his math was a bit off, but the principle is sound).

The same could be accomplished with other programs like Photoshop or The Gimp or command line tools like ImageMagick.

The ImageMagick command for doing this is:

convert image1 image2 image3 -evaluate-sequence mean result

However, if you try this with PNG files that contain an alpha channel (RGBA) the result is a totally transparent image. 

In this case use the option "-alpha off", e.g. like this:

convert render*.png -alpha off -evaluate-sequence mean result.png

A final note: Keep in mind that all images will be loaded into memory during this process - i.e. you want to limit the number of images.

Donnerstag, 26. Juni 2014

Updating Syncthing on a Synology DM1812+

Syncthing is a secure directory syncing tool still in its early development stages which runs on various platforms like Linux, Windows, Mac, BSD and Solaris. There are already ports for Android and the Synology NAS.

  

How to install Syncthing on a Synology Diskstation

Disclaimer: These instructions were only tested on a DM1812+ with DSM 4.0. Your mileage may vary.

Open the Package Center and add under Settings the following Package Source

http://cytec.us/spk/

Click Refresh

You'll find the Syncthing package under "Other Sources" from which it can install it as usual.



You can control Syncthing via its web interface on

http://your_diskstation_ip:7070

That's it... You find instructions on how to operate Syncthing here.

Updating Synthing

[Update Oct. 10, 2014]: This part has been superseded by this post.

Usually you would update the Syncthing package via the Package Center.

Currently (mid 2014) there are frequent updates to Syncthing which the cytek repository does not track.

Fortunately, the Synthing binary (the part that actually implements the syncthing server/client) can update itself by starting it with the -upgrade option from the command line.

However, this fails on the Diskstation with the error message

FATAL: Get https://api.github.com/repos/calmh/syncthing/releases?per_page=1: x509: failed to load system roots and no roots provided

The reason for this is that there are no ssl certificates present on the Diskstation.
On a Linux system these can be found in /etc/ssl/certs and usually end with .pem

On the Diskstation this directory is missing.

To fix this, copy the content from the Linux directory /etc/ssl/certs to a directory on the Diskstation and create a link with the name certs to this directory in /etc/ssl.

The following examples assumes:
  • your Syncthing app is installed on volume1 (determined during install)
  • you have created a shared folder on volume1 named mydata which is accessible by you
  • you've copied the certificates into a folder named linuxcerts in the just mentioned shared folder
I.e. change the path names according to your setup.

log into your Diskstation via ssh as root

mkdir -p /etc/ssl
cd /etc/ssl
ln -s /volume1/mydata/linuxcerts certs


Please note:
These certificates will not be updated automatically and they will eventually expire. So you have to refresh them from time to time manually.

And the place I choose is perhaps not the most secure one; but I'm the only one using my Diskstation. Move them somewhere else, if you want.

To upgrade the binary

  • First stop the service via the package center.
  • ssh into your box.
  • Upgrade Syncthing manually on the command line using
cd /volume1/@appstore/syncthing/bin
./syncthing -upgrade


  • Now start the service again from the package center.