Jump to content

Shader Functions Question


peliosis

Recommended Posts

There are two nice functions in sig02.course16.pdf paper page 59 listing 3.3 :

float bias(varying float value, b) {
return (b > 0) ? pow(value, log(b) / log(0.5)) : 0;
}
float gain(float value, g) {
return .5 * ((value < .5) ? bias(2*value, 1-g) :
(2 - bias(2-2*value, 1-g)));
}

Everything is ok, I created a file with them, but one thing bugged me from the beginning: "varying float value"????

And soon I noticed that this bastard busted my shader because the file couldn't be included.

As soon as I delete the word "varying", everything works like a charm apart from me not being sure if I haven't messed things up:)

Could you explain what is a varying float, is it a valid C++ type (I believe the functions are in C++?)

and why it doesn't work. Is it possible that deleting the word changed the function a bit?

Sincerely yours :ph34r:

Link to comment
Share on other sites

Hi peliosis,

In Vex i think there is no 'varying' keyword, in renderman if i'm not mistaken it is meant to diferentiate from a variable that is actually constant along the surface (or in renderman 'uniform') from one that actually varies along the surface and as such 'varying' i believe Vex and Mantra make no such distinction.

One possible example of a non-varying variable or 'uniform' is the Specular color for instance assuming a constant color is passed while a texture map will be a 'varying' variable.

As far as i can see you are not breaking anything in the shader as the use of these keywords even in renderman is at least most of the times not a requirement.

Cheers

Link to comment
Share on other sites

You are right, there is varying float, but it rarely exists in rman data type lists.

Thanks for the answer, I'm completely satisfied if it doesn't change the look of my surface :)

I thought 'uniform' and 'varying' types were hints to renderman in how it should optimize shading across the surface, no? :unsure:

Link to comment
Share on other sites

I thought 'uniform' and 'varying' types were hints to renderman in how it should optimize shading across the surface, no? :unsure:

That is correct, a uniform variable is simply one that doesn't change across a surface, so renderman only needs to store it once. Consider it like a detail attribute.

I'm pretty sure that in vex shaders everything is considered "varying" ie. it's assumed to be non constant and vary on a per point basis.

Link to comment
Share on other sites

That is correct, a uniform variable is simply one that doesn't change across a surface, so renderman only needs to store it once. Consider it like a detail attribute.

I'm pretty sure that in vex shaders everything is considered "varying" ie. it's assumed to be non constant and vary on a per point basis.

Actually, the VEX optimizer performs static analysis at runtime to automatically determine uniform/varying status of variables. So the uniform/varying keywords are redundant.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...