View Full Version : PrMan shader argument question

04 April 2005, 02:03 AM
In a shader argument, sometimes a comma is used to separate arguments and sometimes a semicolon. What is the requirement for when a semicolon is used and when a comma is used? For example this wood shader from the site:

surface woodShader( float Ka = 1,
Kd = 1,
Ks = 1,
roughness = 0.1;
float ringscale = 10;
color specularcolor = 1;
color lightwood = color(0.3, 0.12, 0.03);
color darkwood = color(0.05, 0.01, 0.005);)

The K params are comma-separated, and the floats and colors are separated by semicolons.


04 April 2005, 09:41 AM
As far as I know, the comma separated lists are all the same type, similar to declaring a number of variables of the same type in one line, i.e.

float a, b, c, d;
int e,f,g;

In your example, the ringscale argument could have been separated from the roughness argument by a comma, and the last three color arguments could all have been separated by a comma. Just what the author wants to do.

Hope this helps


04 April 2005, 12:49 PM
Paul's right. Arguments of the same type (color/float/string) and detail (uniform/varying) can be seperated by commas in the argument list without redeclaring the type. Otherwise you must use semicolons between each argument.

Personally I find it much easier to just use semicolons everywhere. It makes your argument lists a lot easier to read, especially if you give each on a seperate line, like so:

surface wood (

uniform float Ka =1;
uniform float Kd = 1;
uniform float Ks = 1;
output varying color __diffuse;


CGTalk Moderation
04 April 2005, 12:49 PM
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.