LuxCore: the new LuxRender C++ and Python API

Discussion related to the implementation of new features & algorithms to the Core Engine.

Moderators: Dade, jromang, tomb, zcott, coordinators

LuxCore: the new LuxRender C++ and Python API

Postby Dade » Wed Oct 30, 2013 10:24 am

The plan for LuxRender 2.0 has been defined during the summer and one of the major components is going to be a new LuxRender C++ and Python API. The old C API suffer of many limitations when it come to modern features like dynamic scene editing and iterative rendering so it has been decided to write completely new API instead of improving the old one. Along the path has been taken few other important decisions.

Apache Licence 2.0

All the code included in LuxRays repository (i.e. LuxRays, LuxCore, LuxCore implementation aka SLG, LuxMark) will be released under a new license: Apache Licence 2.0. It is a very liberal license allowing the use of the code inside commercial products too. This is a quite big departure from old GPL license and all its constrains. For obvious practical reasons (i.e. the impossible task of contacting all old authors), all the old code under Lux repository is still under GPL.

LuxCore

LuxCore is the name of the new C++/Python API. It is under development and offers all the features shown by SLG in the past (in term of dynamic camera, textures, materials, objects, etc. editing) and more. Writing a complete renderer requires just few lines of code:

Code: Select all
import time
import sys
sys.path.append("./lib")

import pyluxcore

pyluxcore.Init()

print("LuxCore %s\n" % pyluxcore.version())

################################################################################
## RenderConfig and RenderSession examples
################################################################################

print("RenderConfig and RenderSession examples (requires scenes directory)...")

# Load the configuration from file
props = pyluxcore.Properties("scenes/luxball/luxball-hdr.cfg")

# Change the render engine to PATHCPU
props.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"]))

config = pyluxcore.RenderConfig(props)
session = pyluxcore.RenderSession(config)

session.Start()

startTime = time.time()
while True:
   time.sleep(1)

   elapsedTime = time.time() - startTime

   # Print some information about the rendering progress

   # Update statistics
   session.UpdateStats()

   stats = session.GetStats();
   print("[Elapsed time: %3d/5sec][Samples %4d][Avg. samples/sec % 3.2fM on %.1fK tris]" % (
         stats.Get("stats.renderengine.time").GetFloat(),
         stats.Get("stats.renderengine.pass").GetInt(),
         (stats.Get("stats.renderengine.total.samplesec").GetFloat()  / 1000000.0),
         (stats.Get("stats.dataset.trianglecount").GetFloat() / 1000.0)))

   if elapsedTime > 5.0:
      # Time to stop the rendering
      break

session.Stop()

# Save the rendered image
session.GetFilm().Save()

print("Done.")


Dynamic editing of the scene is also extremely simple too:

Code: Select all
# Begin scene editing
self.session.BeginSceneEdit()

# Edit the material
self.scene.Parse(pyluxcore.Properties().
   Set(pyluxcore.Property("scene.materials.shell.type", ["mirror"])).
   Set(pyluxcore.Property("scene.materials.shell.kr", [0.75, 0.75, 0.75])))
      
# End scene editing
self.session.EndSceneEdit()
print("LuxBall material set to: Mirror")


Check few demos below.

PyLuxCore: the Python API

Python is become the de facto standard language for scripting in computer graphics. It has been recently adopted by AutoDesk 3Dsmax too and it was already in use by Blender, Maya, etc. For this reason the Python bindings of the API will be a first class passenger like C++ and they will be developed at the same time of the C++ API. However nothing stop anyone from writing Ruby, Java, etc. API bindings.

SLG is dead ... long live to FrankenLux !

The name SLG will disappear. The rendering code has been merged in Lux with the 1.3 and SLG library is the base for the LuxCore API. SLG GUI is used for LuxVR however SLG as a "brand" will be terminated ... and resurrect as FrankenLux :lol:

LuxCore Demos

Now a couple of demos to show what LuxCore is capable of. The sources are available in a branch of LuxRays repository.

PySideLuxCoreDemo

Most of the LuxCore features (camera, textures, materials, objects editing, etc.) shown in 500 lines of Python code: http://src.luxrender.net/luxrays/file/c ... oredemo.py

pyside.jpg


