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.24 by root, Sun Oct 31 22:55:23 2004 UTC vs.
Revision 1.25 by root, Mon Nov 1 01:57:03 2004 UTC

98 98
99 //wpos = wpos / abs (w (wpos)); 99 //wpos = wpos / abs (w (wpos));
100 100
101 vout.position = wpos; 101 vout.position = wpos;
102 vout.tex_coord[0] = vin.tex_coord[0]; 102 vout.tex_coord[0] = vin.tex_coord[0];
103 vout.tex_coord[1] = model_view_matrix * shader::compile::vec4 (x(vin.normal), y(vin.normal), z(vin.normal), 0); 103 xyz (vout.tex_coord[1]) = normal_matrix * vin.normal;
104 vout.tex_coord[2] = lightpos - model_view_matrix * vin.vertex; 104 xyz (vout.tex_coord[2]) = xyz (lightpos - model_view_matrix * vin.vertex);
105 w (vout.tex_coord[2]) = 1.;
106 xw (vout.tex_coord[3]) = shader::compile::vec2 (length (xyz (vout.tex_coord[2])), 1.);
105 107
106 p.vsh->end (); 108 p.vsh->end ();
107 p.vsh->compile (); 109 p.vsh->compile ();
108 110
109 p.fsh->start (); 111 p.fsh->start ();
110 112
111 temp_1f fac; 113 temp_1f fac;
114 temp_2f disp;
115 temp_1f dx, dy;
116 temp_1f bumpnormal;
117 temp_1f dist;
112 118
113 temp_2f disp; 119 dist = min (x(fin.tex_coord[3]), 100.);
114 120
115 temp_1f dx, dy;
116
117 temp_1f bumpnormal;
118 dx = dFdx (texture_2d (normvar, fin.tex_coord[0]));
119 dy = dFdy (texture_2d (normvar, fin.tex_coord[0]));
120
121 disp = shader::compile::vec2 (dx, dy) * 0.1;
122
123 fac = dot (normalize (fin.tex_coord[1]), normalize (fin.tex_coord[2])); 121 fac = dot (normalize (xyz (fin.tex_coord[1])), xyz (normalize (fin.tex_coord[2])));
124 //fac = dot (shader::compile::vec3 (normalize (fin.tex_coord[1]) + normalize (fin.tex_coord[2])) * 0.5, bumpnormal); 122 //fac = dot (shader::compile::vec3 (normalize (fin.tex_coord[1]) + normalize (fin.tex_coord[2])) * 0.5, bumpnormal);
125 //fac = dot (bumpnormal, normalize (fin.tex_coord[2])); 123 //fac = dot (bumpnormal, normalize (fin.tex_coord[2]));
126 //fac = pow (max (fac, 0.0), 8); 124 //fac = pow (max (fac, 0.0), 8);
127 xyz (fout.frag_color) = (texture_2d (texvar, fin.tex_coord[0] - disp) + 0.1) * max (fac, 0.0); 125 xyz (fout.frag_color) = (texture_2d (texvar, fin.tex_coord[0] - disp)) * max (fac, 1.2 * (1 - dist / 100.));
128 126
129 p.fsh->end (); 127 p.fsh->end ();
130 p.fsh->compile (); 128 p.fsh->compile ();
131 p.link (); 129 p.link ();
132} 130}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines