API Usage example - LuxRender Wiki
Luxrender GPL Physically Based Renderer

API Usage example

Personal tools

From LuxRender Wiki

Jump to: navigation, search

LuxRender C API

float fov=30;
float size=2, radius=20, height=-1;
int resolution=200;
float from[3]= {0,0,0};
float to[3]= {0,0,1};
float color1[3]={1,0,0},color2[3]={0,0,1};
float scale=4;
char *filename="simple.png";
               
luxLookAt(0,10,100,0,-1,0,0,1,0);
luxCamera("perspective","fov",&fov,LUX_NULL);
luxPixelFilter("mitchell","xwidth", &size, "ywidth" , &size,LUX_NULL);
luxSampler("random",LUX_NULL);
luxFilm("multiimage","filename",filename,"xresolution",&resolution,"yresolution",&resolution,LUX_NULL);
luxWorldBegin();
                       
luxAttributeBegin();
luxCoordSysTransform("camera");
luxLightSource("distant" ,"from",from,"to",to,LUX_NULL);
luxAttributeEnd();
                   
luxAttributeBegin();
luxRotate(135,1,0,0);
luxTexture("checks","color","checkerboard" ,"uscale",&scale,"vscale",&scale,"tex1",&color1, "tex2",&color2,LUX_NULL);
luxMaterial("matte","Kd","checks",LUX_NULL);
luxShape("disk","radius",&radius,"height",&height,LUX_NULL);
luxAttributeEnd();
luxWorldEnd();


once the render has finished you can reset Lux and start another:

luxExit()
luxCleanup()
...


LuxRender PyLux Python API

Full pylux documentation is hosted here: http://www.luxrender.net/static/pylux/

Quick example:

>>> import pylux
>>> context = pylux.Context('context-name')
>>> context.worldBegin()
>>> context.lightSource('infinite', [])
>>> context.worldEnd()
>>> # do other stuff, or wait
>>> context.updateStatisticsWindow()
>>> print(context.getAttribute('renderer_statistics_formatted_short', '_recommended_string'))
>>> # end the render
>>> context.exit()
>>> context.cleanup()
>>> del context