To run the demo, you need Python 2.7 (http://www.python.org/download/releases/2.7.5/) and PySide for 2.7 (http://qt-project.org/wiki/PySide_Binaries_Windows). The pre-compiled demo for Windows 64bit is available here: https://drive.google.com/file/d/0B3m-kt ... sp=sharing

Blender LuxCore Render Engine

A 250 lines long (http://src.luxrender.net/luxrays/file/c ... oredemo.py) render engine for Blender based on PyLuxCore:

lux.jpg


Do you notice anything ? Yes, it supports view port real-time update like Cycles, I move the cube around and the upper left view port is updated in real-time :!:

PyLuxCoreTelnet: the new Telnet interface

The old SLG Telnet interface is replaced by this brand new Telnet interface. You can run the Telnet server with:

Code: Select all
david@i7-3930k:~/projects/luxrender-dev/luxrays$ python samples/pyluxcoretelnet/pyluxcoretelnet.py
LuxCore 1.4devel1
Hostname: localhost Port: 18081


Once it runs, you can telnet from anywhere:

Code: Select all
david@i7-3930k:~/projects/luxrender-dev/luxrays$ telnet localhost 18081
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Python 3.3.1 (default, Sep 25 2013, 19:29:01)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>


It offers a complete Python interpreter extended with PyLuxCore and an utility class RenderView to display the renderings. For instance you can run the following sequence of commands:

Code: Select all
cfgProps = pyluxcore.Properties("scenes/luxball/luxball-hdr.cfg")
cfgProps.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"]))
config = pyluxcore.RenderConfig(cfgProps)
session = pyluxcore.RenderSession(config)
session.Start()
rview = RenderView(session)
rview.show()

# Send the following command (for instance, every 500ms) to update the rendering view
qapp.processEvents()

# For this demo:
from time import sleep
while True:
   qapp.processEvents()
   sleep(0.1)


and obtain:

telnet.jpg


So it is the full power Python+PyLuxCore even where Python is not available.For instance SketchUp exporter written in Ruby could use this interface to drive and control the rendering in real-time. All in less than 300 lines of code (http://src.luxrender.net/luxrays/file/6 ... etelnet.py) ... mind blowing ;)

Documentation

I'm working on LuxCore documentation here: http://www.luxrender.net/wiki/LuxCore
Last edited by Dade on Sun Nov 24, 2013 5:09 am, edited 5 times in total.
User avatar
Dade
Developer
 
Posts: 8354
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: LuxCore: the new LuxRender C++ and Python API

Postby marcatore » Wed Oct 30, 2013 11:18 am

I'm not a programmer but it seems a big step forward... :)

very nice news!!!! :)
marcatore
 
Posts: 120
Joined: Sun Aug 09, 2009 4:17 pm

Re: LuxCore: the new LuxRender C++ and Python API

Postby danstermeister » Wed Oct 30, 2013 1:19 pm

it supports view port real-time update like Cycles


Oh wow! Awesome!!!
User avatar
danstermeister
Developer
 
Posts: 154
Joined: Thu Aug 15, 2013 5:29 pm
Location: Boynton Beach, FL

Re: LuxCore: the new LuxRender C++ and Python API

Postby tomb » Wed Oct 30, 2013 1:24 pm

Excellent work Dade! Interesting times indeed :)
User avatar
tomb
Developer
 
Posts: 2677
Joined: Thu Oct 11, 2007 4:23 pm
Location: Oslo, Norway

Re: LuxCore: the new LuxRender C++ and Python API

Postby B.Y.O.B. » Wed Oct 30, 2013 1:26 pm

Wow!
User avatar
B.Y.O.B.
Developer
 
Posts: 5131
Joined: Wed Nov 10, 2010 4:10 pm
Location: Germany

Re: LuxCore: the new LuxRender C++ and Python API

Postby ejnaren » Wed Oct 30, 2013 2:19 pm

Wow Dade. Excellent work.
I see your still fast focused on ruling the universe... :)
I look very much forward to play with this new integration!
User avatar
ejnaren
 
Posts: 27
Joined: Tue May 25, 2010 2:31 pm

Re: LuxCore: the new LuxRender C++ and Python API

Postby SATtva » Thu Oct 31, 2013 3:10 am

Congrats on this huge milestone.
Linux builds packager
聞くのは一時の恥、聞かぬのは一生の恥
User avatar
SATtva
Developer
 
Posts: 7162
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

Re: LuxCore: the new LuxRender C++ and Python API

Postby rgigante » Thu Oct 31, 2013 9:21 am

Congrats guys! Excellent move forward!
User avatar
rgigante
 
Posts: 61
Joined: Mon Oct 15, 2007 4:28 am

Re: LuxCore: the new LuxRender C++ and Python API

Postby Oberon » Thu Oct 31, 2013 1:24 pm

Exciting news!! A big leap forward. Congrats to all devs! :)
Oberon
 
Posts: 12
Joined: Tue Jul 22, 2008 6:27 am
Location: HRO, D

Re: LuxCore: the new LuxRender C++ and Python API

Postby Rhys » Fri Nov 01, 2013 11:37 pm

Very exciting, Thanks for all the work of devs!
Rhys
 
Posts: 776
Joined: Fri Mar 06, 2009 5:40 pm
Location: Australia

Next

Return to Architecture & Design

Who is online

Users browsing this forum: No registered users and 1 guest