Sunday 19 April 2015

Sync'ing the Octane Daylight texture rotation with the North Offset

This applies to Octane Standalone and OctaneRender for Nuke.

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.

Use the following LUA code in the Scripted Graph shown below.  To rotate the sun and IBL, adjust the X slider in the North Offset of the Scripted Graph node.

NOTE: Using this approach in OctaneRender for Nuke will result in the North Offset slider not working in the OctaneRender node.  Instead, adjust the north offset in the Script Graph via the Edit Octane Scene button.


   local inputs, outputs, northOffsetOut, sphericalRotationOut  
   local MyGraphScript = {}  
   
   -- onInit function, this is called once in the beginning.  
   function MyGraphScript.onInit(self, graph)  
     -- input and output infos  
     local inputInfos = {  
       {type=octane.PT_FLOAT, label="North offset", defaultNodeType=octane.NT_FLOAT}  
     }  
       
     local outputInfos = {  
       {type=octane.PT_FLOAT, label="North offset"},  
       {type=octane.PT_FLOAT, label="Spherical Rotation"}  
     }  
   
     inputs = graph:setInputLinkers(inputInfos)  
     outputs = graph:setOutputLinkers(outputInfos)  
       
     northOffsetOut = octane.node.create{ type=octane.NT_FLOAT, name="North offset", graphOwner=graph }  
     outputs[1]:connectTo("input", northOffsetOut)  
       
     sphericalRotationOut = octane.node.create{ type=octane.NT_FLOAT, name="pherical Rotation", graphOwner=graph }  
     outputs[2]:connectTo("input", sphericalRotationOut)  
       
   end  
     
   -- this function is called every time the value of an input linker changes  
   function MyGraphScript.onEvaluate(self, graph)  
     local northOffsetIn = self:getInputValue(inputs[1])  
     northOffsetOut:setAttribute("value", {northOffsetIn[1], 0, 1})  
     sphericalRotationOut:setAttribute("value", {0, -northOffsetIn[1] * 180, 0})  
       
   end  
     
   return MyGraphScript  

No comments:

Post a Comment