Moving and scaling a simple shape shader

Started by otakar, August 24, 2010, 09:54:44 AM

Previous topic - Next topic

otakar

Is it possible to move and scale a simple shape shader (along x/z) via functions? If so, can someone please outline this for me? I have been unsuccessful in my attempts. I am trying to use simple shape shader extensively for masking - it works great for regular patterns, and it would be so helpful if I did not have to duplicate so many nodes.

Thanks!

Tangled-Universe

My first thought is to use the simple shape shader as a childlayer of a distribution-shader.
Then in-between that connection put a translate shader node.

Now using the translate shader you can change the position and scale of the simple shape shader.

Because you used this shader as a child of a distribution shader you won't affect other displacements with the translate shader node.

otakar

TU, do you mean the Transform shader? I just tried it again and the Simple Shape Shader is not affected by any of the params in the Transform shader.

Tangled-Universe

Quote from: otakar on August 24, 2010, 12:04:50 PM
TU, do you mean the Transform shader? I just tried it again and the Simple Shape Shader is not affected by any of the params in the Transform shader.

I'm back home, so now I can actually really try to figure it out for you instead of thinking out loud :)

Tangled-Universe

Ok, now I see. I must admit I barely touched that shader.

You already have parameters for position and scale, but you want to control these using functions (shader)?
That's not possible I think.

Or do you really only want to move the simple shape shader to somewhere else and/or make it a bit bigger/smaller?

otakar

#5
Quote from: Tangled-Universe on August 24, 2010, 12:28:19 PM
Or do you really only want to move the simple shape shader to somewhere else and/or make it a bit bigger/smaller?

Yes, that is what I am after. Say I have a circle shape mask that is a result of a simple shape shader. What I need is a ring, so I can either create another simple shape shader and merge the two to come up with my ring or I can 'transform' that initial simple shape shader, or at least I thought I could. When you get to more complex masks this would really be nice and flexible if it worked.

And yes, I can always use an image based mask of course with its drawbacks...

Edit: Before anyone suggests using the Edge Color (good idea, though), I do need that param for smooth edges (and besides it would only work in the ring-type scenario above, not when the actual mask needs to be moved to different coordinates).

Tangled-Universe

You can move the simple shape shader using the "position" parameters.
The size can be controlled with the "size" parameters. The shape size will be bound to the size of the white boundary box.
For a circle, the diameter equals the size of the boundary box.

So what you are after is this?


otakar

Right, now try to eliminate Simple Shape Shader 01_1 and 'derive' the ring from Simple Shape Shader 01 alone (by using functions I presume and some constant value fed in for the width of the ring). My envisioned use for the simple shape shader is not on heightfields but just as blending inputs for surface shaders, but that does not matter much in this discussion.

Tangled-Universe

Like this? (a scalar->colour also works instead of vector->colour)

otakar

Quote from: Tangled-Universe on August 24, 2010, 02:09:50 PM
Like this? (a scalar->colour also works instead of vector->colour)


Yes, that's where I am at (though I just plug the SSS directly into the blending input, works fine).

Tangled-Universe

Ok :)
So back to the problem now, what is it? :)

Moving scaling outside of the two sss-nodes does not work, since their output is linked to their boundaries.
So a translate-shader won't work.
Only option is to move and scale with the sss-nodes parameters themselves I'm afraid.

otakar

Quote from: Tangled-Universe on August 24, 2010, 02:19:42 PM

Only option is to move and scale with the sss-nodes parameters themselves I'm afraid.

So what you are saying is there is no way to eliminate that second SSS node in the example? THAT is the question. And if I want another ring of the same size, I need yet another two nodes, and so forth... At some point you get quite an army of SSS nodes :)

Tangled-Universe

Quote from: otakar on August 24, 2010, 02:26:04 PM
Quote from: Tangled-Universe on August 24, 2010, 02:19:42 PM

Only option is to move and scale with the sss-nodes parameters themselves I'm afraid.

So what you are saying is there is no way to eliminate that second SSS node in the example? THAT is the question. And if I want another ring of the same size, I need yet another two nodes, and so forth... At some point you get quite an army of SSS nodes :)

Why that second sss-node specifically? I don't get you. You also need the first to get the thick circle. So why don't you move/scale them both with the same value?

Yes, for another ring you'd need two sss-nodes, again.

However, you can also use a shader array to get the circles on a grid.
Just connect the output of the merge shader into the shader-input of the shader array node.
Again this has a drawback, that it only works for displacement :(

It's probably because of the same reason that you can't derive a mask from a crater-shader.

otakar

Shader array is good, thanks for pointing that out! At least that would save you from duplicating masks that are aligned in a grid. Scaling is still an issue, though.

So let's just say I have a number of rings of different sizes (as masks) that are dispersed along the horizontal plane in some non-grid order. My idea was that I could construct the initial ring and then multiply it and scale it and place it wherever I want dynamically using the math functions (not by simply duplicating the nodes and changing their params). If all the rings are supposed to have the same width I could make it an input param (constant), so that I would have to change it only once in the project instead of changing the size in each SSS node. Makes sense?

More and more it seems to me that an image-based mask may just be necessary in this situation if I want to avoid SSS hell ;)

otakar

TU, thanks for entertaining me, though my idea did not go anywhere. I think I'll stick with the Simple Shape Shader, it's quickly becoming my favorite. I just need to keep my network organized or I'll go crazy :)

It'd be nice if the shader array node were be a bit expanded to allow for more than just grid-type arrangements. Maybe a feature request?