File: hmatte.sl

package info (click to toggle)
geomview 1.9.5-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,096 kB
  • sloc: ansic: 93,696; sh: 12,051; cpp: 1,215; makefile: 1,075; objc: 263; perl: 153; yacc: 152; tcl: 76; lex: 74
file content (39 lines) | stat: -rw-r--r-- 874 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
surface
hmatte(
	float Ka	= 0.05,
		Kd	= 1;
	)
{
	float	Lhw,Nhw;	/* w-cord of hyperbolic normal vector to P */
	point	Nh, Lh;	/* first 3 cords of hyperbolic normal vector to P */
	point   Px;
	float	b,d,nn;

	Nh = faceforward(normalize(N),I);
	Px = transform("shader",P);

	/* compute plane equation */
    Ci = 0;
    illuminance(Px)
	{
	Nhw = Px.Nh;
	b = -(L.Px - 0)/(Px.Px - 1);
	Lh = L + b*Px;		/* hyperbolic light vector is lin comb of L,P */
	Lhw = 0 + b;
	d = (Lh.Nh - Lhw*Nhw)/sqrt(abs((Lh.Lh - Lhw*Lhw)*(Nh.Nh - Nhw*Nhw)));

	if (d < 0.0)	d = -d;
	if (d > 1.0)	{
/*
	    printf("Light:%f %f %f %f\n",xcomp(Lh),ycomp(Lh),zcomp(Lh),Lhw);
	    printf("Normal:%f %f %f %f\n",xcomp(Nh),ycomp(Nh),zcomp(Nh),Nhw);
	    printf("Posi:%f %f %f 1.0\n",xcomp(Px),ycomp(Px),zcomp(Px));
*/
	    d = 1.0; 
	    }

	Ci += Os * Cs * (Ka*ambient() + Cl*Kd*d );
	}
    Oi = Os;
}