shadow map in Houdini

   5341   2   0
User Avatar
Member
288 posts
Joined: July 2005
Offline
could anybody tell me how to make shadow map in Houdini with PRMAN?
Greate thx…!
^_^
User Avatar
Member
288 posts
Joined: July 2005
Offline
I can make shadow map now,

light distantlig(
float intensity = 1;
color lightcol = 1;
)
{
vector dir = vector “shader” (0,0,1);
solar(dir, 0)
Cl = intensity * lightcol ;
}
this is my light shader. how to insert the shadow map to my custom light shader?
^_^
User Avatar
Member
941 posts
Joined: July 2005
Offline
ykcosmo
I can make shadow map now,

light distantlig(
float intensity = 1;
color lightcol = 1;
)
{
vector dir = vector “shader” (0,0,1);
solar(dir, 0)
Cl = intensity * lightcol ;
}
this is my light shader. how to insert the shadow map to my custom light shader?

1. Add a string parameter so you can tell your shader what the name of the shadow map is (if any).

2. After calculating the light intensity, you look up the given shadow map (with the map's name and the surface point “Ps” as parameters) and see if the light is blocked for the current sample. You attenuate the intensity according to this info.
Also note that shadows are hardly ever absolute *black*. So it's good to add a control to tint the shadow.

3. Given that these are mapped shadows (as opposed to ray-traced), it's a good idea to add controls for “bias” and “blur”.

4. If you're using PRMan11, then it'd be wise to add the option of actually tracing the shadows (instead of using the maps).

5. Your surface shaders may want to limit light contributions to just the diffuse component, or just the specular component. You can specify this (to the rest of the shading system) by using the special parameters __nondiffuse and __nonspecular – see the PRMan help.

6. Sometimes light masks are not enough. This happens when parts of the same object need to be lit by a subset of the group in the mask (for some effect). This can, again, be done through the use of the special string parameter “__category” – see the PRMan help.

7. It is not uncommon to want to do a “shadow” pass. One way to do this is to “reverse” the lighting – light where there is shadow and black everywhere else. It doesn't directly give you an alpha mask but you can get that from the luminance.

8. Always a good idea to add controls for how the sampling (of either the map or the solid cone in the case of tracing) is done. So we add that as well. Be aware that for maps, a value of 16 makes little difference in render time, but this number of samples has a much greater impact if shadows are traced – samples and blur are tightly linked; see the PRMan help.

Why mention all of this? Because these things are common to *all* light shaders.
If you get into the habit of keeping all these things in mind *now*, then you won't have to reinvent your light shaders a thousand times as your needs grow.

Here's your shader with the modifications I mentioned above – you can use it as a little template for most basic light shaders (cone, point, etc):


light distantlig(
string __category = “Distant”;
float __nondiffuse=0,__nonspecular=0;
float intensity=1 ;
color lightcolor=1 ;
float traceshadows = 0;
string shadowmap = “”;
color shadowcolor = 0;
float invertshadow=0;
float shadowsamples=1;
float shadowblur=0;
float shadowbias=.05;
)
{
float Kshadow;
uniform string shmaptraceshadows!=1)?shadowmap:“raytrace”;

solar(vector “shader” (0,0,1), 0.0 ) {Cl = intensity * lightcolor;}

if (shmap != “”) {
Kshadow=shadow(shmap,Ps,“samples”,shadowsamples,“bias”,shadowbias,
“blur”, shadowblur);
Kshadow=invertshadow==0?Kshadow:1-Kshadow;
Cl = mix(Cl,shadowcolor,Kshadow);
}
}
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
  • Quick Links