1
0
Fork 0

Revert Shaders/model-ALS-ultra.frag (ALS ubershader) changes made necessary by the last commit.

Add ALS specific vertex shader for ubershader.vert and buildings-ubershader.vert named model-ALS-ultra.vert and buildings-model-ALS-ultra.vert respectively. This partly reverts 3dc0e641c1 . Aircraft modelers and other consumers need not take any action.
This commit is contained in:
Emilian Huminiuc 2015-05-14 14:54:19 +02:00 committed by Christian Schmitt
parent f5a3913a31
commit 9d7b575a45
5 changed files with 310 additions and 161 deletions

View file

@ -189,11 +189,11 @@
</internal-format>
</texture-unit>
<program>
<vertex-shader n="1">Shaders/building-ubershader.vert</vertex-shader>
<vertex-shader n="0">Shaders/building-model-ALS-ultra.vert</vertex-shader>
<fragment-shader n="1">Shaders/model-ALS-ultra.frag</fragment-shader>
<fragment-shader n="2">Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader n="3">Shaders/hazes.frag</fragment-shader>
<fragment-shader n="4">Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader n="2">Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader n="3">Shaders/hazes.frag</fragment-shader>
<fragment-shader n="4">Shaders/secondary_lights.frag</fragment-shader>
</program>
</pass>
</technique>

View file

@ -141,7 +141,7 @@ please see Docs/README.model-combined.eff for documentation
<scattering><use>/rendering/scene/scattering</use></scattering>
<terminator><use>/environment/terminator-relative-position-m</use></terminator>
<fogtype><use>/sim/rendering/shaders/skydome</use></fogtype>
<wetness><use>/environment/surface/wetness</use></wetness>
<wetness><use>/environment/surface/wetness</use></wetness>
<rnorm><use>/environment/rain-norm</use></rnorm>
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
@ -432,7 +432,7 @@ please see Docs/README.model-combined.eff for documentation
</vertex-program-two-side>
<program>
<vertex-shader n="1">Shaders/ubershader.vert</vertex-shader>
<vertex-shader n="0">Shaders/model-ALS-ultra.vert</vertex-shader>
<fragment-shader n="1">Shaders/model-ALS-ultra.frag</fragment-shader>
<fragment-shader n="2">Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader n="3">Shaders/hazes.frag</fragment-shader>
@ -1143,21 +1143,6 @@ please see Docs/README.model-combined.eff for documentation
<use>rembrandt</use>
</value>
</uniform>
<uniform>
<name>lonDeg</name>
<type>float</type>
<value>
<use>pos-lon</use>
</value>
</uniform>
<uniform>
<name>latDeg</name>
<type>float</type>
<value>
<use>pos-lat</use>
</value>
</uniform>
</pass>
</technique>

View file

@ -0,0 +1,130 @@
// -*- 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 vertVec;
varying vec3 reflVec;
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;
uniform int rembrandt_enabled;
uniform int color_is_position;
//////Fog Include///////////
// uniform int fogType;
// void fog_Func(int type);
////////////////////////////
void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float cosRy, out mat4 rotmat)
{
rotmat = mat4( cosRy , sinRx * sinRy , cosRx * sinRy, 0.0,
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,
sinRz, cosRz, 0.0, 0.0,
0.0 , 0.0 , 1.0, 0.0,
0.0 , 0.0 , 0.0, 1.0 );
}
void main(void)
{
float sr = sin(6.28 * gl_Color.a);
float cr = cos(6.28 * gl_Color.a);
rawpos = gl_Vertex.xyz;
// Rotation of the object and movement into position
rawpos.xy = vec2(dot(rawpos.xy, vec2(cr, sr)), dot(rawpos.xy, vec2(-sr, cr)));
rawpos = rawpos + gl_Color.xyz;
vec4 ecPosition = gl_ModelViewMatrix * vec4(rawpos.x, rawpos.y, rawpos.z, 1.0);
//fog_Func(fogType);
// Rotate the normal.
vec3 normal = gl_Normal;
normal.xy = vec2(dot(normal.xy, vec2(cr, sr)), dot(normal.xy, vec2(-sr, cr)));
//normal = gl_NormalMatrix * normal;
VNormal = normalize(gl_NormalMatrix * normal);
vec3 n = normalize(normal);
vec3 tempTangent = cross(n, vec3(1.0,0.0,0.0));
vec3 tempBinormal = cross(n, tempTangent);
if (nmap_enabled > 0){
tempTangent = tangent;
tempBinormal = binormal;
}
VTangent = normalize(gl_NormalMatrix * tempTangent);
VBinormal = normalize(gl_NormalMatrix * tempBinormal);
vec3 t = tempTangent;
vec3 b = tempBinormal;
// 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 = 1.0;
// Vertex in eye coordinates
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);
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;
}
if(rembrandt_enabled < 1){
gl_FrontColor = gl_FrontMaterial.emission + vec4(1.0,1.0,1.0,1.0)
* (gl_LightModel.ambient + gl_LightSource[0].ambient);
} else {
gl_FrontColor = vec4(1.0,1.0,1.0,1.0);
}
gl_Position = gl_ModelViewProjectionMatrix * vec4(rawpos,1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}

View file

@ -7,13 +7,15 @@
// by Thorsten Renk, 2013
#version 120
varying vec4 diffuseColor;
varying vec3 VBinormal;
varying vec3 VNormal;
varying vec3 VTangent;
varying vec3 rawpos;
varying vec3 eyeVec;
varying vec3 eyeDir;
varying vec3 reflVec;
varying vec3 vViewVec;
varying vec3 vertVec;
varying float alpha;
uniform sampler2D BaseTex;
uniform sampler2D LightMapTex;
@ -31,7 +33,6 @@ uniform int lightmap_multi;
uniform int nmap_dds;
uniform int nmap_enabled;
uniform int refl_enabled;
uniform int refl_dynamic;
uniform int refl_map;
uniform int grain_texture_enabled;
uniform int rain_enabled;
@ -89,47 +90,6 @@ uniform vec3 dirt_r_color;
uniform vec3 dirt_g_color;
uniform vec3 dirt_b_color;
///reflection orientation
uniform mat4 osg_ViewMatrixInverse;
uniform float latDeg;
uniform float lonDeg;
//////rotation matrices/////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
mat3 rotX(in float angle)
{
mat3 rotmat = mat3(
1.0, 0.0, 0.0,
0.0, cos(angle), -sin(angle),
0.0, sin(angle), cos(angle)
);
return rotmat;
}
mat3 rotY(in float angle)
{
mat3 rotmat = mat3(
cos(angle), 0.0, sin(angle),
0.0, 1.0, 0.0,
-sin(angle), 0.0, cos(angle)
);
return rotmat;
}
mat3 rotZ(in float angle)
{
mat3 rotmat = mat3(
cos(angle), -sin(angle), 0.0,
sin(angle), cos(angle), 0.0,
0.0, 0.0, 1.0
);
return rotmat;
}
////////////////////////////////////////////////////////////////////////////////
float DotNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
float shadow_func (in float x, in float y, in float noise, in float dist);
float fog_func (in float targ, in float altitude);
@ -183,13 +143,13 @@ void main (void)
//vec4 worldPos3D = (osg_ViewMatrixInverse * vec4 (0.0,0.0,0.0, 1.0));
//worldPos3D.a = 0.0;
//vec3 up = (osg_ViewMatrix * worldPos3D).xyz;
float dist = length(eyeVec);
float vertex_alt = max(100.0,dot(up, eyeVec) + alt);
float dist = length(vertVec);
float vertex_alt = max(100.0,dot(up, vertVec) + alt);
float vertex_scattering = ground_scattering + (1.0 - ground_scattering) * smoothstep(hazeLayerAltitude -100.0, hazeLayerAltitude + 100.0, vertex_alt);
vec3 lightHorizon = gl_LightSource[0].position.xyz - up * dot(up,gl_LightSource[0].position.xyz);
float yprime = -dot(eyeVec, lightHorizon);
float yprime = -dot(vertVec, lightHorizon);
float yprime_alt = yprime - sqrt(2.0 * EarthRadius * vertex_alt);
float lightArg = (terminator-yprime_alt)/100000.0;
@ -197,7 +157,7 @@ void main (void)
float mie_angle;
if (lightArg < 10.0)
{mie_angle = (0.5 * dot(normalize(eyeVec), normalize(gl_LightSource[0].position.xyz)) ) + 0.5;}
{mie_angle = (0.5 * dot(normalize(vertVec), normalize(gl_LightSource[0].position.xyz)) ) + 0.5;}
else
{mie_angle = 1.0;}
@ -220,7 +180,7 @@ void main (void)
float fog_lightArg = (terminator-fog_yprime_alt)/100000.0;
float fog_earthShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, fog_yprime_alt) + 0.1;
float ct = dot(normalize(up), normalize(eyeVec));
float ct = dot(normalize(up), normalize(vertVec));
/// END geometry for light
@ -277,57 +237,21 @@ void main (void)
} else {
N = normalize(VNormal);
}
///END bump ////////////////////////////////////////////////////////////////////
vec3 viewN = normalize((gl_ModelViewMatrixTranspose * vec4(N,0.0)).xyz);
vec3 viewVec = normalize(eyeVec);
float v = abs(dot(viewVec, viewN));// Map a rainbowish color
vec4 fresnel = texture2D(ReflGradientsTex, vec2(v, 0.75));
vec4 rainbow = texture2D(ReflGradientsTex, vec2(v, 0.25));
///END bump
vec4 reflection = textureCube(Environment, reflVec * dot(N,VNormal));
vec3 viewVec = normalize(vViewVec);
float v = abs(dot(viewVec, normalize(VNormal)));// Map a rainbowish color
vec4 fresnel = texture2D(ReflGradientsTex, vec2(v, 0.75));
vec4 rainbow = texture2D(ReflGradientsTex, vec2(v, 0.25));
mat4 reflMatrix = gl_ModelViewMatrixInverse;
vec3 wRefVec = reflect(viewVec,N);
////dynamic reflection /////////////////////////////
if (refl_dynamic > 0){
reflMatrix = osg_ViewMatrixInverse;
vec3 wVertVec = normalize(reflMatrix * vec4(viewVec,0.0)).xyz;
vec3 wNormal = normalize(reflMatrix * vec4(N,0.0)).xyz;
float latRad = radians(90. - latDeg);
float lonRad = radians(lonDeg);
mat3 rotCorrX = rotX(-lonRad);
mat3 rotCorrY = rotY(latRad);
mat3 reflCorr = rotCorrX * rotCorrY;
wRefVec = reflect(wVertVec,wNormal);
wRefVec = normalize(reflCorr * wRefVec);
} else { ///static reflection
wRefVec = normalize(reflMatrix * vec4(wRefVec,0.0)).xyz;
}
vec3 reflection = textureCube(Environment, wRefVec).xyz;
vec3 E = eyeDir;
E = normalize(E);
vec3 L = normalize((gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz);
vec3 HV = normalize(L + E);
N = viewN;
float nDotVP = dot(N,L);
float nDotHV = dot(N,HV);
float eDotLV = max(0.0, dot(-E,L));
//glare on the backside of tranparent objects
if ((gl_Color.a < .999 || texel.a < .999) && nDotVP < 0.0) {
nDotVP = dot(-N, L);
nDotHV = dot(-N, HV);
}
nDotVP = max(0.0, nDotVP);
nDotHV = max(0.0, nDotHV);
float nDotVP = max(0.0, dot(N, normalize(gl_LightSource[0].position.xyz)));
float nDotHV = max(0.0, dot(N, normalize(gl_LightSource[0].halfVector.xyz)));
//glare on the backside of tranparent objects
if ((gl_FrontMaterial.diffuse.a < 1.0 || texel.a < 1.0)
&& dot(N, normalize(gl_LightSource[0].position.xyz)) < 0.0) {
nDotVP = max(0.0, dot(-N, normalize(gl_LightSource[0].position.xyz)));
nDotHV = max(0.0, dot(-N, normalize(gl_LightSource[0].halfVector.xyz)));
}
float nDotVP1 = 0.0;
float nDotHV1 = 0.0;
@ -335,7 +259,7 @@ void main (void)
// try specular reflection of sky irradiance
nDotVP1 = max(0.0, dot(N, up));
nDotHV1 = max(0.0, dot(N, normalize(normalize(up) + normalize(-eyeVec))));
nDotHV1 = max(0.0, dot(N, normalize(normalize(up) + normalize(-vertVec))));
if (nDotVP == 0.0)
@ -349,7 +273,7 @@ void main (void)
{pf1 = pow(nDotHV1, 0.5*gl_FrontMaterial.shininess);}
vec3 relPos = (gl_ModelViewMatrixInverse * vec4 (eyeVec,0.0)).xyz;
vec3 relPos = (gl_ModelViewMatrixInverse * vec4 (vertVec,0.0)).xyz;
if (cloud_shadow_flag == 1)
{
light_diffuse = light_diffuse * shadow_func(relPos.x, relPos.y, 1.0, dist);
@ -374,11 +298,11 @@ void main (void)
vec4 Diffuse = light_diffuse * nDotVP;
Diffuse.rgb += secondary_light * light_distance_fading(dist);
vec4 Specular = gl_FrontMaterial.specular * light_diffuse * pf + gl_FrontMaterial.specular * light_ambient * pf1;
Specular+= gl_FrontMaterial.specular * pow(max(0.0,-dot(N,normalize(eyeVec))),gl_FrontMaterial.shininess) * vec4(secondary_light,1.0);
Specular+= gl_FrontMaterial.specular * pow(max(0.0,-dot(N,normalize(vertVec))),gl_FrontMaterial.shininess) * vec4(secondary_light,1.0);
vec4 color = gl_Color + Diffuse * diffuseColor;
vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse;
color = clamp( color, 0.0, 1.0 );
color.a = texel.a * diffuseColor.a;
////////////////////////////////////////////////////////////////////
//BEGIN reflect
////////////////////////////////////////////////////////////////////
@ -399,23 +323,20 @@ void main (void)
reflFactor = clamp(reflFactor, 0.0, 1.0);
// add fringing fresnel and rainbow effects and modulate by reflection
vec3 reflcolor = mix(reflection, rainbow.rgb, refl_rainbow * v);
vec4 reflcolor = mix(reflection, rainbow, refl_rainbow * v);
//vec4 reflcolor = reflection;
vec3 reflfrescolor = mix(reflcolor, fresnel.rgb, refl_fresnel * v);
vec3 noisecolor = mix(reflfrescolor, noisevec.rgb, refl_noise);
vec3 raincolor = noisecolor.rgb * reflFactor;
raincolor += Specular.rgb;
raincolor *= light_diffuse.rgb;
mixedcolor = mix(texel.rgb, raincolor, reflFactor);
vec4 reflfrescolor = mix(reflcolor, fresnel, refl_fresnel * v);
vec4 noisecolor = mix(reflfrescolor, noisevec, refl_noise);
vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0);
raincolor += Specular;
raincolor *= light_diffuse;
mixedcolor = mix(texel, raincolor, reflFactor).rgb;
} else {
mixedcolor = texel.rgb;
}
/////////////////////////////////////////////////////////////////////
//END reflect
/////////////////////////////////////////////////////////////////////
if (color.a < .999){
color.a += .1 * eDotLV;
}
//////////////////////////////////////////////////////////////////////
//begin DIRT
@ -423,21 +344,15 @@ void main (void)
if (dirt_enabled >= 1){
vec3 dirtFactorIn = vec3 (dirt_r_factor, dirt_g_factor, dirt_b_factor);
vec3 dirtFactor = reflmap.rgb * dirtFactorIn.rgb;
//dirtFactor.r = smoothstep(0.0, 1.0, dirtFactor.r);
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, smoothstep(0.0, 1.0, dirtFactor.r));
if (color.a < .999) {
color.a += dirtFactor.r * eDotLV;
}
if (dirt_multi > 0) {
//dirtFactor.g = smoothstep(0.0, 1.0, dirtFactor.g);
//dirtFactor.b = smoothstep(0.0, 1.0, dirtFactor.b);
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, smoothstep(0.0, 1.0, dirtFactor.g));
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, smoothstep(0.0, 1.0, dirtFactor.b));
if (color.a < 1.0) {
color.a += dirtFactor.g * eDotLV;
color.a += dirtFactor.b * eDotLV;
}
}
}
}
}
//////////////////////////////////////////////////////////////////////
//END Dirt
//////////////////////////////////////////////////////////////////////
@ -458,7 +373,7 @@ void main (void)
}
// secondary reflection of sky irradiance in water film
float fresnelW = ((0.8 * wetness) ) * (1.0-smoothstep(0.0,0.4, dot(N,-normalize(eyeVec)) * 1.0 - 0.2 * rain_factor * wetness));
float fresnelW = ((0.8 * wetness) ) * (1.0-smoothstep(0.0,0.4, dot(N,-normalize(vertVec)) * 1.0 - 0.2 * rain_factor * wetness));
float sky_factor = (1.0-ct*ct);
vec3 sky_light = vec3 (1.0,1.0,1.0) * length(light_diffuse.rgb) * (1.0-effective_scattering);
Specular.rgb += sky_factor * fresnelW * sky_light;
@ -472,10 +387,11 @@ void main (void)
float ambient_offset = clamp(amb_correction, -1.0, 1.0);
//vec4 ambient = gl_LightModel.ambient + gl_LightSource[0].ambient;
vec4 ambient = gl_LightModel.ambient + light_ambient;
vec3 ambient_Correction = vec3(ambient.rg, ambient.b * 0.6);
ambient_Correction *= ambient_offset ;
vec4 ambient_Correction = vec4(ambient.rg, ambient.b * 0.6, 1.0)
* ambient_offset ;
ambient_Correction = clamp(ambient_Correction, -1.0, 1.0);
color.a = texel.a * alpha;
vec4 fragColor = vec4(color.rgb * mixedcolor + ambient_Correction.rgb, color.a);
fragColor += Specular * nmap.a;
@ -486,18 +402,18 @@ void main (void)
if ( lightmap_enabled >= 1 ) {
vec3 lightmapcolor = vec3(0.0);
vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor,
lightmap_b_factor, lightmap_a_factor);
lightmap_b_factor, lightmap_a_factor);
lightmapFactor = lightmapFactor * lightmapTexel;
if (lightmap_multi > 0 ){
lightmapcolor = lightmap_r_color * lightmapFactor.r +
lightmap_g_color * lightmapFactor.g +
lightmap_b_color * lightmapFactor.b +
lightmap_a_color * lightmapFactor.a ;
} else {
lightmap_g_color * lightmapFactor.g +
lightmap_b_color * lightmapFactor.b +
lightmap_a_color * lightmapFactor.a ;
} else {
lightmapcolor = lightmapTexel.rgb * lightmap_r_color * lightmapFactor.r;
}
}
fragColor.rgb = max(fragColor.rgb, lightmapcolor * gl_FrontMaterial.diffuse.rgb * smoothstep(0.0, 1.0, mixedcolor*.5 + lightmapcolor*.5));
}
}
//////////////////////////////////////////////////////////////////////
// END lightmap
/////////////////////////////////////////////////////////////////////
@ -621,10 +537,10 @@ void main (void)
///BEGIN Rayleigh fog ///
// Rayleigh color shift due to out-scattering
float rayleigh_length = 0.5 * avisibility * (2.5 - 1.9 * air_pollution)/alt_factor(eye_alt, eye_alt+relPos.z);
float outscatter = 1.0-exp(-dist/rayleigh_length);
fragColor.rgb = rayleigh_out_shift(fragColor.rgb,outscatter);
// Rayleigh color shift due to out-scattering
float rayleigh_length = 0.5 * avisibility * (2.5 - 1.9 * air_pollution)/alt_factor(eye_alt, eye_alt+relPos.z);
float outscatter = 1.0-exp(-dist/rayleigh_length);
fragColor.rgb = rayleigh_out_shift(fragColor.rgb,outscatter);
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
@ -640,6 +556,6 @@ void main (void)
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);
gl_FragColor = fragColor;
}
}

