Experimental additional lighting options for ALS model shaders
This commit is contained in:
parent
c58d606723
commit
1e51bf00c0
8 changed files with 226 additions and 15 deletions
|
@ -43,6 +43,15 @@
|
|||
<landing_light1_offset><use>/sim/rendering/als-secondary-lights/landing-light1-offset-deg</use></landing_light1_offset>
|
||||
<landing_light2_offset><use>/sim/rendering/als-secondary-lights/landing-light2-offset-deg</use></landing_light2_offset>
|
||||
<landing_light3_offset><use>/sim/rendering/als-secondary-lights/landing-light3-offset-deg</use></landing_light3_offset>
|
||||
<use_geo_light type="int">0</use_geo_light>
|
||||
<geo_light_r type="float">0.0</geo_light_r>
|
||||
<geo_light_g type="float">0.0</geo_light_g>
|
||||
<geo_light_b type="float">0.0</geo_light_b>
|
||||
<geo_light_x type="float">0.0</geo_light_x>
|
||||
<geo_light_y type="float">0.0</geo_light_y>
|
||||
<geo_light_z type="float">0.0</geo_light_z>
|
||||
<geo_light_radius type="float">0.0</geo_light_radius>
|
||||
<geo_ambience type="float">0.0</geo_ambience>
|
||||
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
|
||||
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
|
||||
<!-- END fog include -->
|
||||
|
@ -242,6 +251,46 @@
|
|||
<type>float</type>
|
||||
<value><use>landing_light3_offset</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_r</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_r</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_g</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_g</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_b</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_b</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_x</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_y</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_z</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_z</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_radius</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_radius</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_ambience</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_ambience</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
<type>sampler-2d</type>
|
||||
|
@ -267,6 +316,11 @@
|
|||
<type>int</type>
|
||||
<value> <use>use_alt_landing_light</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>use_geo_light</name>
|
||||
<type>int</type>
|
||||
<value> <use>use_geo_light</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>display_xsize</name>
|
||||
<type>int</type>
|
||||
|
|
|
@ -4,12 +4,63 @@
|
|||
<name>Effects/space-combined</name>
|
||||
<inherits-from>Effects/model-combined</inherits-from>
|
||||
|
||||
<!--<parameters>
|
||||
<geo_light_r type="float">0.0</geo_light_r>
|
||||
<geo_light_g type="float">0.0</geo_light_g>
|
||||
<geo_light_b type="float">0.0</geo_light_b>
|
||||
<geo_light_x type="float">0.0</geo_light_x>
|
||||
<geo_light_y type="float">0.0</geo_light_y>
|
||||
<geo_light_z type="float">0.0</geo_light_z>
|
||||
<geo_light_radius type="float">0.0</geo_light_radius>
|
||||
<geo_ambience type="float">0.0</geo_ambience>
|
||||
</parameters> -->
|
||||
|
||||
<technique n="4">
|
||||
<pass>
|
||||
<program>
|
||||
<vertex-shader n="0">Shaders/space-ALS-ultra.vert</vertex-shader>
|
||||
<fragment-shader n="0">Shaders/space-ALS-ultra.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>geo_light_r</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_r</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_g</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_g</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_b</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_b</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_x</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_y</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_z</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_z</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_light_radius</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_light_radius</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>geo_ambience</name>
|
||||
<type>float</type>
|
||||
<value><use>geo_ambience</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<name>Effects/space</name>
|
||||
<inherits-from>Effects/model-default</inherits-from>
|
||||
|
||||
|
||||
<technique n="5">
|
||||
<pass>
|
||||
<program>
|
||||
|
|
70
Shaders/lightspot-ALS.frag
Normal file
70
Shaders/lightspot-ALS.frag
Normal file
|
@ -0,0 +1,70 @@
|
|||
// -*-C++-*-
|
||||
|
||||
uniform float eyerel_x1;
|
||||
uniform float eyerel_y1;
|
||||
uniform float eyerel_z1;
|
||||
uniform float lightspot_r1;
|
||||
uniform float lightspot_g1;
|
||||
uniform float lightspot_b1;
|
||||
uniform float eyerel_x2;
|
||||
uniform float eyerel_y2;
|
||||
uniform float eyerel_z2;
|
||||
uniform float lightspot_r2;
|
||||
uniform float lightspot_g2;
|
||||
uniform float lightspot_b2;
|
||||
uniform float eyerel_x3;
|
||||
uniform float eyerel_y3;
|
||||
uniform float eyerel_z3;
|
||||
uniform float lightspot_r3;
|
||||
uniform float lightspot_g3;
|
||||
uniform float lightspot_b3;
|
||||
uniform float eyerel_x4;
|
||||
uniform float eyerel_y4;
|
||||
uniform float eyerel_z4;
|
||||
uniform float lightspot_r4;
|
||||
uniform float lightspot_g4;
|
||||
uniform float lightspot_b4;
|
||||
uniform float eyerel_x5;
|
||||
uniform float eyerel_y5;
|
||||
uniform float eyerel_z5;
|
||||
uniform float lightspot_r5;
|
||||
uniform float lightspot_g5;
|
||||
uniform float lightspot_b5;
|
||||
uniform float lightspot_project1;
|
||||
uniform float lightspot_project2;
|
||||
uniform float lightspot_dir1;
|
||||
uniform float lightspot_dir2;
|
||||
uniform float lightspot_size1;
|
||||
uniform float lightspot_size2;
|
||||
uniform float lightspot_size3;
|
||||
uniform float lightspot_size4;
|
||||
uniform float lightspot_size5;
|
||||
|
||||
vec3 lightspot(vec3 relPos)
|
||||
{
|
||||
|
||||
|
||||
vec3 eye_rel = vec3 (eyerel_x1, eyerel_y1, eyerel_z1);
|
||||
vec3 difference_vec = relPos - eye_rel;
|
||||
|
||||
mat2 rotMat = mat2 (cos(lightspot_dir1), sin(lightspot_dir1), -sin(lightspot_dir1), cos(lightspot_dir1));
|
||||
|
||||
difference_vec.xy = rotMat * difference_vec.xy;
|
||||
difference_vec.x/= (1.0 + lightspot_project1);
|
||||
|
||||
|
||||
float lightspot_arg = (1.0 - smoothstep(5.0, 15.0, length(difference_vec))) * (1.0 - 0.5* smoothstep(5.0, 15.0/(1.0+lightspot_project1), difference_vec.x));
|
||||
|
||||
vec3 lightspot_color = vec3 (lightspot_r1,lightspot_g1, lightspot_b1 ) * lightspot_arg;
|
||||
|
||||
eye_rel = vec3 (eyerel_x2, eyerel_y2, eyerel_z2);
|
||||
lightspot_arg = (1.0 - smoothstep(0.0, 5.0, length(relPos - eye_rel)));
|
||||
lightspot_color += vec3 (lightspot_r2,lightspot_g2, lightspot_b2 ) * lightspot_arg;
|
||||
|
||||
eye_rel = vec3 (eyerel_x3, eyerel_y3, eyerel_z3);
|
||||
lightspot_arg = (1.0 - smoothstep(0.0, 5.0, length(relPos - eye_rel)));
|
||||
lightspot_color += vec3 (lightspot_r3,lightspot_g3, lightspot_b3 ) * lightspot_arg;
|
||||
|
||||
return lightspot_color;
|
||||
|
||||
}
|
|
@ -22,7 +22,6 @@ uniform float hdg;
|
|||
uniform int refl_dynamic;
|
||||
uniform int nmap_enabled;
|
||||
uniform int shader_qual;
|
||||
uniform int rembrandt_enabled;
|
||||
|
||||
//////Fog Include///////////
|
||||
// uniform int fogType;
|
||||
|
@ -107,12 +106,10 @@ void main(void)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -28,11 +28,22 @@ uniform float landing_light1_offset;
|
|||
uniform float landing_light2_offset;
|
||||
uniform float landing_light3_offset;
|
||||
|
||||
uniform float geo_light_x;
|
||||
uniform float geo_light_y;
|
||||
uniform float geo_light_z;
|
||||
uniform float geo_light_radius;
|
||||
uniform float geo_ambience;
|
||||
|
||||
uniform float geo_light_r;
|
||||
uniform float geo_light_g;
|
||||
uniform float geo_light_b;
|
||||
|
||||
uniform int quality_level;
|
||||
uniform int tquality_level;
|
||||
uniform int use_searchlight;
|
||||
uniform int use_landing_light;
|
||||
uniform int use_alt_landing_light;
|
||||
uniform int use_geo_light;
|
||||
|
||||
|
||||
const float EarthRadius = 5800000.0;
|
||||
|
@ -147,10 +158,27 @@ void main()
|
|||
{
|
||||
secondary_light += landing_light(landing_light2_offset, landing_light3_offset);
|
||||
}
|
||||
|
||||
vec3 geo_light = vec3 (0.0, 0.0, 0.0);
|
||||
|
||||
if (use_geo_light == 1)
|
||||
{
|
||||
vec3 geo_light_vec = vec3 (geo_light_x, geo_light_y, geo_light_z);
|
||||
vec3 geo_light_rel_vec = geo_light_vec - (relPos + (gl_ModelViewMatrixInverse * vec4 (0.0, 0.0, 0.0, 1.0)).xyz);
|
||||
|
||||
vec3 geo_lightdir = (gl_ModelViewMatrix * vec4 (geo_light_rel_vec, 0.0)).xyz;
|
||||
float geo_light_incidence = geo_ambience + (1.0- geo_ambience) * clamp(dot(n, geo_lightdir),0.0, 1.0);
|
||||
|
||||
geo_light = vec3 (geo_light_r, geo_light_g, geo_light_b) * (1.0 - smoothstep(0.5 * geo_light_radius, geo_light_radius, length(geo_light_rel_vec))) * geo_light_incidence;
|
||||
}
|
||||
|
||||
if (dist > 2.0) // we don't want to light the cockpit...
|
||||
{color.rgb +=secondary_light * light_distance_fading(dist);}
|
||||
{color.rgb +=secondary_light * light_distance_fading(dist) + geo_light ;}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
texel = texture2D(texture, gl_TexCoord[0].st);
|
||||
fragColor = color * texel + specular;
|
||||
|
||||
|
@ -324,8 +352,8 @@ fragColor.rgb = mix(hazeColor + secondary_light * fog_backscatter(mvisibility),
|
|||
|
||||
}
|
||||
|
||||
gl_FragColor = fragColor;
|
||||
|
||||
gl_FragColor = fragColor;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,12 @@ uniform float landing_light1_offset;
|
|||
uniform float landing_light2_offset;
|
||||
uniform float landing_light3_offset;
|
||||
|
||||
uniform float geo_light_x;
|
||||
uniform float geo_light_y;
|
||||
uniform float geo_light_z;
|
||||
uniform float geo_light_radius;
|
||||
uniform float geo_ambience;
|
||||
|
||||
// constants needed by the light and fog computations ###################################################
|
||||
|
||||
const float EarthRadius = 5800000.0;
|
||||
|
@ -89,6 +95,10 @@ uniform vec3 lightmap_g_color;
|
|||
uniform vec3 lightmap_b_color;
|
||||
uniform vec3 lightmap_a_color;
|
||||
|
||||
uniform float geo_light_r;
|
||||
uniform float geo_light_g;
|
||||
uniform float geo_light_b;
|
||||
|
||||
uniform vec3 dirt_r_color;
|
||||
uniform vec3 dirt_g_color;
|
||||
uniform vec3 dirt_b_color;
|
||||
|
@ -323,8 +333,15 @@ void main (void)
|
|||
}
|
||||
|
||||
|
||||
vec3 geo_light_vec = (gl_ModelViewMatrix * vec4 (geo_light_x, geo_light_y, geo_light_z, 0.0)).xyz;
|
||||
vec3 geo_light_rel_vec = geo_light_vec -(gl_ModelViewMatrix * vec4 (rawpos, 0.0)).xyz;
|
||||
|
||||
float geo_light_incidence = geo_ambience + (1.0- geo_ambience) * clamp(dot(N, geo_light_rel_vec),0.0, 1.0);
|
||||
|
||||
vec3 geo_light = vec3 (geo_light_r, geo_light_g, geo_light_b) * (1.0 - smoothstep(0.5 * geo_light_radius, geo_light_radius, length(geo_light_rel_vec))) * geo_light_incidence;
|
||||
|
||||
vec4 Diffuse = light_diffuse * nDotVP;
|
||||
Diffuse.rgb += secondary_light * light_distance_fading(dist);
|
||||
Diffuse.rgb += secondary_light * light_distance_fading(dist) + geo_light;
|
||||
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(vertVec))),gl_FrontMaterial.shininess) * vec4(secondary_light,1.0);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ uniform float hdg;
|
|||
uniform int refl_dynamic;
|
||||
uniform int nmap_enabled;
|
||||
uniform int shader_qual;
|
||||
uniform int rembrandt_enabled;
|
||||
|
||||
//////Fog Include///////////
|
||||
// uniform int fogType;
|
||||
|
@ -107,12 +106,6 @@ void main(void)
|
|||
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_FrontColor = gl_Color;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue