Multiple Distance Shaders

Started by Blonderator, July 07, 2008, 10:56:16 PM

Previous topic - Next topic

mogn


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.

Tangled-Universe

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

JimB

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.
Some bits and bobs
The Galileo Fallacy, 'Argumentum ad Galileus':
"They laughed at Galileo. They're laughing at me. Therefore I am the next Galileo."

Nope. Galileo was right for the simpler reason that he was right.

jo

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

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

jo

#20
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

JimB

#21
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.
Some bits and bobs
The Galileo Fallacy, 'Argumentum ad Galileus':
"They laughed at Galileo. They're laughing at me. Therefore I am the next Galileo."

Nope. Galileo was right for the simpler reason that he was right.

jo

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

mogn

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

Blonderator

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.