A while back I wrote an animation script for doing walkthroughs in octane that has been posted here. I would like to extend that script to include rotating an hdr sky texture in sync with the sun animation already included in that script.
Below is a segment of the code where I grab the daylight environment and copy it.
I can't find a call to determine if a sky texture hdr has been assigned to the skytexture pin, and going straight to the projection node on the hdr image doesn't work either.
Can someone point me in the right direction, I basically want to rotate the sky at a rate of 18deg per hour during a daylight sun animation by setting an animator the Y angle of a spherical projection. Alternatively what would be a different approach to achieve the same thing?
thx
local copyEnv = copyRt:getConnectedNode(octane.P_ENVIRONMENT)
copySunDir = nil
if not copyEnv then
showError("Walkthrough Error!", "A 'Daylight' or 'Texture' environment node must be connected to the render target", true)
else
-- Check if a daylight environment
if copyEnv:getProperties().type == octane.NT_ENV_DAYLIGHT then
-- Get the sun direction from the daylight environment
copySunDir = copyEnv:getConnectedNode(octane.P_SUN_DIR)
if not copySunDir or copySunDir:getProperties().type ~= octane.NT_SUN_DIRECTION then
showError("Walkthrough Error!", "No sun direction connected to the daylight environment", true)
end
THESE TWO DO NOT WORK
copySkyTex = copyEnv:getConnectedNode(octane.P_SKY_TEXTURE)
copySkyTex = copyEnv:getConnectedNode(octane.P_PROJECTION)
END THIS DOES NOT WORK
if not copySkyTex or copySkyTex:getProperties().type ~= octane.NT_PROJ_SPHERICAL then
showDebugInfo("copySkyColor","Not a Texture")
end
else
Animating an hdr daylight environment sky
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
Hi,
in this way it should work:
ciao beppe
in this way it should work:
Code: Select all
local rt = nil
local copyEnv = copyRt:getConnectedNode(octane.P_ENVIRONMENT)
copySunDir = nil
if not copyEnv then
showError("Walkthrough Error!", "A 'Daylight' or 'Texture' environment node must be connected to the render target", true)
else
-- Check if a daylight environment
if copyEnv:getProperties().type == octane.NT_ENV_DAYLIGHT then
-- Get the sun direction from the daylight environment
copySunDir = copyEnv:getConnectedNode(octane.P_SUN_DIR)
end
if not copySunDir or copySunDir:getProperties().type ~= octane.NT_SUN_DIRECTION then
showError("Walkthrough Error!", "No sun direction connected to the daylight environment", true)
end
--The pin is P_TEXTURE, not P_SKY_TEXTURE
copySkyTex = copyEnv:getConnectedNode(octane.P_TEXTURE)
copyProjection = copySkyTex:getConnectedNode(octane.P_PROJECTION)
--this is another node inside copySkyTex
if not copySkyTex or copyProjection:getProperties().type ~= octane.NT_PROJ_SPHERICAL then
showDebugInfo("copySkyColor","Not a Texture")
end
end
Many Thanks
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
bepeg4d,
Thankyou for your help,
unfortunately I'm still struggling, it is not obvious to me from the api documents, how I query and change the Y Angle property on a spherical projection node. Any tips would be greatly appreciated.
thx
Mark
Thankyou for your help,
unfortunately I'm still struggling, it is not obvious to me from the api documents, how I query and change the Y Angle property on a spherical projection node. Any tips would be greatly appreciated.
thx
Mark
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
Hi Mark,
did you know about this scripted graph by Paul?
http://poserphysics.blogspot.it/2015/04 ... xture.html
I guess that you should find what you need, if not, drop me a line.
Happy scripting,
ciao beppe
did you know about this scripted graph by Paul?
http://poserphysics.blogspot.it/2015/04 ... xture.html
I guess that you should find what you need, if not, drop me a line.
Happy scripting,
ciao beppe
bepeg4d
Thanks once again,
I swapped out the North Offset for a Sun Direction Node in Paul's code and got something working, still have a little more to do unraveling the output from the sun direction node, the whole thing returns a single number that seems like a modified sine function that I need to turn back into the range of 0 - 360 deg.
best
Mark
Thanks once again,
I swapped out the North Offset for a Sun Direction Node in Paul's code and got something working, still have a little more to do unraveling the output from the sun direction node, the whole thing returns a single number that seems like a modified sine function that I need to turn back into the range of 0 - 360 deg.
best
Mark
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
The easiest way to get the sun direction is to query it via the input pin of the sun environment:
Alternatively, given just the node, both the float node and the sun direction node will have a
By default the +Z is south, the rotation away from the +Z axis can be calculated as atan2(v.x, v.z):
I'm not sure how you want to animate this though. The sun also goes up and down, so you can only match the sun position in your environment map on two specific times of the day. At any other times the sun will be too low or too high compared to your environment map.
On a projection node you can similarly query and set the transform. You can use
--
Roeland
local v = environment:getPinValue("sundir")
Alternatively, given just the node, both the float node and the sun direction node will have a
A_VALUE
attribute which contains the direction:local v = node:getAttribute("value")
By default the +Z is south, the rotation away from the +Z axis can be calculated as atan2(v.x, v.z):
rotationY = math.atan2(v[1], v[3])
. But you also have to take the sun position in your environment map into account.I'm not sure how you want to animate this though. The sun also goes up and down, so you can only match the sun position in your environment map on two specific times of the day. At any other times the sun will be too low or too high compared to your environment map.
On a projection node you can similarly query and set the transform. You can use
octane.matrix.makeRotY
to make a rotation around the Y axis, and octane.matrix.split
to get an approximate decomposition in rotation, translation and scale.
Code: Select all
-- there's a few ways to do this, but this way works regardless of what type of
-- node is connected to the transform pin
local M = projection:getPinValue("transform")
local rotation, scale, translation = octane.matrix.split(M, octane.matrix.rotationOrder.ROT_YXZ)
local rotationY = rotation[2]
...
-- set a new transform with a rotation:
M = octane.matrix.makeRotY(rotationY)
projection:setPinValue("transform", M)
Roeland