2011-12-01 20:52:05 +00:00
|
|
|
// -*- mode: C; -*-
|
|
|
|
// Licence: GPL v2
|
|
|
|
// © Emilian Huminiuc and Vivian Meazza 2011
|
|
|
|
#version 120
|
|
|
|
|
|
|
|
varying vec3 rawpos;
|
|
|
|
varying vec3 VNormal;
|
|
|
|
varying vec3 VTangent;
|
|
|
|
varying vec3 VBinormal;
|
|
|
|
varying vec3 vViewVec;
|
|
|
|
varying vec3 reflVec;
|
2013-01-31 12:15:18 +00:00
|
|
|
varying vec3 vertVec;
|
2011-12-01 20:52:05 +00:00
|
|
|
|
|
|
|
varying float alpha;
|
|
|
|
|
|
|
|
attribute vec3 tangent;
|
|
|
|
attribute vec3 binormal;
|
|
|
|
|
|
|
|
uniform float pitch;
|
|
|
|
uniform float roll;
|
|
|
|
uniform float hdg;
|
|
|
|
uniform int refl_dynamic;
|
|
|
|
uniform int nmap_enabled;
|
|
|
|
uniform int shader_qual;
|
2012-04-01 17:20:33 +00:00
|
|
|
uniform int rembrandt_enabled;
|
2011-12-01 20:52:05 +00:00
|
|
|
|
|
|
|
//////Fog Include///////////
|
2012-02-14 16:38:18 +00:00
|
|
|
// uniform int fogType;
|
|
|
|
// void fog_Func(int type);
|
2011-12-01 20:52:05 +00:00
|
|
|
////////////////////////////
|
|
|
|
|
|
|
|
void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float cosRy, out mat4 rotmat)
|
|
|
|
{
|
2012-05-01 11:58:35 +00:00
|
|
|
rotmat = mat4( cosRy , sinRx * sinRy , cosRx * sinRy, 0.0,
|
2011-12-01 20:52:05 +00:00
|
|
|
0.0 , cosRx , -sinRx * cosRx, 0.0,
|
|
|
|
-sinRy, sinRx * cosRy, cosRx * cosRy , 0.0,
|
|
|
|
0.0 , 0.0 , 0.0 , 1.0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rotationMatrixH(in float sinRz, in float cosRz, out mat4 rotmat)
|
|
|
|
{
|
|
|
|
rotmat = mat4( cosRz, -sinRz, 0.0, 0.0,
|
2012-05-01 11:58:35 +00:00
|
|
|
sinRz, cosRz, 0.0, 0.0,
|
|
|
|
0.0 , 0.0 , 1.0, 0.0,
|
|
|
|
0.0 , 0.0 , 0.0, 1.0 );
|
2011-12-01 20:52:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
rawpos = gl_Vertex.xyz;
|
|
|
|
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
2012-02-14 16:38:18 +00:00
|
|
|
//fog_Func(fogType);
|
2011-12-01 20:52:05 +00:00
|
|
|
|
|
|
|
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
2011-12-13 11:21:59 +00:00
|
|
|
if (nmap_enabled > 0 && shader_qual > 2){
|
2011-12-01 20:52:05 +00:00
|
|
|
VTangent = normalize(gl_NormalMatrix * tangent);
|
|
|
|
VBinormal = normalize(gl_NormalMatrix * binormal);
|
|
|
|
} else {
|
|
|
|
VTangent = vec3(0.0);
|
|
|
|
VBinormal = vec3 (0.0);
|
|
|
|
}
|
|
|
|
vec3 n = normalize(gl_Normal);
|
|
|
|
vec3 t = cross(n, vec3(1.0,0.0,0.0));
|
|
|
|
vec3 b = cross(n,t);
|
|
|
|
|
|
|
|
// 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
|
2013-01-31 12:15:18 +00:00
|
|
|
vertVec = ecPosition.xyz;
|
2011-12-01 20:52:05 +00:00
|
|
|
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);
|
|
|
|
vec3 reflVec_stat = normalize(gl_ModelViewMatrixInverse * reflect_eye).xyz;
|
|
|
|
if (refl_dynamic > 0){
|
|
|
|
//prepare rotation matrix
|
|
|
|
mat4 RotMatPR;
|
|
|
|
mat4 RotMatH;
|
|
|
|
float _roll = roll;
|
|
|
|
if (_roll>90.0 || _roll < -90.0)
|
|
|
|
{
|
|
|
|
_roll = -_roll;
|
|
|
|
}
|
|
|
|
float cosRx = cos(radians(_roll));
|
|
|
|
float sinRx = sin(radians(_roll));
|
|
|
|
float cosRy = cos(radians(-pitch));
|
|
|
|
float sinRy = sin(radians(-pitch));
|
|
|
|
float cosRz = cos(radians(hdg));
|
|
|
|
float sinRz = sin(radians(hdg));
|
|
|
|
rotationMatrixPR(sinRx, cosRx, sinRy, cosRy, RotMatPR);
|
|
|
|
rotationMatrixH(sinRz, cosRz, RotMatH);
|
|
|
|
vec3 reflVec_dyn = (RotMatH * (RotMatPR * normalize(gl_ModelViewMatrixInverse * reflect_eye))).xyz;
|
|
|
|
|
|
|
|
reflVec = reflVec_dyn;
|
|
|
|
} else {
|
|
|
|
reflVec = reflVec_stat;
|
|
|
|
}
|
|
|
|
|
2012-04-01 17:20:33 +00:00
|
|
|
if(rembrandt_enabled < 1){
|
2012-05-01 11:58:35 +00:00
|
|
|
gl_FrontColor = gl_FrontMaterial.emission + gl_Color
|
|
|
|
* (gl_LightModel.ambient + gl_LightSource[0].ambient);
|
2012-04-01 17:20:33 +00:00
|
|
|
} else {
|
|
|
|
gl_FrontColor = gl_Color;
|
|
|
|
}
|
2011-12-01 20:52:05 +00:00
|
|
|
gl_Position = ftransform();
|
|
|
|
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
|
|
|
}
|