2011-12-01 20:52:05 +00:00
|
|
|
// -*- mode: C; -*-
|
2015-03-29 11:47:58 +00:00
|
|
|
// UBERSHADER - vertex shader
|
2011-12-01 20:52:05 +00:00
|
|
|
// Licence: GPL v2
|
|
|
|
// © Emilian Huminiuc and Vivian Meazza 2011
|
|
|
|
#version 120
|
|
|
|
|
2015-03-29 11:47:58 +00:00
|
|
|
varying vec4 diffuseColor;
|
|
|
|
varying vec3 VBinormal;
|
2011-12-01 20:52:05 +00:00
|
|
|
varying vec3 VNormal;
|
|
|
|
varying vec3 VTangent;
|
2015-03-29 11:47:58 +00:00
|
|
|
varying vec3 rawpos;
|
|
|
|
varying vec3 eyeVec;
|
|
|
|
varying vec3 eyeDir;
|
2011-12-01 20:52:05 +00:00
|
|
|
|
|
|
|
attribute vec3 tangent;
|
|
|
|
attribute vec3 binormal;
|
|
|
|
|
|
|
|
uniform int nmap_enabled;
|
2012-04-01 17:20:33 +00:00
|
|
|
uniform int rembrandt_enabled;
|
2011-12-01 20:52:05 +00:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
rawpos = gl_Vertex.xyz;
|
|
|
|
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
2015-03-29 11:47:58 +00:00
|
|
|
eyeVec = ecPosition.xyz;
|
|
|
|
eyeDir = gl_ModelViewMatrixInverse[3].xyz - gl_Vertex.xyz;
|
2011-12-01 20:52:05 +00:00
|
|
|
|
|
|
|
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
2014-01-15 22:26:26 +00:00
|
|
|
|
2011-12-01 20:52:05 +00:00
|
|
|
vec3 n = normalize(gl_Normal);
|
2015-03-29 11:47:58 +00:00
|
|
|
|
|
|
|
// generate "fake" binormals/tangents
|
|
|
|
vec3 c1 = cross(n, vec3(0.0,0.0,1.0));
|
|
|
|
vec3 c2 = cross(n, vec3(0.0,1.0,0.0));
|
|
|
|
vec3 tempTangent = c1;
|
|
|
|
|
|
|
|
if(length(c2)>length(c1)){
|
|
|
|
tempTangent = c2;
|
|
|
|
}
|
|
|
|
|
2014-01-15 22:26:26 +00:00
|
|
|
vec3 tempBinormal = cross(n, tempTangent);
|
|
|
|
|
|
|
|
if (nmap_enabled > 0){
|
|
|
|
tempTangent = tangent;
|
|
|
|
tempBinormal = binormal;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTangent = normalize(gl_NormalMatrix * tempTangent);
|
|
|
|
VBinormal = normalize(gl_NormalMatrix * tempBinormal);
|
2011-12-01 20:52:05 +00:00
|
|
|
|
2015-03-29 11:47:58 +00:00
|
|
|
diffuseColor = gl_Color;
|
2014-01-15 22:26:26 +00:00
|
|
|
// Super hack: if diffuse material alpha is less than 1, assume a
|
|
|
|
// transparency animation is at work
|
2011-12-01 20:52:05 +00:00
|
|
|
if (gl_FrontMaterial.diffuse.a < 1.0)
|
2015-03-29 11:47:58 +00:00
|
|
|
diffuseColor.a = gl_FrontMaterial.diffuse.a;
|
2011-12-01 20:52:05 +00:00
|
|
|
|
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;
|
|
|
|
}
|
2015-03-29 11:47:58 +00:00
|
|
|
|
2011-12-01 20:52:05 +00:00
|
|
|
gl_Position = ftransform();
|
2015-03-29 11:47:58 +00:00
|
|
|
gl_ClipVertex = ecPosition;
|
2011-12-01 20:52:05 +00:00
|
|
|
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
|
|
|
}
|