Jump to content

Ambient()


B.Walters

Recommended Posts

As a wonderful Christmas present, I received the Advanced Renderman book and I've been plowing through it full-speed. Now that I'm back at home/work, I've been trying to actually implement a lot of the shaders in VEX (mostly from memory to see if I really understand them). But I hit a problem-spot early on with the ambient function.

Here's what I've tried:

vector my_ambient()

{

vector C = 0;

illuminance(P, N, PI*2, LIGHT_AMBIENT)

{

C += Cl;

}

return C;

}

The problem is my_ambient always returns 0 - no lights are getting passed through the luminance loop. If I change the argument LIGHT_AMBIENT to LIGHT_AMBIENT|LIGHT_DIFFUSE|LIGHT_SPECULAR - then it will loop through any other normal lights I have in the scene (and sum up their values), but still not the ambient light.

So I know it's something small/simple, but I can't figure it out. By the way, is there anyway to see what Houdini's built-in ambient() looks like?

Link to comment
Share on other sites

An ambient lights is a different object type than a normal light and, as in PRMan, the only way to access its contribution is through the built-in function "ambient()". So your my_ambient() function would simply forward the call to the built-in one (not very useful except as an exercise):

vector my_ambient() {
   return ambient();
}

IOW: ambient lights are not iterated over in an illuminance loop. Instead, their contribution is fetched using the ambient() function.

However, this doesn't mean that you can't have a normal light that behaves like an ambient light and that will show up in normal illuminance loops. The following *light* shader is an example:

light my_ambient(
	  vector lightcolor = 1;
	  float  intensity  = 1;
   ) 
{
   Cl = lightcolor*intensity;
   L  = 0;
}

If you assign this last shader to a normal light, it will show up in an illuminance loop (due to the fact that it is a light object as opposed to an ambient light object), and it will emulate the behaviour of a standard ambient light (in terms of shading).

HTH.

P.S: Happy New Year Everyone! :)

Link to comment
Share on other sites

As a wonderful Christmas present, I received the Advanced Renderman book and I've been plowing through it full-speed. Now that I'm back at home/work, I've been trying to actually implement a lot of the shaders in VEX (mostly from memory to see if I really understand them). But I hit a problem-spot early on with the ambient function.

Here's what I've tried:

The problem is my_ambient always returns 0 - no lights are getting passed through the luminance loop. If I change the argument LIGHT_AMBIENT to LIGHT_AMBIENT|LIGHT_DIFFUSE|LIGHT_SPECULAR - then it will loop through any other normal lights I have in the scene (and sum up their values), but still not the ambient light.

So I know it's something small/simple, but I can't figure it out. By the way, is there anyway to see what Houdini's built-in ambient() looks like?

Actually, I think this was a bug in H8. I think it works in H9 (from what a little bird tells me).

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...