I'm having trouble with the node network. I'm trying to use multiple distance shaders to control cloud coverage. There are multiple cameras and distance shaders used to isolate a single cloud cell in one layer.
However I can't seem to blend the cloud layer by both distance shaders. I've tried plugging both of them into a multi-shader, to try and combine them - however, only the distance shader in the "shader 1" input of the multi-shader has an effect on the clouds. The other distance shaders do nothing.
Can anyone help? I've attached an image showing my setup. In the image, "Distance shader 01" is the only one having an effect on the cloud layer.
As far as I know, the multishader can only be used in objects, which is a pity.
That is a shame.
Would there be any other way to use 2 distance shaders with my clouds? I've tried function shaders like Add, but those don't seem to work too well either.
Instead of the multishader (which is likely only for objects), try the merge shader. The merge method (you'll see it in the shader which defaults to "mix") will be up to what you want for effect.
Hi,
I've attached a clip file which uses a conditional shader to create a donut of cloud about a camera. Connect the conditional node output to the cloud's density fractal output and away you go. The first distance shader defines the "hole", the second defines the circumference. The second distance shader is inverted compared to the first, I made the far colour black and the near colour white. I then combined the two with the conditional node, which uses the "Less than" condition. This basically means that the conditional node outputs the minimum value of the two distance shaders.
There are probably other ways you could do this, but right now I'm too tired to think what they are :-).
Regards,
Jo
Here's another way, this one makes a "lens" shaped cloud
Two cameras, two distance shaders both inverted (Far distance black), combine them with a Multiply Colour, use the result as the blend shader.
<edit>P.S. if you use his camera and distance shaders this will also make Jo's doughnut ;D </edit>
Hi again,
There is an improved version of my previous clip attached. This uses the Smooth step scalar node to smooth out the fade in/fade out parts of the donut. With my previous one just using the distance shader directly gives you a linear ramp from black to white. The problem with this is that there is an abrupt change from, for example, all black to the start of the ramp. Imagine drawing a ramp. Where it starts to leave the ground and head upward there is an abrupt change of direction, you could call it a discontinuity between the flat ground and the surface of the ramp, rather than a smooth transition. This can lead to aliasing or "jaggies", just as you might see the difference between an antialiased line and one which isn't antialiased ( aliased in fact :-).
This is where the Smooth step node comes in. If you look at its documentation (http://forums.planetside.co.uk/index.php?topic=3174) you will see that it can be used to create smooth transitions between values. Using the example of the ramp, it creates a smooth run in to the ramp. This removes the discontinuity. Basically it helps you create an antialiased shader. As well as the clip I've attached a screenshot showing the network. As you can see it's easy to add in the Smooth step nodes in this case. Sometimes it takes more thinking about :-).
Another thing to consider with this particular shader setup is that you want to make sure you don't have the far distance of Distance shader 01 greater than the near distance of Distance shader 02. If you did you would get an overlap of the ramping areas of each shader. Hold a ruler in each hand, with the tops sloping in toward each other, but with the tops a few inches apart. Imagine a line connection the tops of the rulers, this is a plateau area. If you move the rulers toward each other so that they overlap you will notice you now have a hard angle between them and no plateau. Instead you have what amounts to a ridge. The sharp top of this ridge is another discontinuity and will cause aliasing. By having a plateau with a smooth transition on each side you will always have a better quality shader.
Of course for the scale of these shaders the aliasing might not be noticeable, but it's a good bad to get into the habit of thinking how your shaders/networks might exhibit aliasing artifacts and how you can address that.
Regards,
Jo
Hi,
Disclaimer - even more tired than I was before, may talk nonsense :-).
M_L, I don't think your shader has quite the same effect as mine. For example if you get places where the values are 0.5 my shader will output 0.5 and yours will output 0.25. With my donut setup you will get the same effect, because one or both of the shaders will be outputting either 1 or 0, but if differing areas overlapped you would have a different result. No big deal, depends on what you're looking for really, but there are differences.
Messing with this stuff makes me think we need a function node which takes a vector as input and then works out its distance to the current render position. I don't think cameras need to be part of the equation, and they're a bit of a nuisance to deal with really. In the example of your lens cloud, rather than having to create cameras wherever you wanted to place a cloud seems like overkill. This would be a handy place where it be handy to use a Null object to position the cloud in the 3D Preview, and then have the position of the Null used as the input to a non-camera-related distance shader. You could make a distance shader with function nodes, but it would a useful thing to have already made.
Regards,
Jo
Why so complicated guys? :)
Just use the "multiply" and "add" function nodes...
If you need some help with it, I can show you an example, my Finally Spring image uses 5 masks created using this technique.
Martin
Jo.
I agree that the outputs from the Multiply Colour and Conditional Scalar are different and which one would be best will depend on what you are trying to achieve, there are probably other ways to combine distance shaders that will give yet different results.
For distance shaders based on spherical distance from a point is there any need to reference an external node at all? The distance from point could be incorporated into the shader itself, although the ability to link the distance shader to a camera or null node would need to be retained. The difficulty would come if the distance shader were operating in the planar mode where both a reference point and direction are requited. :-\
Thanks for the tip for using a smooth step to soften the blend edges that will be useful.
Hi Martin,
Quote from: Tangled-Universe on July 08, 2008, 08:15:17 AM
Why so complicated guys? :)
Just use the "multiply" and "add" function nodes...
What's complicated about one node ( conditional ) ? :-) I'm a bit surprised we don't have min and max function nodes already, you can implement them using the conditional as I've done, but just needing the two connections would be a bit simpler.
Regards,
Jo
Hi,
Quote from: Mr_Lamppost on July 08, 2008, 09:11:31 AM
For distance shaders based on spherical distance from a point is there any need to reference an external node at all? The distance from point could be incorporated into the shader itself, although the ability to link the distance shader to a camera or null node would need to be retained.
You might notice that the design of the function nodes is generally that they take another node as inputs for their values. This is the most flexible way to do it, if not perhaps always the most convenient.
QuoteThe difficulty would come if the distance shader were operating in the planar mode where both a reference point and direction are requited. :-\
That's actually pretty easy to deal with. The orientation can be specified either through providing another vector as a reference point ( where the node works out the direction to that reference point ), providing a vector as an actual direction vector or providing a vector set up as heading/pitch/bank.
Regards,
Jo
Quote from: jo on July 08, 2008, 06:28:10 AM
Messing with this stuff makes me think we need a function node which takes a vector as input and then works out its distance to the current render position.
That would probably be useful, yes, but it can also be done by subtracting Get Camera Position from Get Position in Texture. (This gives a vector, so you might want to use Convert -> Length Scalar unless the value is plugged into something that will expect a scalar and therefore do the conversion automatically.)
We'd have to make different versions for each of the types of position that can be used: Position (which usually means "final position"), Position in Texture and Position in Geometry. The more of these slightly-higher-level functions we build, the more functions have to support these different kinds of positions.
Perhaps a simple function to calculate the distance between two positions would be a good compromise. You could plug in the two position vectors you're interested in, giving you all the flexibility you need, without forcing to you think about whether you need to convert the vector to a scalar.
Matt
I had noticed and agree on both points, which I guess is why distance shaders are controlled via cameras that already have both position and direction. Saves a lot of special cases.
Quote from: jo on July 08, 2008, 10:20:58 AM
I'm a bit surprised we don't have min and max function nodes already, you can implement them using the conditional as I've done, but just needing the two connections would be a bit simpler.
They would make node networks easier to follow, a while ago I remember posting an example that used a conditional which gave people problems as they hadn't noticed that I had changed the comparison condition even though I had noted the change in the name of the node. ::)
A really handy addition would be a Comment Node.
Thanks so much for all the help guys! I really appreciate it.
The conditional scalar method works great, but how would you do that with 3 or more cameras? Can you plug in the smooth step scalar from the third camera into a second conditional scalar node, and the output from the first conditional scalar into the second one?
Quote from: Mr_Lamppost on July 08, 2008, 12:03:29 PM
A really handy addition would be a Comment Node.
Yes I miss that too, and I hate conditionals.
Quote from: jo on July 08, 2008, 10:20:58 AM
Hi Martin,
Quote from: Tangled-Universe on July 08, 2008, 08:15:17 AM
Why so complicated guys? :)
Just use the "multiply" and "add" function nodes...
What's complicated about one node ( conditional ) ? :-) I'm a bit surprised we don't have min and max function nodes already, you can implement them using the conditional as I've done, but just needing the two connections would be a bit simpler.
Regards,
Jo
Yes you're right, but just like Mogn I don't like them and I don't find them intuitive to work with.
All just because of my weak mathematic ability :p
This all sounds incredibly complicated, when all you'd need is a Merge Shader. For multiple cameras use multiple Merge Shaders? If a lot of functionality can only be achieved through knowledge of maths, and the majority of users are left with brain ache at the thought of the figuring out functions (being mostly artist types), maybe a repository of .tgc's is a good idea, with brief descriptions and properly linked to on the PS website (like other 3D apps have for scripts, shaders, plugins, etc)? Trawling and searching through multiple forum topics and websites could probably soon become a major 'mare, and many a good tool could be lost in the static.
Hi Martin,
Quote from: Tangled-Universe on July 09, 2008, 12:54:42 AM
Yes you're right, but just like Mogn I don't like them and I don't find them intuitive to work with.
All just because of my weak mathematic ability :p
I actually think conditionals are a lot simpler than trying to do the same thing mathematically using addition and multiplication etc., both practically and conceptually. They're really very simple, and let you choose what value to output based on comparing two other values in a very basic way. I tried to explain them in the documentation, have you looked at that? It's here :
http://forums.planetside.co.uk/index.php?topic=10
It's barely maths at all, and I did use names like "greater than" and "less than" instead of the more mathematical ">" and "<" symbols. It's more of a programming thing, but not a tricky one :-). I'd be interested to hear if you don't think the documentation is clear enough.
In my example clip files I was using the conditional to choose the lowest value that was coming from the two distance shaders, that's all.
I should say that there is the potential to create discontinuities with conditionals so they aren't appropriate everywhere by any means, but they're a quick and easy way to do things. I think...
I believe mogn has some sort of philosophical objection to conditionals, rather than any sort of practical one.
Regards,
Jo
Hi Jim,
Quote from: JimB on July 09, 2008, 04:01:31 AM
This all sounds incredibly complicated, when all you'd need is a Merge Shader. For multiple cameras use multiple Merge Shaders?
I reckon the Merge shader is actually considerably more complex than using the conditional in this case. There are way more settings. It also doesn't give the same results as my example. If the Merge shader had a "minimum" option then you could do the same thing as in my particular example. Maybe that's what the "Choose by altitude" setting does? I don't actually know.
You might think just by looking at it that my method using the conditional and the one using multiply give the same effect, but they don't. It's actually pretty different. If you thought of the output of each method as describing the surface of a terrain they wouldn't look very similar. If you don't understand the differences then it's a bit tricky to get the effect you want.
The Merge shader also doesn't give you the antialiasing behaviour that my example using the Smooth step node does.
Each to their own, I guess.
QuoteIf a lot of functionality can only be achieved through knowledge of maths, and the majority of users are left with brain ache at the thought of the figuring out functions (being mostly artist types), maybe a repository of .tgc's is a good idea, with brief descriptions and properly linked to on the PS website (like other 3D apps have for scripts, shaders, plugins, etc)? Trawling and searching through multiple forum topics and websites could probably soon become a major 'mare, and many a good tool could be lost in the static.
I take your point. I believe it's always been the plan to get something like that together, but right now we are still at an alpha development stage of the software. I also dream of a macro system where people can take more complex networks of nodes and package them up as one node with a few settings to control internal behaviour. That means that the basic building blocks of the function system can be combined to create nodes that those less able with the functions can just use as if they were one of the higher level shader nodes.
Regards,
Jo
Hi Blonderator,
Quote from: Blonderator on July 08, 2008, 09:18:51 PM
The conditional scalar method works great, but how would you do that with 3 or more cameras? Can you plug in the smooth step scalar from the third camera into a second conditional scalar node, and the output from the first conditional scalar into the second one?
Basically, yes you can, but you may need to change the condition used ( i.e. less than ) to combine things how you want. I've attached a clip file and screenshot showing how to combine several distance shaders using conditionals. If you look you will see that one of the conditionals is using greater than, and one is using less than. This is necessary to combine things to give my desired result of a cherry inside the donut hole - or something :-). Believe it or not I didn't figure this out using sublime mathematical reasoning. What I did was open all of the distance shaders in separate previews, as well as the conditional nodes. Then I figured out how to combine the shaders to make the donut shape. Next thing was I looked at how to combine the "donut" with the "cherry" ( Distance shader 01 ) and what I needed to set the first conditional node to. Basically I did it visually via tinkering. Ok it does help that I know that the conditional shaders do, but it wasn't rocket surgery :-). Anyway, I'm not trying to get down on anyone here, but hopefully encourage people to have a go. Opening multiple node previews in separate windows ( admittedly easier right now if you have two monitors ) allows you to see the output of each component, and then you can start to experiment.
I also had a quick mess about with the Merge shader and wasn't quickly able to get the same result, but I'm not very familiar with that node yet either. None of the merge options seemed appropriate.
Regards,
Jo
Jo, I've used a Merge Shader to create a band of cloud in the middle distance using two Distance Shaders combined (one that goes from transparent to opaque, the other opaque to transparent further behind). It worked fine, and was used to create multiple depths of a cloud layer (not in a sinlge pass) that were later combined to make a thick layer of cloud that parallaxed when the camera moved in XSI (textures on geometries). Distances were easily tweakable once I had the right drop-down options in the Merge Shader. I think it was Input B subtracting from Input A, and only took a couple of minutes to figure out (something like; when in doubt change all the options and see what happens).
I didn't try it to create multiple bands in a single cloud layer pass though, so perhaps your way is better in that case.
Hi Jim,
Quote from: JimB on July 09, 2008, 06:43:09 AM
Jo, I've used a Merge Shader to create a band of cloud in the middle distance using two Distance Shaders combined (one that goes from transparent to opaque, the other opaque to transparent further behind). It worked fine, and was used to create multiple depths of a cloud layer (not in a sinlge pass) that were later combined to make a thick layer of cloud that parallaxed when the camera moved in XSI (textures on geometries). Distances were easily tweakable once I had the right drop-down options in the Merge Shader. I think it was Input B subtracting from Input A, and only took a couple of minutes to figure out (something like; when in doubt change all the options and see what happens).
I did some more messing about and was able to create what seems to be the same sort of donut using the merge shader. I needed to change my setup of the distance shaders and I had to mess with the merge shader mix factor as well as experiment with all the merge mode - although I could probably have figured it out without experimentation if I'd wanted to apply some brain power :-). I still don't think it's more complex than my way using the function nodes, as well as being less clear conceptually, but it does perhaps lend itself to messing around more. I already knew exactly how I could achieve the effect using the conditional, so that's what I did. Each to their own :-).
Regards,
Jo
Quote from: jo on July 09, 2008, 05:20:26 AM
I believe mogn has some sort of philosophical objection to conditionals, rather than any sort of practical one.
Regards,
Jo
You are rigth about that.
By the way the "soft step" is a nice function.
Before that came into play, I implemented this by functions as 3d^2-2d^3 (d= distance):
d2 = sqr(d)
soft_step = add(mult(add(d2,d2),complement(d)),d2)
I.e. 5 nodes
Quote from: jo on July 09, 2008, 06:12:11 AM
What I did was open all of the distance shaders in separate previews, as well as the conditional nodes....Opening multiple node previews in separate windows...
Thank you. That is also what I was doing to compare the effects of the distance shaders, learn how the "Planar" setting effected the clouds, etc.
However I never though of opening the preview in a window (didn't know it was possible) so each time I wanted to see the effect on the cloud coverage, I had to click on the cloud node to view it. I'm glad you can see results in real time like that.
Thank you to everyone, especially Jo, for spending so much time on this issue - I've learned a considerable amount, as well as achieving the exact kind of cloud I was looking for. The in-depth explanations of the conditional scalar node and it's use have really helped me learn a lot. I also never knew that shaders, when used improperly, could develop aliasing :o Now I know why my terrains sometime get screwed up if I try to play with them using different nodes. :-\
I'll post the clouds that I made with your help when they finish rendering sometime tomorrow.