View Full Version : Inserting functions
08-25-2003, 12:41 PM
How do I use a function that is inside the sl I have written. I don't have my example code with me.
displacement = function....
something like that... a bit vague I know but any help would be grand. Thanks heaps.
08-25-2003, 03:45 PM
OK, first I have to admit I have no idea what you are really trying to ask so heres a pretty vanilla answer.
b = foo();
If that does not answer your question try finding your example code and I'll give answering it another shot.
08-25-2003, 04:05 PM
If you are talking about RenderMan SL then you can only use floats - there are no doubles or int types.
You should definitely get Advanced RenderMan (http://www.amazon.com/exec/obidos/ASIN/1558606181/rendermania-20/103-2559086-3168627) by Antony Apodaca and Larry Gritz if you are learning SL. Both of them were involved in creating/updating the RenderMan standard. (Tony still works at Pixar).
08-25-2003, 09:51 PM
That is absolutely right about Renderman's SL. I was trying to make it as vanilla as possible and since I just added a few billion new doubles to the program I was working on at the time I just used doubles without thinking about it. I'll go edit it just for safety's sake.
08-27-2003, 11:32 AM
Well the example is in the book you speak of.... The worely noise function that is spoken of in Advanced renderman. I worte the code, then tried to add it to a shader. It wouldn't compile correctly, could that be because I am using pixie??
I think the vanilla answer gives me a good idea. I could have been trying to use the return variable instead of the function itself. Thanks
I will post the code in a couple of days as I forgot it again. Thanks for the help.
08-27-2003, 03:46 PM
If you wanted to use a member variable you could do this
m_a = a+b;
a = m_a;
08-27-2003, 07:02 PM
Using global variables is BAD!!!! Plus renderman doesn't let you do it anyway .
If you want to pass by reference then just add output infront of the variable you pass into your function
float foo(output varying float m_a)
/* DO SOMETHING */
m_a = a + b;
and call as
answer = float(m_a);
Which is a good way of getting back two values from a function.
RenderMan has scoping anyway so to access a global variable you have to declare it as extern in the function. You even have to do this for P,N etc and L and Cl in illuminance loops (although some compilers let you get away with it).
Just had a look at voronoi which I guess is the one you mean. If you look the return type is void. ie it doesn't return anything! All the values you get back through output variables. A lot of functions are going this way.
So you need to create empty variables, call the function
And your empty variables will magically be filled! AKA pass by reference.
01-16-2006, 12:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.