Procedural aircraft lights for ALS - WIP
This commit is contained in:
parent
4676d19237
commit
97cc53d7b3
5 changed files with 567 additions and 0 deletions
213
Effects/procedural-light.eff
Normal file
213
Effects/procedural-light.eff
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PropertyList>
|
||||||
|
<name>Effects/procedural-light</name>
|
||||||
|
|
||||||
|
<parameters>
|
||||||
|
<texture n="0">
|
||||||
|
<type>white</type>
|
||||||
|
</texture>
|
||||||
|
|
||||||
|
<light_color_base_r type="float">1.0</light_color_base_r>
|
||||||
|
<light_color_base_g type="float">0.0</light_color_base_g>
|
||||||
|
<light_color_base_b type="float">0.0</light_color_base_b>
|
||||||
|
<light_color_center_r type="float">1.0</light_color_center_r>
|
||||||
|
<light_color_center_g type="float">1.0</light_color_center_g>
|
||||||
|
<light_color_center_b type="float">1.0</light_color_center_b>
|
||||||
|
<intensity_scale type="float">1.0</intensity_scale>
|
||||||
|
<pointing_x type="float">-1.0</pointing_x>
|
||||||
|
<pointing_y type="float">0.0</pointing_y>
|
||||||
|
<pointing_z type="float">0.0</pointing_z>
|
||||||
|
<is_directional type="bool">false</is_directional>
|
||||||
|
<is_strobe type="bool">false</is_strobe>
|
||||||
|
<inner_angle type="float">0.2</inner_angle>
|
||||||
|
<outer_angle type="float">0.4</outer_angle>
|
||||||
|
<zero_angle type="float">0.7</zero_angle>
|
||||||
|
<outer_gain type="float">0.5</outer_gain>
|
||||||
|
<visibility><use>/environment/ground-visibility-m</use></visibility>
|
||||||
|
<avisibility><use>/environment/visibility-m</use></avisibility>
|
||||||
|
<lthickness><use>/environment/ground-haze-thickness-m</use></lthickness>
|
||||||
|
<terrain_alt><use>/environment/mean-terrain-elevation-m</use></terrain_alt>
|
||||||
|
<eye_alt><use>/sim/rendering/eye-altitude-m</use></eye_alt>
|
||||||
|
<terminator><use>/environment/terminator-relative-position-m</use></terminator>
|
||||||
|
</parameters>
|
||||||
|
|
||||||
|
<technique n="4">
|
||||||
|
<predicate>
|
||||||
|
<and>
|
||||||
|
<property>/sim/rendering/shaders/skydome</property>
|
||||||
|
<or>
|
||||||
|
<less-equal>
|
||||||
|
<value type="float">2.0</value>
|
||||||
|
<glversion/>
|
||||||
|
</less-equal>
|
||||||
|
<and>
|
||||||
|
<extension-supported>GL_ARB_shader_objects</extension-supported>
|
||||||
|
<extension-supported>GL_ARB_shading_language_100</extension-supported>
|
||||||
|
<extension-supported>GL_ARB_vertex_shader</extension-supported>
|
||||||
|
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||||
|
</and>
|
||||||
|
</or>
|
||||||
|
</and>
|
||||||
|
</predicate>
|
||||||
|
<pass>
|
||||||
|
<lighting>true</lighting>
|
||||||
|
<material>
|
||||||
|
<active><use>material/active</use></active>
|
||||||
|
<ambient><use>material/ambient</use></ambient>
|
||||||
|
<diffuse><use>material/diffuse</use></diffuse>
|
||||||
|
<specular><use>material/specular</use></specular>
|
||||||
|
<emissive><use>material/emissive</use></emissive>
|
||||||
|
<shininess><use>material/shininess</use></shininess>
|
||||||
|
<color-mode><use>material/color-mode</use></color-mode>
|
||||||
|
</material>
|
||||||
|
<blend>
|
||||||
|
<active><use>blend/active</use></active>
|
||||||
|
<source><use>blend/source</use></source>
|
||||||
|
<destination><use>blend/destination</use></destination>
|
||||||
|
</blend>
|
||||||
|
<shade-model><use>shade-model</use></shade-model>
|
||||||
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
|
<rendering-hint><use>rendering-hint</use></rendering-hint>
|
||||||
|
<render-bin>
|
||||||
|
<bin-number>111</bin-number>
|
||||||
|
<bin-name>DepthSortedBin</bin-name>
|
||||||
|
</render-bin>
|
||||||
|
<texture-unit>
|
||||||
|
<!-- The texture unit is always active because the shaders expect
|
||||||
|
that. -->
|
||||||
|
<unit>0</unit>
|
||||||
|
<active><use>texture[0]/active</use></active>
|
||||||
|
<type><use>texture[0]/type</use></type>
|
||||||
|
<image><use>texture[0]/image</use></image>
|
||||||
|
<filter><use>texture[0]/filter</use></filter>
|
||||||
|
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format> <use>texture[0]/internal-format</use> </internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<depth>
|
||||||
|
<write-mask>false</write-mask>
|
||||||
|
</depth>
|
||||||
|
<vertex-program-two-side>false</vertex-program-two-side>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/light-ALS.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/light-ALS.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/noise.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/hazes.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
|
||||||
|
|
||||||
|
<uniform>
|
||||||
|
<name>light_color_base_r</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>light_color_base_r</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>light_color_base_g</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>light_color_base_g</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>light_color_base_b</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>light_color_base_b</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>light_color_center_r</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>light_color_center_r</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>light_color_center_g</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>light_color_center_g</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>light_color_center_b</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>light_color_center_b</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>intensity_scale</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>intensity_scale</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>pointing_x</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>pointing_x</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>pointing_y</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>pointing_y</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>pointing_z</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>pointing_z</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>inner_angle</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>inner_angle</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>outer_angle</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>outer_angle</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>zero_angle</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>zero_angle</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>outer_gain</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>outer_gain</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>visibility</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>visibility</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>avisibility</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>avisibility</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>hazeLayerAltitude</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>lthickness</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>eye_alt</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>eye_alt</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>terminator</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>terminator</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>texture</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>is_directional</name>
|
||||||
|
<type>bool</type>
|
||||||
|
<value><use>is_directional</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>is_strobe</name>
|
||||||
|
<type>bool</type>
|
||||||
|
<value><use>is_strobe</use></value>
|
||||||
|
</uniform>
|
||||||
|
</pass>
|
||||||
|
</technique>
|
||||||
|
|
||||||
|
</PropertyList>
|
22
Models/Effects/procedural_light.ac
Normal file
22
Models/Effects/procedural_light.ac
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
AC3Db
|
||||||
|
MATERIAL "DefaultWhite" rgb 1.0000 1.0000 1.0000 amb 0.2000 0.2000 0.2000 emis 0.0000 0.0000 0.0000 spec 0.5000 0.5000 0.5000 shi 10 trans 0.0000
|
||||||
|
MATERIAL "DefaultWhite" rgb 1.0000 1.0000 1.0000 amb 0.2000 0.2000 0.2000 emis 0.0000 0.0000 0.0000 spec 0.0250 0.0250 0.0250 shi 50 trans 0.1000
|
||||||
|
OBJECT world
|
||||||
|
name "Blender_export__procedural_light.ac"
|
||||||
|
kids 1
|
||||||
|
OBJECT poly
|
||||||
|
name "procedural_light"
|
||||||
|
numvert 4
|
||||||
|
-0.0000019 -1.0000000 -1.0000000
|
||||||
|
-0.0000005 1.0000000 -1.0000000
|
||||||
|
0.0000005 -1.0000000 1.0000000
|
||||||
|
0.0000019 1.0000000 1.0000000
|
||||||
|
numsurf 1
|
||||||
|
SURF 0X20
|
||||||
|
mat 1
|
||||||
|
refs 4
|
||||||
|
1 0 0
|
||||||
|
0 0 0
|
||||||
|
2 0 0
|
||||||
|
3 0 0
|
||||||
|
kids 0
|
15
Models/Effects/procedural_light.xml
Normal file
15
Models/Effects/procedural_light.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<PropertyList>
|
||||||
|
|
||||||
|
<path>procedural_light.ac</path>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<effect>
|
||||||
|
<inherits-from>Effects/procedural-light</inherits-from>
|
||||||
|
<object-name>procedural_light</object-name>
|
||||||
|
</effect>
|
||||||
|
|
||||||
|
|
||||||
|
</PropertyList>
|
230
Shaders/light-ALS.frag
Normal file
230
Shaders/light-ALS.frag
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
// -*-C++-*-
|
||||||
|
|
||||||
|
uniform sampler2D texture;
|
||||||
|
|
||||||
|
uniform float light_color_base_r;
|
||||||
|
uniform float light_color_base_g;
|
||||||
|
uniform float light_color_base_b;
|
||||||
|
|
||||||
|
uniform float light_color_center_r;
|
||||||
|
uniform float light_color_center_g;
|
||||||
|
uniform float light_color_center_b;
|
||||||
|
|
||||||
|
uniform float intensity_scale;
|
||||||
|
|
||||||
|
uniform float pointing_x;
|
||||||
|
uniform float pointing_y;
|
||||||
|
uniform float pointing_z;
|
||||||
|
|
||||||
|
uniform float outer_angle;
|
||||||
|
uniform float inner_angle;
|
||||||
|
uniform float zero_angle;
|
||||||
|
uniform float outer_gain;
|
||||||
|
|
||||||
|
uniform float visibility;
|
||||||
|
uniform float avisibility;
|
||||||
|
uniform float hazeLayerAltitude;
|
||||||
|
uniform float eye_alt;
|
||||||
|
uniform float terminator;
|
||||||
|
|
||||||
|
uniform float osg_SimulationTime;
|
||||||
|
|
||||||
|
uniform bool is_directional;
|
||||||
|
uniform bool is_strobe;
|
||||||
|
|
||||||
|
varying vec3 vertex;
|
||||||
|
varying vec3 relPos;
|
||||||
|
varying vec3 normal;
|
||||||
|
|
||||||
|
float Noise2D(in vec2 coord, in float wavelength);
|
||||||
|
float fog_func (in float targ, in float alt);
|
||||||
|
|
||||||
|
float shape (in vec3 coord, in float noise, in float fade, in float transmission, in float glare, in float lightArg)
|
||||||
|
{
|
||||||
|
float r = length (coord) / max(fade, 0.2);
|
||||||
|
|
||||||
|
float angle = noise * 6.2832;
|
||||||
|
|
||||||
|
float sinphi = dot(vec2 (sin(angle),cos(angle)), normalize(coord.yz));
|
||||||
|
float sinterm = sin(mod((sinphi-3.0) * (sinphi-3.0),6.2832));
|
||||||
|
float ray = 0.0;
|
||||||
|
if (sinterm == 0.0)
|
||||||
|
{ray = 0.0;}
|
||||||
|
else
|
||||||
|
{ray = clamp(pow(sinterm,10.0),0.0,1.0);
|
||||||
|
ray *= exp(-40.0 * r * r) * smoothstep(0.8, 1.0,fade) * smoothstep(0.7, 1.0, glare);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float base = exp(-80.0*r*r );
|
||||||
|
float halo = 0.2 * exp(-10.0 * r * r) * (1.0 - smoothstep(-5.0, 0.0, lightArg));
|
||||||
|
float fogEffect = (1.0-smoothstep(0.4,0.8,transmission));
|
||||||
|
//fogEffect = 1.0;
|
||||||
|
|
||||||
|
//float offset = 0.0;
|
||||||
|
//offset *=0.3;
|
||||||
|
//vec2 offset_vec = vec2 (1.0, 0.0);
|
||||||
|
//offset_vec *= offset;
|
||||||
|
|
||||||
|
// vec2 coord_reduced1 = vec2(coord.y- 1.2* offset_vec.x, coord.z - 1.2 * offset_vec.y);
|
||||||
|
//vec2 coord_reduced2 = vec2(coord.y- 2.0 * offset_vec.x, coord.z - 2.0 * offset_vec.y);
|
||||||
|
//vec3 coord_reduced = coord;
|
||||||
|
//r = min(length (coord_reduced1), 0.8* length(coord_reduced2));
|
||||||
|
//r /= 1.0 - 0.3 * smoothstep(0.0, 0.3, offset);
|
||||||
|
|
||||||
|
float intensity = clamp(base + halo + ray,0.0,1.0) + 0.2 * fogEffect * (1.0-smoothstep(0.3, 0.6,r));
|
||||||
|
|
||||||
|
intensity *=fade;
|
||||||
|
|
||||||
|
return intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float directional_fade (in float direction)
|
||||||
|
{
|
||||||
|
|
||||||
|
float arg = clamp(direction, 0.0, 1.0);
|
||||||
|
float ia = (1.0 - inner_angle);
|
||||||
|
float oa = (1.0 - outer_angle);
|
||||||
|
float za = (1.0 - zero_angle);
|
||||||
|
|
||||||
|
if (direction > ia) {return 1.0;}
|
||||||
|
else if (direction > oa)
|
||||||
|
{return outer_gain + (1.0-outer_gain) * (direction - oa) / (ia - oa);}
|
||||||
|
else if (direction > za)
|
||||||
|
{return outer_gain * (direction - za) / (oa - za);}
|
||||||
|
else {return 0.0;}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
float strobe_fade (in float fade)
|
||||||
|
{
|
||||||
|
|
||||||
|
float time_arg1 = sin(4.0 * osg_SimulationTime);
|
||||||
|
float time_arg2 = sin(4.0 * osg_SimulationTime - 0.4);
|
||||||
|
|
||||||
|
return fade * 0.825 * (pow(time_arg1, 40.0) + pow(time_arg2, 8.0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
|
||||||
|
float noise = 0.0;
|
||||||
|
|
||||||
|
vec3 light_color_base = vec3 (light_color_base_r, light_color_base_g, light_color_base_b);
|
||||||
|
vec3 light_color_center = vec3 (light_color_center_r, light_color_center_g, light_color_center_b);
|
||||||
|
|
||||||
|
vec3 pointing_vec = vec3 (pointing_x, pointing_y, pointing_z);
|
||||||
|
vec3 viewDir = normalize(relPos);
|
||||||
|
|
||||||
|
// fogging
|
||||||
|
|
||||||
|
float dist = length(relPos);
|
||||||
|
float delta_z = hazeLayerAltitude - eye_alt;
|
||||||
|
float transmission;
|
||||||
|
float vAltitude;
|
||||||
|
float delta_zv;
|
||||||
|
float H;
|
||||||
|
float distance_in_layer;
|
||||||
|
float transmission_arg;
|
||||||
|
|
||||||
|
// angle with horizon
|
||||||
|
float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
|
||||||
|
|
||||||
|
|
||||||
|
if (delta_z > 0.0) // we're inside the layer
|
||||||
|
{
|
||||||
|
if (ct < 0.0) // we look down
|
||||||
|
{
|
||||||
|
distance_in_layer = dist;
|
||||||
|
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
|
||||||
|
delta_zv = delta_z - vAltitude;
|
||||||
|
}
|
||||||
|
else // we may look through upper layer edge
|
||||||
|
{
|
||||||
|
H = dist * ct;
|
||||||
|
if (H > delta_z) {distance_in_layer = dist/H * delta_z;}
|
||||||
|
else {distance_in_layer = dist;}
|
||||||
|
vAltitude = min(distance_in_layer,visibility) * ct;
|
||||||
|
delta_zv = delta_z - vAltitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // we see the layer from above, delta_z < 0.0
|
||||||
|
{
|
||||||
|
H = dist * -ct;
|
||||||
|
if (H < (-delta_z))
|
||||||
|
{
|
||||||
|
distance_in_layer = 0.0;
|
||||||
|
delta_zv = 0.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vAltitude = H + delta_z;
|
||||||
|
distance_in_layer = vAltitude/H * dist;
|
||||||
|
vAltitude = min(distance_in_layer,visibility) * (-ct);
|
||||||
|
delta_zv = vAltitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
transmission_arg = (dist-distance_in_layer)/avisibility;
|
||||||
|
if (visibility < avisibility)
|
||||||
|
{
|
||||||
|
transmission_arg = transmission_arg + (distance_in_layer/visibility);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transmission_arg = transmission_arg + (distance_in_layer/avisibility);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
transmission = fog_func(transmission_arg, 0.0);
|
||||||
|
float lightArg = terminator/100000.0;
|
||||||
|
|
||||||
|
|
||||||
|
float r = length(vertex);
|
||||||
|
float mix_factor = 0.3 + 0.7 * smoothstep(0.0, 0.5, r);
|
||||||
|
|
||||||
|
// directionality
|
||||||
|
|
||||||
|
vec3 nViewDir = normalize(viewDir);
|
||||||
|
vec3 nPointingVec = normalize(pointing_vec);
|
||||||
|
float direction = dot (nViewDir, nPointingVec );
|
||||||
|
|
||||||
|
float fade;
|
||||||
|
vec2 offset = vec2 (0.0, 0.0);
|
||||||
|
|
||||||
|
if (is_directional)
|
||||||
|
{
|
||||||
|
fade = directional_fade(direction);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{fade = 1.0;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// time evolution
|
||||||
|
|
||||||
|
if (is_strobe) {fade = strobe_fade (fade);}
|
||||||
|
|
||||||
|
fade *= intensity_scale;
|
||||||
|
|
||||||
|
// disc size correction for daylight
|
||||||
|
|
||||||
|
// shape of the light disc
|
||||||
|
float glare = length(light_color_center)/1.7321 * (1.0 - smoothstep(-5.0, 10.0, lightArg));
|
||||||
|
float intensity = shape(vertex, noise, fade, transmission, glare, lightArg);
|
||||||
|
|
||||||
|
// coloring of the light disc
|
||||||
|
vec3 light_color = mix(light_color_base, light_color_center, intensity*intensity);
|
||||||
|
|
||||||
|
|
||||||
|
gl_FragColor = vec4 (light_color.rgb, intensity * transmission );
|
||||||
|
|
||||||
|
|
||||||
|
}
|
87
Shaders/light-ALS.vert
Normal file
87
Shaders/light-ALS.vert
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
// -*-C++-*-
|
||||||
|
|
||||||
|
#version 120
|
||||||
|
|
||||||
|
// doing directionality is surprisingly complicated - with just the vector and the eye we can't
|
||||||
|
// do a spherical billboard, but the animation itself operates before the shader, so
|
||||||
|
// the model-coordinate to eye relationship is always the same
|
||||||
|
// thus we need to use pitch, yaw and roll to get the current model space coordinates
|
||||||
|
|
||||||
|
uniform float pitch;
|
||||||
|
uniform float roll;
|
||||||
|
uniform float hdg;
|
||||||
|
|
||||||
|
|
||||||
|
varying vec3 vertex;
|
||||||
|
varying vec3 relPos;
|
||||||
|
varying vec3 normal;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
|
||||||
|
vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
|
||||||
|
|
||||||
|
vec4 l = gl_ModelViewMatrixInverse * vec4(0.0,0.0,1.0,1.0);
|
||||||
|
vec3 u = normalize(ep.xyz - l.xyz);
|
||||||
|
|
||||||
|
vec3 absu = abs(u);
|
||||||
|
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
|
||||||
|
vec3 w = cross(u, r);
|
||||||
|
|
||||||
|
vertex = gl_Vertex.xyz;
|
||||||
|
relPos = vertex - ep.xyz;
|
||||||
|
normal = gl_NormalMatrix * gl_Normal;
|
||||||
|
|
||||||
|
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
gl_Position.xyz = gl_Vertex.x * u;
|
||||||
|
gl_Position.xyz += gl_Vertex.y * r;
|
||||||
|
gl_Position.xyz += gl_Vertex.z * w;
|
||||||
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
|
||||||
|
|
||||||
|
//gl_Position = ftransform();
|
||||||
|
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
||||||
|
|
||||||
|
gl_FrontColor = vec4 (1.0,1.0,1.0,1.0);
|
||||||
|
gl_BackColor = gl_FrontColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
|
//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 model_x = (RotMatH * RotMatPR * vec4 (1.0, 0.0, 0.0, 0.0)).xyz;
|
||||||
|
vec3 model_y = (RotMatH * RotMatPR * vec4 (0.0, 1.0, 0.0, 0.0)).xyz;
|
||||||
|
vec3 model_z = (RotMatH * RotMatPR * vec4 (0.0, 0.0, 1.0, 0.0)).xyz;
|
||||||
|
|
||||||
|
vec3 pointingVec = normalize(pointing_x * model_x + pointing_y * model_y + pointing_z * model_z);
|
||||||
|
pointing_angle = dot (viewDir, pointingVec);*/
|
Loading…
Reference in a new issue