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
Illuminance troubles
3155 4 0- Wish
- Member
- 282 posts
- Joined: Jan. 2006
- Offline
- Mario Marengo
- 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.
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.
- Wish
- Member
- 282 posts
- Joined: Jan. 2006
- Offline
- Wish
- Member
- 282 posts
- Joined: Jan. 2006
- Offline
- Wish
- Member
- 282 posts
- Joined: Jan. 2006
- Offline
-
- Quick Links