… | |
… | |
102 | |
102 | |
103 | vout.position = wpos; |
103 | vout.position = wpos; |
104 | vout.tex_coord[0] = vin.tex_coord[0]; |
104 | vout.tex_coord[0] = vin.tex_coord[0]; |
105 | xyz (vout.tex_coord[1]) = normal_matrix * vin.normal; |
105 | xyz (vout.tex_coord[1]) = normal_matrix * vin.normal; |
106 | lightvec = xyz (lightpos - model_view_matrix * vin.vertex); |
106 | lightvec = xyz (lightpos - model_view_matrix * vin.vertex); |
107 | camdist = length (xyz (vout.tex_coord[2])); |
107 | camdist = 1 - max (length (xyz (vout.tex_coord[2])) / 10000., 0); |
108 | |
108 | |
109 | p.vsh->end (); |
109 | p.vsh->end (); |
110 | p.vsh->compile (); |
110 | p.vsh->compile (); |
111 | |
111 | |
112 | p.fsh->start (); |
112 | p.fsh->start (); |
… | |
… | |
115 | temp_2f disp; |
115 | temp_2f disp; |
116 | temp_1f dx, dy; |
116 | temp_1f dx, dy; |
117 | temp_1f bumpnormal; |
117 | temp_1f bumpnormal; |
118 | temp_1f dist; |
118 | temp_1f dist; |
119 | |
119 | |
120 | dist = min (x(camdist), 10000.); |
|
|
121 | |
|
|
122 | fac = dot (normalize (xyz (fin.tex_coord[1])), normalize (lightvec)); |
120 | fac = dot (normalize (xyz (fin.tex_coord[1])), normalize (lightvec)); |
123 | //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); |
124 | //fac = dot (bumpnormal, normalize (fin.tex_coord[2])); |
122 | //fac = dot (bumpnormal, normalize (fin.tex_coord[2])); |
125 | //fac = pow (max (fac, 0.0), 8); |
123 | //fac = pow (max (fac, 0.0), 8); |
126 | xyz (fout.frag_color) = (texture_2d (texvar, fin.tex_coord[0] - disp)) * max (fac * (0.4 + 1.F * (1 - dist / 10000.)), 0); |
124 | xyz (fout.frag_color) = (texture_2d (texvar, fin.tex_coord[0] - disp)) * max (fac * (0.4 + 1.F * camdist), 0); |
127 | |
125 | |
128 | p.fsh->end (); |
126 | p.fsh->end (); |
129 | p.fsh->compile (); |
127 | p.fsh->compile (); |
130 | p.link (); |
128 | p.link (); |
131 | } |
129 | } |