PDA

View Full Version : Adaptive node gradients???



Revanto
03-20-2018, 07:45 PM
I just want to start off by saying that I'm not a big fan of nodes but I am actually looking for a node set up where one input of the gradient node is adaptive based on a new object size. Here's a overview of what I am talking about:

I have an object in Layout and there is a gradient node applied/projected on the X axis of the surface so the gradient is going along the Z axis. It's a black and white gradient. The gradient is sized to the Z scale of the object. However, the black value of the gradient is always at 0 on the Z axis. The white value fits the other Z axis value of the object scale.

Now, if I replace the object (which has the exact same surface names) or use the object replacement plugin, how can I make it so that the black value stays at 0 but the white value varies on the -Z axis based on the new object size?

Is this possible or would I have to manually adjust the size of the gradient myself for each object?

Considering I have a ton of objects to do this to, I would love if it were possible.

Cheers,
Revanto :p

kyuzo
03-21-2018, 07:21 AM
There are far better node experts out there, but my suggestion would be to:

Tick the 'Show Output' option on the white key on the gradient. This gives you somewhere to plug in other nodes which can influence that key's colour, POSITION, and alpha.

Into this, plug in an Item Info node (which gives you access to another item's position, SCALE and rotation).

MonroePoteet
03-21-2018, 10:31 AM
Unfortunately, the Scale returned from the Item Info node isn't the *size* of the object, and will always return (1,1,1) unless the object has been scaled up or down. A 1-meter cube will return (1,1,1) and a 100-meter cube will return the same.

From the description, it sounds like all Object geometry is at Z=0 or less and the goal is for Z=0 to be black and Z=<minimum> to be white. To do this, the Bounding Box of the object is what's needed. I don't see any native nodes that provide access to the Bounding Box, but the 2015 TrueArt Node Library has an Extended Item Info node which provides access to it. The Extended Item Info node, however, has to be told what Item from a pull-down, unless specified as an input. Thankfully, the library also provides the Extended Spot Info node, which outputs the current Item ID which can be used as input to Extended Item Info.

The basic approach is to get the range of the Z dimension of the Bounding Box, scale the Object Spot Z position into that range, and then that can be used directly as a B&W color input:

140813

Althought the Extended Item Info node provides the Box Size output, unless every object has geometry at Z=0 (Bounding Box maximum), we need the actual maximum to bring each Object Spot into the range. If ALL objects that this node network might be applied to are certain to have geometry at 0.0, then the network can be simplified to use the Box Size Z and eliminate the subtraction of the Maximum, using the Object Spot directly.

A sample LW2015 scene is attached. Note that even though each of the Objects have the same Surface name, the "adaptive gradient" Surface will have to be copy-n-pasted into all of them.

The TrueArt Node Library for 2015 and lower versions can be downloaded here:

http://www2.trueart.pl/?URIType=Directory&URI=Products/Plug-Ins/TrueArt%20Node%20Library

The library isn't available yet for LW2018, but can be pre-ordered if you're so inclined.

mTp

P.S. Here's the simplified node setup if every geometry this is to be applied to has geometry at Z=0.0 and below:

140815

Revanto
03-21-2018, 08:31 PM
Thanks for those useful tips and I will try them out. However, There may be an issue here because if I use subdivision surfaces, the resulting volume of the mesh will not match the bounding box of the object when in nurbs mode. Freezing the mesh is not an option so, sadly, whatever solution there is, has to take into consideration shrinkage due to subdiv surfaces. I know that this may be a minor difference but I have to get this perfect.

I can't actually use the scene file you provided me, mTp, because I only have 9.6 and 2018. The screen grabs should be enough to set up up though. Thanks.

If there is no solution to this then I will just have to accept the fact and do it all manually. It comes with the territory, I suppose...

Revanto :p

PS: I forgot to mention that the objects do go beyond 0 on the Z axis (black input) but that doesn't matter because the 0 value is the absolute for all objects to start black in colour. Just getting the white value to be adaptive after subdiv will be the challenge.

MonroePoteet
03-22-2018, 02:23 AM
The only recommendation I can make with subpatching is to create a UV map on the Z axis, carefully make sure whatever you define as Z=0 is at the top of the UV map, and apply a black-to-white gradient image with the Width Tile and Height Tile set to "Edge". The subpatches created in subdivision should correctly reflect their position on the gradient.

Here's an image that could be mapped.

140818

mTp

Revanto
03-22-2018, 05:05 AM
I used to do the whole B&W image setup in the past except I had an issue with banding. I really wanted to do the same thing with gradients but in the standard 9.6 gradient settings, there was no setting for bounding box or working along specific axes. I'm still using 9.6 to try sort this out. I probably have a better chance in 2018 but 9.6 feels like a comfortable blanky I'm not ready to throw aside yet.

Anyway, mTp, I was confused by your node setup because I don't know what's going on. It's not your fault, it's mine because of my dumbness when it comes to nodes (and basic math). However, I did fiddle around and found a node setup which wasn't bad and only required two nodes. I did have to create a junk UV map from the side view of each model and use that to drive the gradient node input and connect it to the surface colour, but it gave me a decent result.
I also did a quick test with a dummy model for something else but I got banding along the gradient which I am not happy about because I assumed that if I used a gradient instead of an image that I wouldn't have banding issues. Maybe it's a 9.6 issue or I am doing something wrong. I just want to end up with a clean gradient.

But the biggest and dumbest thing I realised today is that when I had the idea in my head, I forgot that every time I replace an object into the scene, manually or with an object sequencer plugin, that the new object's surface overrides the old surface/s with the same name. I had this fantasy idea in my head that I could make an ultimate surface that was adaptive, based on object size, and that it would be the master of all surfaces for all future objects. That just goes to show how much I have barely used Layout over the years.... sigh...

If I can handle the banding issue then I think I'll use my UV mapping technique to get the job done.

Revanto :p

DogBoy
03-23-2018, 02:58 AM
you could use a gradient instead of MonroePoteets image. Just use U or V as the input on the gradient from a UV map node (under Vertex Maps in the nodes list).

Revanto
03-23-2018, 08:45 PM
you could use a gradient instead of MonroePoteets image. Just use U or V as the input on the gradient from a UV map node (under Vertex Maps in the nodes list).

That's actually what I did after figuring it out on my own. But thanks anyway. I do appreciate that you tried to help.

Revanto