Lua script repository

Forums: Lua script repository
Forum for OctaneRender Lua scripting examples, discussion and support.

Lua script repository

Postby bepeg4d » Sat Nov 05, 2016 5:24 pm

bepeg4d Sat Nov 05, 2016 5:24 pm
Alembic
  • merge-abc-materials
    The script tries to group the materials of an abc archive that match the material names of a "guidance" obj mesh (e.g. RED_1, RED_2 & RED_3 would match RED and are grouped together "RED"). If the "guidance" obj mesh is bogus then you would get an abc mesh that's the same as the original.
    download link - forum link

Animation
  • anim_texture
    This script graph will allow you to load a series of images and use it as an image texture.
    download link[/url - [url=https://render.otoy.com/forum/viewtopic.php?f=73&t=43806&start=20#p214719]forum link
  • AnimateValue_SG*
    Animate a value via Lua scripted graph.Define a Start value, an End value and the duration expressed in seconds.
    The total number of frames depends on the FPS value of the scene.
    You can animate any kind of value, just connect the output of this scripted graph node to a blue (value) pin of a desire node.
    download link - forum link
  • AnimateValues scripted graph pack Color-Enum-Float-Grey-Int *
    AnimateValue scripted graph, with some more options, and declined in five different values:Color-Enum-Float-Grey-Int
    download link -forum link
  • AnimateValue_FloatStations*
    Here is a Lua Script based of AnimateValue_SG that has 10 'Stations'. Think of it like a train ride, with an origin followed by 10 stops, with the 10th stop being the end stop.
    download link -forum link
  • Creating a colour blend animation
    Here's a simple example to create a colour blending animator for an RGB texture node (octane.NT_TEX_RGB) (Works only from release candidate 1.25). It displays 2 colour swatches to select start and end colour. A bit subtle is that the swatch returns colours components in the range [0, 255] while NT_TEX_RGB expects its components in the range [0, 1] so we have to normalize ourselves.
    forum link
  • Yaw, Roll and Pitch Animation rendering(v1.55)
    I modified the turntable animation script a bit to animate yaw, pitch and roll camera rotations.
    forum link

Baking

Camera
  • Animated tiled camera v1.05
    The idea is to create an animation of big frame buffers divided into tiles to be ready to be sent to ORC. As a side effect, in v2, is useful also for removing the frame buffer limitation on VRAM . The script works with Thin Lens Panoramic, and Backing camera node.
    download link forum link
  • cam_calculator_v2*
    After writing the old school exposure script graph, I thought it may be useful to havea calculator that calculates the field of view and aperture from "old school" camera parameters (film width / focal length / f-stop).
    download link - forum link
  • camera-explode*
    Scripted node graph to extract camera position
    download link - forum link
  • camera map
    This script approximately maps a texture so it fits into the camera view. Note this does not take things like distortion and depth of field into account.
    download link - forum link
  • FromAbc2Pano-002
    Lua script for substitute the Alembic Camera Node with a Panoramic Camera node taking the same position and target of the original abc node.
    download link - forum link
  • FromABC2Thin*
    Scripted node graph to extract camera position
    download link - forum link
  • OlReadyCam_3.0
    Camera key frame animation script for Octane Standalone
    download link - forum link

Camera Imager
  • EV compensation*
    How to calculate the exposure using some EV compensation like in a real camera. So I wrote a small Lua script graph.
    download link - forum link
  • old school exposure]*
    Since some people miss the old school exposure settings for reasons that are totally beyond me, I have whipped up a little Lua node graph that emulates the old exposure settings. Just download the file and import it into your project (via RMB click in the node graph editor -> Import...) and connect it with the exposure pin of the camera imager node.
    download link - forum link

Environment
  • Change HDR every frame
    Here is a simple Lua script example that change the HDR image for every frames of a scene with an animated alembic node.
    forum link
  • load sun + sky from sIBL
    Octane doesn't support loading sIBL environments directly, but via a script you can set up a common use case: setting up a HDR environment and sun light. This script will set up the sun position and environment texture, but it has limitations. download link - forum link
  • sIBL*
    With the scripted graph introduced with Octane 2.10, we can convert this load sun + sky from sIBL script to one of these scripted graphs.
    download link - forum link
  • Sync Daylight rotation with North Offset*
    If you want to have the Daylight Environment Sky Texture rotate as you change the North Offset, you can do this with an LUA Scripted Graph.
    download link - forum link
  • VisibleBackground
    Lua scripted graph node for automatically adapting an image assigned to a Visible Environment node to be displayed like a Background image.
    download link - forum link

Experimental
  • boids*
    Script to simulate flocking in Octane. It does this by scattering a number of meshes and rotating them to face a certain direction, and applying the Boids rules to them repeatedly. The result is a realistic looking (and very configurable) school of fish, or flock of birds.
    download link - forum link
  • Live Texture Painting Script
    In this example we do live texture painting. Just start rendering something, select a texture node and start the script. Now you should by able to paint some stuff on your selected texture. You can also use it to paint a texture environment. This is a proof-of-concept, not a production stable script!
    forum link
  • sa*
    Simulated annealing optimiser: scripted graph node that uses a parametric optimiser to try to optimise some quantity in the node graph.
    download link - forum link

File handling
  • Save Incremental
    This is a little script I meant to do since quite a while: It allows you to save the current project with incrementing file names. This way you can create a history over the development of your project, without having to specify new file names all the time.
    download link - forum link

General
  • Accessing application preferences in Lua
    In Octane, preferences are stored in an internal node of type octane.NT_LOCAL_APP_PREFS. You can fetch it by calling octane.project.getPreferences(). Getting and setting preferences is a matter of manipulating a node.
    forum link
  • create-docs_213
    Script to create Lua API documentation in html:For the people who don't like the API browser. I wrote a Lua script a while ago to create a html file describing the Octane Lua API. The script will ask for an output file.
    download link - forum link
  • Creating your own image textures with the Octane Lua API
    In this example we'll explain how to create an image texture in Lua. At the end you should end up with a nice gradient texture. Let's have a look at (some of) the attributes of the image texture node (octane.NT_TEX_IMAGE).
    forum link
  • Creating a scripted node graph*
    Octane 2.10 introduced a new feature for scripting, called a "scripted graph". This is a node graph with an embedded script, which will create all the contents. It can change the contents in response to changes to the input value, or the scene time.
    forum link
  • Creating tabs in Lua
    From release 1.27, you can have tabs in your lua user interface. Tabs are similar to groups or panel stacks. They take a list of children, one for each tab. The tab component is resized to fit it's largest child component.
    forum link
  • How to use binding in Lua
    Today we'll explain how to use the octane.gui.bind functionality. The examples here work with release candidate 1.29. Binding doesn't bring extra functionality to the API. It's a way to manage complexity in scripts with a user interface.
    forum link
  • Introducing the Octane Lua API
    With version 1.5, Octane will have Lua scripting capabilities. To make users familiar with it we will post a series of topics on the forum introducing various aspects of the API.
    forum link
  • Nodes and Nodegraphs in Lua
    Today we'll give a brief overview of the node and graph module. Every Octane user is familiar with nodes and graphs but let's explain some details to get you up to speed. We won't build a full example here but we'll include some code snippets to experiment with.
    forum link
  • Panel stack example script
    Just a quick example on how to use the panel stack in Lua. I modified the user interface of the turntable animation to use a panel stack. Panel stacks come in handy when you have a lot of stuff to display on a single window. The panel stack component reveals a scroll bar when the components don't fit.
    forum link
  • Script headers and shortcuts
    Octane analyze the script header and add the possibility to assign shortcuts to scripts. A script header is just a comment that appears on top of your script. Ideally you describe here what your script does, how to use it, the author, ... . The full header must appear in the first 50 lines of the script, we don't bother scanning the full script.
    forum link
  • Simple Bitmap Example in Lua
    This is a simple example on how to use bitmaps in Lua. It creates 2 bitmaps. The top bitmap is used for free-drawing by hooking up a mouse listener. On a mouse down event we colour the pixel. The bottom bitmap just loads a picture with an opacity of 0.5. When a bitmap loads a picture, it's always resized to fit the picture. Keep this in mind when you're creating sprites for your script.
    forum link

Geometry
  • bg4d-connect-group-02
    Creates a group node and connect to all the selected meshes.
    download link - forum link
  • bg4dCreateFogVolume
    Creates a cube fog volume with the desired measures
    download link - forum link
  • bg4dCreatePlane-11
    Creates a simple plane with the desired dimensions and axis. It is useful for faster adding a floor to the scene or for creating emitter planes.
    download link - forum link
  • bg4d-placeMesh
    just choose a point in the viewport with the target picker, select a mesh node and run the script (i have set the shortcut to alt+8)
    after that, connect the placement node to a geometry group and that's it.
    download link - forum link
  • Creating your own geometry with the Octane Lua API
    Create your own geometry from the Octane Lua Api. We'll create a simple cube and assign a material to each face of the cube. We do this by creating a mesh node and directly manipulating it's attributes.
    forum link
  • Load instances
    Here is a script for loading instaces and organize them in a single node .
    download link - forum link
  • Loading obj through scripts
    Loading obj through scripts: load a .obj file and display the result.
    forum link
  • LoadPolyGroupAsMaterial
    Lua script to load polygroups from ZBrush as material inputs (v1.55-v3).
    download link - forum link
  • obj loader script
    A script that loads obj files from a directory and hook them up to an geo group node.
    forum link

Materials
  • bg4dCreateMixMat
    Create a mix material between a diffuse and a glossy with several option
    download link - forum link
  • Copy material from mesh pin to new material node
    Copies the nodes internal to the pin into the project as material nodes.
    forum link
  • DownloadLiveDBmaterialID
    Enter the desired Material ID to downoal it in the current scene.
    download link - forum link
  • FindMatLiveDB
    Create an updated list of all the LiveDB materials.
    download link - forum link
  • Generating a Julia texture in Lua
    Now that we generated the Mandelbrot set, here's a script to generate a Julia set. The principle is the same. The only thing to note here is that there's a function to convert from the HSL colour model to the RGB model. The HSL model (or HSV) comes in very handy when you'd like to generate a full colour spectrum from a single value.
    forum link
  • Generating a Mandelbrot texture in Lua
    Here's a example of how to create a procedural texture. It generates the Mandelbrot set in Lua.
    forum link
  • MatSwitch
    Scripted node graph for switching between two materials
    download link - forum link
  • MBB QUIXEL PBR
    The script searches and downloads the MBB_QUIXEL_PBR.orbx material provided by miko3d, asks for the albedo texture path, automatically imports all the needed maps in the proper pins, and then, the resulting material will be saved as an .orbx file if needed.
    download link - forum link
  • merge-abc-materials
    The script tries to group the materials of an abc archive that match the material names of a "guidance" obj mesh (e.g. RED_1, RED_2 & RED_3 would match RED and are grouped together "RED"). If the "guidance" obj mesh is bogus then you would get an abc mesh that's the same as the original.
    download link - forum link
  • Metal material *
    Simulates a metal using its complex index of refraction.
    download link- forum link
  • Octane_noise_generator_0_11
    A noise generator for Octane. The idea is to create an application where it's really easy to add new noise patterns based on the existing functionality. You don't have to worry about creating the user interface, that's all done automatically.
    download link- forum link
  • OffsetTex-01*
    That is a scriptgraph that takes an RGB image and an Transform Value as inputs and outputs a new image with the selected transform values.
    download link- forum link
  • octane-spec-mat-lua*
    "texture load / setup: select the diffuse map from the texture set and the script load the rest by its name, _diffuse, _roughness, _specular, _normal ... and also setup values for the specific map.
    download link- forum link
  • Texture2glossy
    Creates a Glossy material starting from a Diffuse image texture path. It is possible to specify the Bump and Specular/Roughness suffix to automatically find the textures, if not found, the diffuse texture in grayscale mode will be used
    download link -forum link
  • TextureTransform*
    That is a scriptgraph that takes an RGB image and an Transform Value as inputs and outputs a new image with the selected transform values.
    download link- forum link


Node Graph
  • cameraTransform*
    Take an ABC camera as input and extract its transformation, the output tranform can be plugged in a placement node for example.
    download link- forum link
  • Finding all render targets
    This is how you collect all node names into a new array, and then print all elements of the array. This array can be used for the items property of a combo box.
    forum link
  • FromOBJtoABC
    Lua script for helping in the substitution of an obj static mesh with an alembic scene file.
    download link- forum link
  • Get information from a mesh node
    calculate the statistics of a mesh and return a table of those values
    forum link
  • Material linker
    Select at least one mesh, and ONE node graph with the materials. Run the script (shortcut is ALT-L) and all names that match will be linked up
    download link -forum link
  • Move nodes into node pins
    This script moves all the selected nodes into their destination pins if possible. To use, select the nodes to be moved (don't select the destination node) and run this script.
    download link- forum link
  • ObjectSwitch*
    Switch between object A and B with a boolean node.
    download link- forum link
  • refresh scatter nodes
    his script will reload the file in each scatter node. For the interested users, there's a generic update function here which will call a predicate function on each node of a specific type in the project. This might come in handy in other scripts.
    forum link
  • tree copy mode in lua
    Here's a little script to copy and paste a full node tree. The root of the tree is the selected node. To use it, just select a node and run the script. The script is mapped to alt + c but you can change this of course. Might be useless 99.99% of the time but I think it's nifty.
    forum link

Scatter and clones
  • Matlab Code mScatter
    This is the Matlab Code of mScatter. I am looking for someone to turn it into C-Code or Lua for wide distribution and faster processing. If you just load it into Matlab and run it, it writes scatter matrices in you current folder. Those can be loaded into a scatter node straightaway. I always test it then with simple cubes in Octane.
    download link- forum link
  • posRotScale2scatter
    Paste a list of positions, rotations and scales and assemble your matrices in octane.
    download link - forum link
  • Texture Scatter
    Creates a number of random image textures, and allows you to use one of these (at random) on each instance of a mesh. It is possible to vary the input image file, and the image transform for each image texture.
    download link - forum link

Workflow
  • Batch Render from command line _ LUA script
    Octane command line doesn't provide a built-in way for batch rendering animation, so here is an advanced LUA script for that.
    download link forum link
  • Daylight animations in Lua
    Here's a script to render daylight animations. It has the same functionality as the daylight animation rendering in pre 1.5 releases.
    forum link
  • Load Animation Path
    Here is a script that animates a camera from a camera-target position file. It uses ffmpeg for the video creation. See also viewtopic.php?f=73&t=39246
    download link - forum link
  • myBatchRender
    Batch Render modified version, the output window does not display at all so no need to press start or close download link - forum link
  • Octane Render Walkthrough 1.04(v1.55)
    Here is a script that can be used to create a walkthrough of an Octane Scene. Conceptually a series of camera moves can be record in a sequence of files. Multiple sequences need to be combined in another application such as Windows Movie Maker. Each camera move can be a combination of an orbit, pan, zoom, tilt, rotate, roll, sun path or depth clip operation, optionally each move can have a quadratic easing function applied to it. Camera moves can be previewed before saving as an automatically named file sequence based on a seed name.
    download link - forum link
  • RTresolutions-02
    lua script that changes all the render target resolutions in one time.
    download link - forum link
  • Turntable animations in Lua
    In this second part we'll finish the turntable animation script we started (see this post for part 1.
    download link - forum link
  • turntableG-V102 (v2.26)
    Grimm's take on the turntable anim script: alternative Turntable script with various animation settings.
    download link - forum link

*Scripted Graph Lua script
Last edited by bepeg4d on Sun Mar 03, 2019 7:49 am, edited 13 times in total.
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9940
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Lua script repository

Postby gah5118 » Wed Nov 30, 2016 10:57 pm

gah5118 Wed Nov 30, 2016 10:57 pm
Thanks for rounding everything up!

Wonder if it would be beneficial to have a roundup on the site itself rather than in the forums. A section which would have a material / shader section, lua script section, tutorial section, and whatever other sections that would be helpful.. not for discussion but a go to place that is well organized with links to the resources.
Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
gah5118
Licensed Customer
Licensed Customer
 
Posts: 358
Joined: Thu Jun 02, 2011 4:25 pm

Re: Lua script repository

Postby smicha » Wed Nov 30, 2016 11:56 pm

smicha Wed Nov 30, 2016 11:56 pm
What a fantastic topic! Thank you so so so so mych :)
3090, Titan, Quadro, Xeon Scalable Supermicro, 768GB RAM; Sketchup Pro, Classical Architecture.
Custom alloy powder coated laser cut cases, Autodesk metal-sheet 3D modelling.
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3151
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Lua script repository

Postby bmustata » Mon Mar 19, 2018 11:36 am

bmustata Mon Mar 19, 2018 11:36 am
Super topic!
bmustata
 
Posts: 7
Joined: Sat Feb 10, 2018 10:07 am

Re: Lua script repository

Postby whersmy » Mon Oct 19, 2020 7:06 am

whersmy Mon Oct 19, 2020 7:06 am
Is there a script / way to remove unused nodes used by a Rendertarget? Sometimes I`m working on a new project in an old project for months and Octane loads all the old nodes as well..which can take long.. :idea:
Octane 2022.1.1 nv535.98
mac pro g5| pentium g2030 iGPU| maximus extreme V| 2x gtx590 - 8gb - SSD - win7-x64- 1500W Silverstone|
x201t - gtx580 - egpu ec
Dell G5 - 16GB - dgpu GTX1060 - TB3 egpu @ 1060 / RTX 4090

Octane Render experiments
User avatar
whersmy
Licensed Customer
Licensed Customer
 
Posts: 723
Joined: Thu Aug 30, 2012 7:40 am

Re: Lua script repository

Postby bepeg4d » Mon Oct 19, 2020 7:33 am

bepeg4d Mon Oct 19, 2020 7:33 am
Hi,
you could select your Render Target, then use the following script:
viewtopic.php?f=73&t=38491
to copy paste all the connected node in a new Node Graph, or even a new scene file, to remove all the remaining nodes more easily.

ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9940
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Lua script repository

Postby whersmy » Mon Oct 19, 2020 7:48 am

whersmy Mon Oct 19, 2020 7:48 am
Thanks !!

It roots back to really old Octane versions, maybe that`s the reason it outputs this error?

Would love to get this working!
Attachments
error.jpg
Octane 2022.1.1 nv535.98
mac pro g5| pentium g2030 iGPU| maximus extreme V| 2x gtx590 - 8gb - SSD - win7-x64- 1500W Silverstone|
x201t - gtx580 - egpu ec
Dell G5 - 16GB - dgpu GTX1060 - TB3 egpu @ 1060 / RTX 4090

Octane Render experiments
User avatar
whersmy
Licensed Customer
Licensed Customer
 
Posts: 723
Joined: Thu Aug 30, 2012 7:40 am

Re: Lua script repository

Postby bepeg4d » Fri Oct 23, 2020 11:47 am

bepeg4d Fri Oct 23, 2020 11:47 am
Hi,
here is the corrected version:
Code: Select all
    -- Creates a copy of tree starting at the selected item. The copy is immediately
    -- pasted into the current project and the copied tree is selected.
    --
    -- @description creates an item tree copy
    -- @author      Thomas Loockx
    -- @version     0.1
    -- @shortcut    alt+c

    -- get the current selection
    local selection = octane.project.getSelection()

    -- only do something if we have a single selection
    if #selection == 1 then
        -- create a root graph to copy into
        local copyGraph = octane.nodegraph.createRootGraph("Copy Tree Graph")
        -- copy the full tree into the copy graph
        local copyRoot = copyGraph:copyItemTree(selection[1])
        -- unclutter it a bit
        copyGraph:unfold()
        -- copy it into the scene graph
        local copies = octane.project.getSceneGraph():copyFrom(copyGraph:getOwnedItems())
        -- select all those copied items
        octane.project.clearSelection()
        for i, item in pairs(copies) do
            octane.project.select(item)
        end
    end


ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9940
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Lua script repository

Postby whersmy » Sun Oct 25, 2020 9:27 am

whersmy Sun Oct 25, 2020 9:27 am
Hurray, yeah this works wonders...!! Thanks again bep!

The Nodegraph sometimes during fun projects ends up being the canvas of drawing...can get messy.. :)
Octane 2022.1.1 nv535.98
mac pro g5| pentium g2030 iGPU| maximus extreme V| 2x gtx590 - 8gb - SSD - win7-x64- 1500W Silverstone|
x201t - gtx580 - egpu ec
Dell G5 - 16GB - dgpu GTX1060 - TB3 egpu @ 1060 / RTX 4090

Octane Render experiments
User avatar
whersmy
Licensed Customer
Licensed Customer
 
Posts: 723
Joined: Thu Aug 30, 2012 7:40 am

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 4 guests

Thu Mar 28, 2024 11:31 pm [ UTC ]