Shader problem

各位可在這裡交流有關RenderMan的問題和分享制作經驗

Shader problem

文章jly625 » 15日 4月 2002年, 13:30

I would like to know how to specify one light which only affect diffuse or specular in one surface shader.

i.e.

light 1, 2, 3, 4, 5 --> only affect diffuse, not affect specular.
light 6 --> only affect specular, not affect diffuse.

thanks!
jly625
討論區新秀
討論區新秀
 
文章: 55
註冊時間: 21日 2月 2002年, 08:00
來自: Hong Kong

Share On:

Share on Facebook Facebook Share on Twitter Twitter

Try message passing

文章likforce » 18日 4月 2002年, 18:33

You can use message passing to transfer data from lightshader to surface shader
here is the lightshader :

light dirlight(
color lightcolor = 1;
float intensity = 1;
output float nondiffuse = 1;
output float nonspecular = 0
)
{
vector dir = vector "shader" (0,0,1);

solar( dir, 0 )
Cl = intensity * lightcolor;
}


the two param "nondiffuse" and "nonspecular" is to control the light effect on the surface
i.e.
nondiffuse = 1 => no diffuse on surface
nonspecular =1 => no specular on surface

here is the surface shader :
color diffuse(normal Nn)
{
extern point P;
color C = 0;
illuminance(P, Nn, PI/2)
{
float nondiff = 0;
lightsource("nondiffuse", nondiff);
C += Cl * (1 - nondiff) * (Nn . normalize(L));
}
return C;
}

color specular (normal Nn; vector V; float roughness)
{
extern point P;
color C = 0;
illuminance (P, Nn, PI/2)
{
float nonspec = 0;
lightsource("nonspecular", nonspec);
vector H = normalize(normalize(L) + V);
C += Cl * (1 - nonspec) * pow(max(0, Nn . H), 1/roughness);
}
return C;
}

surface testshader(color col1 = 0.5;
float roughness = 0.2,
Kd = 1,
Ks = 1)
{
normal Nn = normalize(N);
vector In = normalize(-I);

Ci = col1 * (Kd * diffuse(Nn)) + (Ks * specular(Nn, In, roughness));
}



Then u can get this:
圖檔[/img]
likforce
討論區新秀
討論區新秀
 
文章: 2
註冊時間: 28日 9月 2001年, 08:00

文章jly625 » 18日 4月 2002年, 22:18

I've got it

Thanks guy!!
jly625
討論區新秀
討論區新秀
 
文章: 55
註冊時間: 21日 2月 2002年, 08:00
來自: Hong Kong


回到 Pixar's RenderMan

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 19 位訪客