View file

@ -0,0 +1,118 @@
// -*- 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;
varying vec3 vertVec;
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;
uniform int rembrandt_enabled;
//////Fog Include///////////
// uniform int fogType;
// void fog_Func(int type);
////////////////////////////
void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float cosRy, out mat4 rotmat)
{
rotmat = mat4( cosRy , sinRx * sinRy , cosRx * sinRy, 0.0,
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,
sinRz, cosRz, 0.0, 0.0,
0.0 , 0.0 , 1.0, 0.0,
0.0 , 0.0 , 0.0, 1.0 );
}
void main(void)
{
rawpos = gl_Vertex.xyz;
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
//fog_Func(fogType);
VNormal = normalize(gl_NormalMatrix * gl_Normal);
vec3 n = normalize(gl_Normal);
vec3 tempTangent = cross(n, vec3(1.0,0.0,0.0));
vec3 tempBinormal = cross(n, tempTangent);
if (nmap_enabled > 0){
tempTangent = tangent;
tempBinormal = binormal;
}
VTangent = normalize(gl_NormalMatrix * tempTangent);
VBinormal = normalize(gl_NormalMatrix * tempBinormal);
vec3 t = tempTangent;
vec3 b = tempBinormal;
// 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
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);
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;
}
if(rembrandt_enabled < 1){
gl_FrontColor = gl_FrontMaterial.emission + gl_Color
* (gl_LightModel.ambient + gl_LightSource[0].ambient);
} else {
gl_FrontColor = gl_Color;
}
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}