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

Comparing libgender/material.C (file contents):
Revision 1.29 by root, Tue Nov 2 02:59:33 2004 UTC vs.
Revision 1.30 by root, Wed Nov 3 01:12:34 2004 UTC

88: tex ("textures/rockwall.jpg"), texvar (tex.name) 88: tex ("textures/rockwall.jpg"), texvar (tex.name)
89, norm ("textures/rockwall_height.jpg"), normvar (norm.name) 89, norm ("textures/rockwall_height.jpg"), normvar (norm.name)
90{ 90{
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, zpos; 96 varying_1f camdist, zpos;
97 varying_2f texcoord; 97 varying_2f texcoord;
98 varying_3f lightvec, normal; 98 varying_3f lightvec, normal;
106 texcoord = xy (vin.tex_coord[0]); 106 texcoord = xy (vin.tex_coord[0]);
107 normal = normal_matrix * vin.normal; 107 normal = normal_matrix * vin.normal;
108 lightvec = xyz (lightpos - model_view_matrix * vin.vertex); 108 lightvec = xyz (lightpos - model_view_matrix * vin.vertex);
109 camdist = 1 - max (length (lightvec) / 10000., 0); 109 camdist = 1 - max (length (lightvec) / 10000., 0);
110 110
111 p.vsh->stop (); 111 p->vsh->stop ();
112 112
113 p.fsh->start (); 113 p->fsh->start ();
114 114
115 temp_1f fac; 115 temp_1f fac;
116 temp_2f disp; 116 temp_2f disp;
117 temp_1f dx, dy; 117 temp_1f dx, dy;
118 temp_1f bumpnormal; 118 temp_1f bumpnormal;
122 //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);
123 //fac = dot (bumpnormal, normalize (fin.tex_coord[2])); 123 //fac = dot (bumpnormal, normalize (fin.tex_coord[2]));
124 fac = pow (max (fac, 0.0), 2); 124 fac = pow (max (fac, 0.0), 2);
125 xyz (fout.frag_color) = texture_2d (texvar, texcoord) * (fac + 0.4) * camdist; 125 xyz (fout.frag_color) = texture_2d (texvar, texcoord) * (fac + 0.4) * camdist;
126 126
127 p.fsh->stop (); 127 p->fsh->stop ();
128 p.link (); 128 p->link ();
129} 129}
130 130
131void test_material::enable (view &ctx) 131void test_material::enable (view &ctx)
132{ 132{
133 p.enable (); 133 p->enable ();
134 lightpos->set (vec3 (0, 0, 0)); 134 lightpos->set (vec3 (0, 0, 0));
135 texvar->enable (); 135 texvar->enable ();
136 normvar->enable (); 136 normvar->enable ();
137} 137}
138 138
139void test_material::disable (view &ctx) 139void test_material::disable (view &ctx)
140{ 140{
141 normvar->disable (); 141 normvar->disable ();
142 texvar->disable (); 142 texvar->disable ();
143 p.disable (); 143 p->disable ();
144} 144}
145 145

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines