2010-09-21 06:23:13 +00:00
|
|
|
|
// -*- mode: C; -*-
|
|
|
|
|
// Licence: GPL v2
|
2011-12-01 20:57:20 +00:00
|
|
|
|
// <20> Emilian Huminiuc and Vivian Meazza 2011
|
2010-09-21 06:23:13 +00:00
|
|
|
|
|
2011-02-16 08:48:58 +00:00
|
|
|
|
varying vec3 rawpos;
|
|
|
|
|
varying float fogCoord;
|
2010-09-21 06:23:13 +00:00
|
|
|
|
varying vec3 VNormal;
|
2010-09-21 07:17:07 +00:00
|
|
|
|
varying vec3 VTangent;
|
|
|
|
|
varying vec3 VBinormal;
|
2010-09-21 06:23:13 +00:00
|
|
|
|
varying vec3 Normal;
|
|
|
|
|
varying vec3 vViewVec;
|
|
|
|
|
varying vec3 reflVec;
|
|
|
|
|
|
|
|
|
|
varying vec4 Diffuse;
|
2011-02-16 08:48:58 +00:00
|
|
|
|
varying float alpha;
|
2010-09-21 06:23:13 +00:00
|
|
|
|
|
|
|
|
|
uniform mat4 osg_ViewMatrixInverse;
|
|
|
|
|
|
|
|
|
|
attribute vec3 tangent;
|
|
|
|
|
attribute vec3 binormal;
|
|
|
|
|
|
2011-12-01 20:57:20 +00:00
|
|
|
|
////fog "include"////////
|
|
|
|
|
uniform int fogType;
|
|
|
|
|
|
|
|
|
|
void fog_Func(int type);
|
|
|
|
|
/////////////////////////
|
|
|
|
|
|
2010-09-21 06:23:13 +00:00
|
|
|
|
void main(void)
|
|
|
|
|
{
|
2011-02-16 08:48:58 +00:00
|
|
|
|
rawpos = gl_Vertex.xyz / gl_Vertex.w;
|
|
|
|
|
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
|
|
|
|
ecPosition.xyz = ecPosition.xyz / ecPosition.w;
|
|
|
|
|
fogCoord = ecPosition.z;
|
2011-12-01 20:57:20 +00:00
|
|
|
|
fog_Func(fogType);
|
2010-09-21 06:23:13 +00:00
|
|
|
|
|
|
|
|
|
vec3 n = normalize(gl_Normal);
|
2011-02-16 08:48:58 +00:00
|
|
|
|
vec3 t = cross(gl_Normal, vec3(1.0,0.0,0.0));
|
|
|
|
|
vec3 b = cross(n,t);
|
2010-09-21 06:23:13 +00:00
|
|
|
|
|
|
|
|
|
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
2011-02-16 08:48:58 +00:00
|
|
|
|
VTangent = normalize(gl_NormalMatrix * tangent);
|
|
|
|
|
VBinormal = normalize(gl_NormalMatrix * binormal);
|
2010-09-21 06:23:13 +00:00
|
|
|
|
Normal = normalize(gl_Normal);
|
|
|
|
|
|
|
|
|
|
Diffuse = gl_Color * gl_LightSource[0].diffuse;
|
|
|
|
|
//Diffuse= gl_Color.rgb * max(0.0, dot(normalize(VNormal), gl_LightSource[0].position.xyz));
|
2011-02-16 08:48:58 +00:00
|
|
|
|
|
2010-09-21 06:23:13 +00:00
|
|
|
|
// Super hack: if diffuse material alpha is less than 1, assume a
|
|
|
|
|
// transparency animation is at work
|
|
|
|
|
if (gl_FrontMaterial.diffuse.a < 1.0)
|
|
|
|
|
alpha = gl_FrontMaterial.diffuse.a;
|
|
|
|
|
else
|
|
|
|
|
alpha = gl_Color.a;
|
|
|
|
|
|
|
|
|
|
// Vertex in eye coordinates
|
|
|
|
|
vec3 vertVec = ecPosition.xyz;
|
|
|
|
|
|
|
|
|
|
vViewVec.x = dot(t, vertVec);
|
|
|
|
|
vViewVec.y = dot(b, vertVec);
|
|
|
|
|
vViewVec.z = dot(n, vertVec);
|
|
|
|
|
|
|
|
|
|
// calculate the reflection vector
|
|
|
|
|
vec4 reflect_eye = vec4(reflect(vertVec, VNormal), 0.0);
|
|
|
|
|
reflVec = normalize(gl_ModelViewMatrixInverse * reflect_eye).xyz;
|
|
|
|
|
|
2011-02-16 08:48:58 +00:00
|
|
|
|
gl_FrontColor = gl_FrontMaterial.emission + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient);
|
2010-09-21 06:23:13 +00:00
|
|
|
|
|
|
|
|
|
gl_Position = ftransform();
|
|
|
|
|
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
2011-02-16 08:48:58 +00:00
|
|
|
|
}
|