[offtopic] I found Mitsuba a free high quality renderer.

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

[offtopic] I found Mitsuba a free high quality renderer.

Post by D.J.Peters »

I found the free and Open Source render package Mitsuba for Mac OS X(64-bit), Windows (32/64-bit) and Linux (64-bit).
at http://www.mitsuba-renderer.org

One amazing example (click to enlarge):
Image

Last two days I study some of the renderer source codes
and It comes with a bunch of them (integrators).

1 Direct illumination (direct)
2 Path tracer (path)
3 Simple volumetric path tracer (volpath_simple)
4 Extended volumetric path tracer (volpath)
5 Bidirectional Path Tracer (bdpt)
6 Photon map integrator (photonmapper)
7 Progressive Photon Mapping (ppm)
8 Stochastic Progressive Photon Mapping (sppm)
9 Primary Sample Space Metropolis Light Transport (pssmlt
10 Path Space Metropolis Light Transport (mlt)
11 Bidirectional Path Tracing
12 Energy Redistribution Path Tracing (erpt)
...

The input scenes are written in XML.

"mtsgui" is a QT frontend with fast OpenGL peview.

"mitsuba" is the command line version.

But it comes with a server app "mtssrv" also.

You can put the server app on many boxes in your network you like and build your own render farm.

I downloaded mitsuba for Win32 and put it on 4 older INTEL P4 boxes and on my main box.

The rendered results (quality and speed) are really awesome.

Joshy
Image
Image
Image
Image
Last edited by D.J.Peters on Sep 25, 2017 17:05, edited 3 times in total.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by srvaldez »

simply amazing!
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by vdecampo »

Impressive! How long did these scenes take to render?
integer
Posts: 408
Joined: Feb 01, 2007 16:54
Location: usa

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by integer »

Those are awesome!
Thanks for the link.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by D.J.Peters »

Tip 1: If you won't an HDR image *.exr as result you can use *.png instead.

The point are if in a XML scene a high dynmic range film are defined you have to replace it with an low dynamic.

With other words "mitsuba.exe -o box.png cbox\cbox.xml" does not create " box.png" instead it writes out "box.exr"

replace: <film type="hdrfilm">

with: <film type="ldrfilm">

than -o box.png works

Tip 2: you can disable the info banner in the image also (it's enabled by default)

Code: Select all

<!-- <film type="hdrfilm"> -->
<film type="ldrfilm">
  <boolean name="banner" value="false"/>
  <integer name="width" value="1024"/>
  <integer name="height" value="512"/>
  <rfilter type="gaussian"/>
</film>
Tip 3: Here are how I use it as backend for my own 3D editor and capture the progress.

Joshy

Code: Select all

'          1         2         3         4         5         6         7
' 1234567890123456789012345678901234567890123456789012345678901234567890123456
' Rendering: [++++++++++++++++++++++++++++++++++++++++++++] (14.5s, ETA: 0.0s)
#ifdef __FB_WIN32__
' on Windows you need the full path enclosed in double high quotes if a space is in the path
const MITSUBA = chr(34) & "D:\Mitsuba 0.5.0\mitsuba.exe" & chr(34)
const PARAMS  = " -r 1 -p 1 -o test01 .\scenes\joshy\test01.xml"
#else
' on linux it's installed in the path so you nead only the program name
const MITSUBA = "mitsuba"
const PARAMS  = " -r 1 -p 1 -o test01 ./scenes/joshy/test01.xml"
#endif

var hStdIn = FreeFile()
if open pipe(MITSUBA & PARAMS, for input, as #hStdIn) then
  print "error: can't execute " & MITSUBA & " !"
  beep : sleep : end 1
end if  

var aLine = ""
while not eof(hStdIn)
  line input #hStdIn, aLine
  aLine=trim(aLine)
  var nChars = len(aLine)
  if nChars>0 then
    var t=""
    for i as integer = 0 to nChars-1
      if aLine[i]>31 then t+=chr(aLine[i])
    next  
    nChars = len(t) 
    if nChars>0 then 
      if left(t,1)="R" then 
        locate 1,1 : print t
      end if  
    end if  
  end if
wend
close #hStdIn
print "done ..."
beep
sleep
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by dafhi »

I found this paper on ray classification .. maybe you can make sense of it.

Mitsuba is awesome .. another renderer worth checking out is Appleseed
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by D.J.Peters »

@dafhi I read many books and papers in the last 3 decades and can't count how many tracers I wrote in the past (the first was on a C64)
last days I wrote a octree with really fast AABB ray traversal in FreeBASIC
but the topic "5-dimensional space subdivision" was missing in my large collection.

thank you for sharing

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by D.J.Peters »

I control/call the renderer from FreeBASIC now.

Joshy

some results one hour per image

click to enlarge:
Image

click to enlarge:
Image

Code: Select all

/'

For documentation, please refer to:
  http://www.mitsuba-renderer.org/docs.html

Mitsuba version 0.5.0 Copyright (c) 2014 Wenzel Jakob
Usage: mitsuba [options] <One or more scene XML files>
Options/Arguments:
   -h          Display this help text
   -D key=val  Define a constant, which can referenced as "$key" in the scene
   -o fname    Write the output image to the file denoted by "fname"
   -a p1;p2;.. Add one or more entries to the resource search path
   -p count    Override the detected number of processors. Useful for reducing
               the load or creating scheduling-only nodes in conjunction with
               the -c and -s parameters, e.g. -p 0 -c host1;host2;host3,...
   -q          Quiet mode - do not print any log messages to stdout
   -c hosts    Network rendering: connect to mtssrv instances over a network.
               Requires a semicolon-separated list of host names of the form
                       host.domain[:port] for a direct connection
                 or
                       user@host.domain[:path] for a SSH connection (where
                       "path" denotes the place where Mitsuba is checked
                       out -- by default, "~/mitsuba" is used)
   -s file     Connect to additional Mitsuba servers specified in a file
               with one name per line (same format as in -c)
   -j count    Simultaneously schedule several scenes. Can sometimes accelerate
               rendering when large amounts of processing power are available
               (e.g. when running Mitsuba on a cluster. Default: 1)
   -n name     Assign a node name to this instance (Default: host name)
   -x          Skip rendering of files where output already exists
   -r sec      Write (partial) output images every 'sec' seconds
   -b res      Specify the block resolution used to split images into parallel
               workloads (default: 32). Only applies to some integrators.
   -v          Be more verbose
   -w          Treat warnings as errors
   -z          Disable progress bars

 
'/

#include once "FBImage.bi"

#ifdef __FB_WIN32__
' on Windows you need the full path where you installed Mitsuba  
' enclosed in double high quotes if a space is in the path
const MITSUBA_PATH = chr(34) & "D:/Mitsuba 0.5.0/mitsuba.exe" & chr(34)
#else
' on linux it's installed in the path so you nead only the program name
const MITSUBA_PATH = "mitsuba"
' or the path where you installed Mitsuba 
'const MITSUBA_PATH = "/usr/local/mitsuba/mitsuba"
#endif

'const SCENE_FILE       = " ./scenes/cbox/cbox.xml"

'const SCENE_FILE       = " ./scenes/cbox_sss/cbox_sss.xml"

'const SCENE_FILE       = " ./scenes/hetvol/hetvol.xml"

'const SCENE_FILE       = " ./scenes/irawan/charmeuse.xml"
'const SCENE_FILE       = " ./scenes/irawan/denim.xml"
'const SCENE_FILE       = " ./scenes/irawan/gabardine.xml"
'const SCENE_FILE       = " ./scenes/irawan/polyester.xml"
'const SCENE_FILE       = " ./scenes/irawan/shantung.xml"
'const SCENE_FILE       = " ./scenes/irawan/twill.xml"

'const SCENE_FILE       = " ./scenes/matpreview/matpreview.xml"

'const SCENE_FILE       = " ./scenes/medieval/Arabic_City_II.xml"
'const SCENE_FILE       = " ./scenes/medieval/Babylonian_City.xml"
'const SCENE_FILE       = " ./scenes/medieval/Italian_City.xml"

'const SCENE_FILE       = " ./scenes/scarf/scarf.xml"
'const SCENE_FILE       = " ./scenes/sponza/sponza.xml"
'const SCENE_FILE       = " ./scenes/sssdragon/sssdragon.xml"
'const SCENE_FILE       = " ./scenes/torus/torus.xml"

'const SCENE_FILE       = " ./scenes/veach_bidir/bidir.xml"
'const SCENE_FILE       = " ./scenes/veach_mi/mi.xml"

'const SCENE_FILE       = " ./scenes/tests/test01.xml"

'const SCENE_FILE       = " ./scenes/bathroom/scene.xml"
const SCENE_FILE       = " ./scenes/bathroom2/scene.xml"

'const SCENE_FILE       = " ./scenes/hair-curl/scene.xml"


const NUMBER_OF_RAYS = 512 ' number of rays per pixel (sample count)
const TILE_SIZE = 32
const PREVIEW_FILE = "bathroom2" ' without extension ".png" or ".jpg"
const PIXEL_FORMAT     = "RGB"
const FILE_FORMAT      = "jpg"
const NUMBER_OF_CPUS   = " -p 2"
const BLOCK_RESOLUTION = " -b " & TILE_SIZE ' default 32 (32x32)
const IMAGE_WRITES     = " -r 5" ' refresh image every # seconds
const IMAGE_FILE       = " -o " & PREVIEW_FILE 

dim as integer dw,dh
screeninfo dw,dh
dw=640*2
dh=(dw\4)*3

dw\=TILE_SIZE : dw*=TILE_SIZE 
dh\=TILE_SIZE : dh*=TILE_SIZE 

var USER_DEFINES = " -D pixelformat=" & PIXEL_FORMAT & " -D fileformat=" & FILE_FORMAT & " -D xres=" & dw & " -D yres=" & dh & " -D rays=" & NUMBER_OF_RAYS

var PARAMS = " -v" & _ ' verbose
             NUMBER_OF_CPUS   & _
             BLOCK_RESOLUTION & _
             USER_DEFINES     & _
             IMAGE_WRITES     & _
             IMAGE_FILE       & _
             SCENE_FILE

var cmdLine = MITSUBA_PATH & PARAMS
chdir exepath()

var hFile = FreeFile()
if open pipe (cmdLine, for input, as #hFile) then
  print "error: can't execute " & cmdLine & " !"
  beep : sleep : end 1
end if

'screenres iif(dw<128,128,dw),dh,32

dim as boolean renderStart

while not eof(hFile) andalso inkey()<>chr(27)
  var aLine=""  
  dim as ubyte char=0
  line input #hFile,aLine
  'while char<32 : get #hFile,,char : wend
  'while char>31 : aLine &= chr(char) : get #hFile,,char : wend
  
  open err for output as #99 : print #99,aLine : close #99
 

  var nChars = len(aLine)
  if nChars>0 then
    if renderStart = false then
      if instr(aLine,"Starting render job") then
        renderStart=true
      end if  
      
    elseif instr(aLine,"Rendering:") then
      windowtitle right(aLine,len(aLine)-len("Rendering:"))
      'var l = instr(aLine,"(")
      'if l then
      '  var r = instrrev(aLine,")") 
      '  var n = r-l + 1
      '  var m = mid(aLine,l,n)
        'windowtitle m
      'end if  
    elseif instr(aLine,"Writing image to") then
      sleep 500
      var img = LoadRGBAFile(PREVIEW_FILE & "." & FILE_FORMAT)
      if img then
        dim as integer w,h
        if imageinfo(img,w,h) = 0 then
          if screenptr()=0 then screenres iif(w<128,128,w),h,32
          'line (0,0)-step(w-1,h-1),RGB(255,0,255),BF
          put (0,0),img,PSET 'ALPHA
        end if
        imagedestroy(img)
      end if
    end if
  else
    exit while
  end if  
wend
close #hFile



' load final image
var img = LoadRGBAFile(PREVIEW_FILE & "." & FILE_FORMAT)
if img then
  dim as integer w,h
  if imageinfo(img,w,h) = 0 then
    if screenptr()=0 then screenres w,h,32
    line (0,0)-step(w-1,h-1),RGB(255,0,255),BF
    put (0,0),img,ALPHA
  end if
  imagedestroy(img)
end if
open err for output as #99 : print #99,"done ... press any key !" : close #99
if screenptr() then windowtitle "done ... press any key !"
sleep
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by UEZ »

Indeed very "geil" stuff. Thanks for sharing. :)
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: [offtopic] I found Mitsuba a free high quality renderer.

Post by D.J.Peters »

I found some more nice XML files for Mitsuba.

Joshy
Image
Image
Image
Image
Image
Image
Last edited by D.J.Peters on Dec 14, 2019 16:50, edited 1 time in total.
Post Reply