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 Shader Script
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
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
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.
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)