ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libgender/material.C
(Generate patch)

Comparing cvsroot/libgender/material.C (file contents):
Revision 1.25 by root, Mon Nov 1 01:57:03 2004 UTC vs.
Revision 1.27 by root, Mon Nov 1 20:20:22 2004 UTC

91 using namespace shader::compile; 91 using namespace shader::compile;
92 92
93 p.vsh->start (); 93 p.vsh->start ();
94 94
95 temp_4f wpos; 95 temp_4f wpos;
96 varying_1f camdist;
97 varying_3f lightvec;
96 98
97 wpos = model_view_projection_matrix * vin.vertex; 99 wpos = model_view_projection_matrix * vin.vertex;
98 100
99 //wpos = wpos / abs (w (wpos)); 101 //wpos = wpos / abs (w (wpos));
100 102
101 vout.position = wpos; 103 vout.position = wpos;
102 vout.tex_coord[0] = vin.tex_coord[0]; 104 vout.tex_coord[0] = vin.tex_coord[0];
103 xyz (vout.tex_coord[1]) = normal_matrix * vin.normal; 105 xyz (vout.tex_coord[1]) = normal_matrix * vin.normal;
104 xyz (vout.tex_coord[2]) = xyz (lightpos - model_view_matrix * vin.vertex); 106 lightvec = xyz (lightpos - model_view_matrix * vin.vertex);
105 w (vout.tex_coord[2]) = 1.; 107 camdist = 1 - max (length (xyz (vout.tex_coord[2])) / 10000., 0);
106 xw (vout.tex_coord[3]) = shader::compile::vec2 (length (xyz (vout.tex_coord[2])), 1.);
107 108
108 p.vsh->end (); 109 p.vsh->end ();
109 p.vsh->compile (); 110 p.vsh->compile ();
110 111
111 p.fsh->start (); 112 p.fsh->start ();
114 temp_2f disp; 115 temp_2f disp;
115 temp_1f dx, dy; 116 temp_1f dx, dy;
116 temp_1f bumpnormal; 117 temp_1f bumpnormal;
117 temp_1f dist; 118 temp_1f dist;
118 119
119 dist = min (x(fin.tex_coord[3]), 100.);
120
121 fac = dot (normalize (xyz (fin.tex_coord[1])), xyz (normalize (fin.tex_coord[2]))); 120 fac = dot (normalize (xyz (fin.tex_coord[1])), normalize (lightvec));
122 //fac = dot (shader::compile::vec3 (normalize (fin.tex_coord[1]) + normalize (fin.tex_coord[2])) * 0.5, bumpnormal); 121 //fac = dot (shader::compile::vec3 (normalize (fin.tex_coord[1]) + normalize (fin.tex_coord[2])) * 0.5, bumpnormal);
123 //fac = dot (bumpnormal, normalize (fin.tex_coord[2])); 122 //fac = dot (bumpnormal, normalize (fin.tex_coord[2]));
124 //fac = pow (max (fac, 0.0), 8); 123 //fac = pow (max (fac, 0.0), 8);
125 xyz (fout.frag_color) = (texture_2d (texvar, fin.tex_coord[0] - disp)) * max (fac, 1.2 * (1 - dist / 100.)); 124 xyz (fout.frag_color) = (texture_2d (texvar, fin.tex_coord[0] - disp)) * max (fac * (0.4 + 1.F * camdist), 0);
126 125
127 p.fsh->end (); 126 p.fsh->end ();
128 p.fsh->compile (); 127 p.fsh->compile ();
129 p.link (); 128 p.link ();
130} 129}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines