Illuminance troubles

   3155   4   0
User Avatar
Member
282 posts
Joined: Jan. 2006
Offline
Hi! I got troubles with shadow calculation. I'm making calculation by shadow(vector) function. I have 3 lights in the scene. 2 of them with shadows and one without. Light without shader is lights up the shadowside of the model and the color of the model in shadow must not be zero equal. But it does. I think there must be smth like:
if(recieveshadow) {
shadow()
}

What is the recieveshadow function is?
Thanks
Houdini is great! O'right?
User Avatar
Member
941 posts
Joined: July 2005
Offline
There's no VEX function called “receiveshadow()” that I'm aware of; and the way it's used in your code snippet implies it's a variable (likely of type int), not a function.
If all your lights are H9's default (“hlight”) and one of them has “Shadow Type” set to “No Shadows” then it will not cast shadows (at least not via the shadow() call in an illuminance loop). Period. So something else is going on.
You'd normally call the “shadow()” function within an illuminance block to run any shadow shaders associated with the light being looped over. However, the function takes at least one argument, which is the color that needs to be attenuated. So, for example, for a standard hand-rolled diffuse calculation, things might look like this:

//…//
vector Nf = normalize(frontface(N,I));
vector Cdiff = 0;
illuminance(P,Nf) {
// run shadow shader to attenuate Cl
shadow(Cl);
// add this light's contribution to diffuse
Cdiff += Cl * diffuseBRDF(normalize(L),Nf);
}

// Cdiff now holds the shadowed diffuse calculation
//…//

Note that the diffuse() function will do all that for you though, so there's no need to do it yourself unless you're doing something fancier than standard diffuse or specular – I'm only showing diffuse as an example of how shadow() would be used.

Also note that the surface and/or light shader has the option to bypass the whole “shadow shader” mechanism and do its own shadow calculations using fastshadow(), filtershadow(), occlusion(), etc. So the above is true only as long as you don't deviate from the standard way of doing things – i.e: calling diffuse() and specular(), etc. and building your illuminance loops as in the example above.

I can pretty much guarantee that if you're only using “hlight”s, and one of them is set to “No Shadows”, then for that light, the call “shadow(Cl)” in the code above will have no effect – i.e: it will not attenuate Cl.

HTH.
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
282 posts
Joined: Jan. 2006
Offline
Hi Mario! Thanks for the reply. I will try to find what's going on. I thought that the problem was in shad()
Houdini is great! O'right?
User Avatar
Member
282 posts
Joined: Jan. 2006
Offline
nothing helps. I really can't understand what's wrong.

illuminance (pp, nn, PI, LIGHT_DIFFUSE|LIGHT_SPECULAR) {
int nondiff = 0;
int nonspec = 0;
limport(“__nondiffuse”,nondiff);
limport(“__nonspecular”,nonspec);

shadow(Cl);

Cspec += Cl*uv.x;
Cdiff += Cl*uv.x;
}
Houdini is great! O'right?
User Avatar
Member
282 posts
Joined: Jan. 2006
Offline
Problem is solved. LIGHT_DIFFUSE|LIGHT_SPECULAR is wrong
Houdini is great! O'right?
  • Quick Links