Elevation Shader Script

Forums: Elevation Shader Script
Forum for OctaneRender Lua scripting examples, discussion and support.

Elevation Shader Script

Postby Sighman » Fri Oct 03, 2014 7:06 am

Sighman Fri Oct 03, 2014 7:06 am
I would like to develop a LUA nodegraph that could create a texture based on the 'height' of a mesh. It is basically a Boolean shader used to drive a mix node and draw a line at a certain distance along the x, y, or z axis. This could be in local or global space. The attached image shows a global elevation shader applied to two object. The objects are five feet high and the elevation is set to three feet. The line is blurred but I would be happy with a straight line.

I just need to know if it is even possible to do this in LUA and, if it is, some direction to get started.

Thanks.

Elevation.png
Elevation Shader
Win8/64, I7-4770K (3.5Ghz) 24GB, GTX-980ti (6GB) / GTX-TITAN (6GB)
Sighman
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 1112
Joined: Thu Jan 19, 2012 9:11 am
Location: Calgary, AB

Re: Elevation Shader Script

Postby roeland » Mon Dec 08, 2014 2:06 am

roeland Mon Dec 08, 2014 2:06 am
It's not possible to run lua code in a shader, you can only change values in nodes using lua.

You can use a checker board texture and apply the appropriate scaling. By default the checks are 1 unit wide and the origin is in the centre of a square.

Set the coordinate space to world space, and then set up the UVW transform:

First scale the checkerboard up so the entire scene fits into one square: set the scale to something like (1000, 1000, 1000)
Then on the Y axis you have to move the border of the checkerboard up to where you want it. By default the border now is at -1000/2, so move it up by (1000/2 + Y). Of course you can do this with a script inside a scripted node graph.

The scale value on the X and Z axes don't matter much as long as it's larger than your scene. On the Y axis it can't be too large, since floating point calculations only have about 7 digits of precision.

--
Roeland
Attachments
y-offset.png
Example setup with the threshold at Y = +0.3
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1811
Joined: Wed Mar 09, 2011 10:09 pm

Re: Elevation Shader Script

Postby Sighman » Fri Dec 12, 2014 6:03 pm

Sighman Fri Dec 12, 2014 6:03 pm
Ok, thanks Roland, that's cool. I can work with that.

Sorry to bother again but can you think of a way to add some noise at the transition point of the tile.
Win8/64, I7-4770K (3.5Ghz) 24GB, GTX-980ti (6GB) / GTX-TITAN (6GB)
Sighman
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 1112
Joined: Thu Jan 19, 2012 9:11 am
Location: Calgary, AB

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 10 guests

Tue Apr 23, 2024 10:08 am [ UTC ]