## problems understanding the functions

Started by al91, December 01, 2009, 11:30:24 am

#### al91

##### December 01, 2009, 11:30:24 am
um i have problems understanding the functions shaders and what exactly they do..can anybody explain them to me?

#### FrankB

##### December 01, 2009, 02:50:13 pm #1
they are primarily math functions that apply an operation to the color or position of the procedural geometry or anything really that you feed into it.

An example for a function could be to apply a sine to the color of a surface layer. To do that, you would

- feed that into "x from scalar" (for example, or y or z)
- feed that into sin
- feed that into the color function input of your surface layer.

This network of function nodes gives you color[-1;1] = sin(x)

For any function, you need to feed them coordinates at the top of the function chain. That's essentially how functions work. In a nutshell. A tiny nutshell.

Frank

#### domdib

##### December 02, 2009, 09:38:47 am #2
Dear Frank,

Please consider expanding the tiny nutshell to something more approaching coconut size  Perhaps (as I've hinted elsewhere) there's an NWDA tutorial or product in there somewhere?

Regards,

Dominic

#### PorcupineFloyd

##### December 02, 2009, 09:47:08 am #3
Yes, a basic approach to functions is so much needed.

#### Zairyn Arsyn

##### December 02, 2009, 11:05:06 am #4
Quote from: PorcupineFloyd on December 02, 2009, 09:47:08 am
Yes, a basic approach to functions is so much needed.

yes, i heavily agree.
WARNING! WIZARDS! DO NOT PREDICT THE BEHAVIOR OF OTTERS UNLESS YOU OBEY BIG HAPPY TOES.

i7 2600k 3.4GHZ|G.skill 16GB 1600MHZ|Asus P8P67 EVO|Evga 770GTX 4GB|SB X-FI|Antec 750W
http://zlain81.deviantart.com/

#### FrankB

##### December 02, 2009, 06:05:47 pm #5
Quote from: domdib on December 02, 2009, 09:38:47 am
Dear Frank,

Please consider expanding the tiny nutshell to something more approaching coconut size  Perhaps (as I've hinted elsewhere) there's an NWDA tutorial or product in there somewhere?

Regards,

Dominic

Ok, ok... I'll try to put something together after christmas. No time before that unfortunately

#### domdib

##### December 03, 2009, 05:43:18 am #6
Great news! Something to look forward to AFTER Christmas

#### PG

##### December 03, 2009, 06:26:19 am #7
I think the biggest problem people have, I certainly do, is that they can see how you do it but can't understand why you'd want to. I can see what that function does but I wouldn't have the first clue how it works or what I could do with it. Maybe that's due to the awful syllabus that English schools are afflicted with, but if I wanted to create a swirling cloud mass or something like that I wouldn't have the first clue where to start. So I think a Terragen-centric maths lesson would be required first for a lot of people.
Figured out how to do clicky signatures

#### FrankB

##### December 03, 2009, 09:14:49 am #8
that's true, PG, and it gives me a headache when thinking about a tutorial that is to be broadly understood.
I don't feel inclined to teach maths as such, but then I also know that nobody will actually understand the use of functions, or use them purposefully without maths.

Secondly, I'm not a maths expert. I have once tried to create a cyclone function, but failed, because I don't know what the right math formula for it would be. Sometimes it's also difficult for me to translate pure math functions into node elements that are available in TG2. In maths, you often have to transform an equation, which is an art on its own, and requires a lot of knowledge in maths.

To take a very simple example, let's say you find in a book, that the formula you're looking to have is tan(x), and assume the TG2 doesn't have a TAN function node. If you don't know that you could transform TAN into sin(x)/cos(x) instead, you would be lost.

However, what i could do is explain the functions that I do understand, and how to a. build them in TG2, and b. apply them to a scene in TG2 in practice. That's as far as I can go with a tutorial. If that's still helpful, I'm happy to do it.

Cheers,
Frank

#### PG

##### December 03, 2009, 09:42:34 am #9
Yeah that seems the most sensible approach. I think that knowledge and teaching of mathematics varies too much between people and indeed between nations so even if we had a TG2-centric maths lesson it could still skip over areas that many don't understand.
Figured out how to do clicky signatures

#### domdib

##### December 03, 2009, 10:42:12 am #10
Perhaps some of the more mathematically inclined function experts might be able to supplement your work Frank? Maybe in that case it could go on the wiki, with links to some of the threads that have used functions in the past? Since I'm the one requesting it, I could do this.

#### Oshyan

##### December 03, 2009, 11:17:04 pm #11
The wiki would be a great place for collaboration on this, to be sure. But I think everyone should also keep strongly in mind that the vast majority of scenes - even those of highest quality - are accomplished without the use of functions, or at least without the creation of new function networks (i.e. someone may use an existing function network clip, but is unlikely to create some new technique). Function nodes are very powerful, to be sure, but they are not by any means a necessity to using TG, or even to knowing it well and accomplishing very complex and realistic scenes. They are perhaps most useful for accomplishing the unusual, the otherworldly, etc. though of course they also have potential value in realistic settings. But no one should have the impression that they're missing out and their TG2 scenes aren't good *because* of their lack of knowledge of function nodes.

Additionally, for anyone who does have a real interest in this, there are books written that will give you as good an introduction as anyone here could give you, and quite frankly a more comprehensive understanding that will be applicable not just to TG2, but the many other CG industry applications that build shaders in similar ways. This book has been suggested quite a few times, and it remains one of the best references available:
http://www.amazon.com/Texturing-Modeling-Procedural-Approach-Kaufmann/dp/1558608486/ref=sr_1_1?ie=UTF8&s=books&qid=1244894170&sr=1-1

The bottom line is if you're really interested in using the power of function nodes, you'll need a strong understanding of math, and to spend a good amount of time learning to understand how math can build 3D graphics. It will require dedication. If you're not already inclined toward math, you may not want to stick with it long enough to really get much innovation and benefit from function nodes. But again that doesn't mean your scenes will suffer.

- Oshyan

#### Henry Blewer

##### December 03, 2009, 11:50:15 pm #12
FrankB asked me to write about what I know. So I am going to be doing some experiments with them. When I think I have enough knowledge, I'll write up a tutorial about that group of functions.
Oshyan will probably need to make a bunch of corrections. But, at least then the thing will be correct.
It has been 15 years since I have done any real math, except for fractal programs like ChaosPro. But Chaospro makes it easy.
http://flickr.com/photos/njeneb/
Forget Tuesday; It's just Monday spelled with a T

#### Henry Blewer

##### December 04, 2009, 12:52:43 am #13
The book is kind of pricey, but the excerpts I read are well written.
http://flickr.com/photos/njeneb/
Forget Tuesday; It's just Monday spelled with a T

#### Oshyan

##### December 04, 2009, 12:58:17 am #14
Yeah, it's a bit steep. Maybe eBay?