Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -u -r a/Effects/hud.eff b/Effects/hud.eff
- --- a/Effects/hud.eff 2020-05-15 10:29:23.699964741 +0200
- +++ b/Effects/hud.eff 2020-05-15 10:31:49.192893138 +0200
- @@ -75,6 +75,22 @@
- <sample-res>0.0006</sample-res>
- <sample-far>2.5</sample-far>
- <hud-brightness>1.0</hud-brightness>
- + <!-- Parallax correction.
- + If enabled, the HUD texture is displayed straight in front of the view point,
- + and with a constant angular width. This simulates collimation.
- + In that case, the HUD object UV mapping is completely ignored. -->
- + <use-parallax type="bool">false</use-parallax>
- + <!-- Angular width/height of the HUD texture (when using parallax). -->
- + <hud-width-deg>25</hud-width-deg>
- + <hud-height-deg>25</hud-height-deg>
- + <!-- The optical axis is the direction from the viewpoint at which the texture
- + is centered when using parallax correction.
- + By default, it is the '-x' axis in the HUD object model space, which is forward
- + if no rotation offsets are applied to the HUD object.
- + Additional offsets to the optical axis can be given here. -->
- + <optical-offset-yaw>0</optical-offset-yaw>
- + <optical-offset-pitch>0</optical-offset-pitch>
- + <optical-offset-roll>0</optical-offset-roll>
- </parameters>
- <technique n="4">
- @@ -452,6 +468,36 @@
- <type>int</type>
- <value><use>material/color-mode-uniform</use></value>
- </uniform>
- + <uniform>
- + <name>use_parallax</name>
- + <type>bool</type>
- + <value><use>use-parallax</use></value>
- + </uniform>
- + <uniform>
- + <name>hud_width</name>
- + <type>float</type>
- + <value><use>hud-width-deg</use></value>
- + </uniform>
- + <uniform>
- + <name>hud_height</name>
- + <type>float</type>
- + <value><use>hud-height-deg</use></value>
- + </uniform>
- + <uniform>
- + <name>optical_yaw</name>
- + <type>float</type>
- + <value><use>optical-offset-yaw</use></value>
- + </uniform>
- + <uniform>
- + <name>optical_pitch</name>
- + <type>float</type>
- + <value><use>optical-offset-pitch</use></value>
- + </uniform>
- + <uniform>
- + <name>optical_roll</name>
- + <type>float</type>
- + <value><use>optical-offset-roll</use></value>
- + </uniform>
- </pass>
- </technique>
- diff -u -r a/Shaders/hud-ALS.frag b/Shaders/hud-ALS.frag
- --- a/Shaders/hud-ALS.frag 2020-05-15 10:29:31.814960102 +0200
- +++ b/Shaders/hud-ALS.frag 2020-05-15 10:30:04.372941491 +0200
- @@ -7,6 +7,7 @@
- varying vec3 normal;
- varying vec3 refl_vec;
- varying vec3 light_diffuse;
- +varying vec3 optical_relpos;
- varying float splash_angle;
- varying float Mie;
- varying float ambient_fraction;
- @@ -41,6 +42,11 @@
- uniform float sample_far;
- uniform float hud_brightness;
- +uniform bool use_parallax;
- +
- +uniform float hud_width;
- +uniform float hud_height;
- +
- uniform int use_reflection;
- uniform int use_reflection_lightmap;
- uniform int use_mask;
- @@ -69,23 +75,34 @@
- vec4 frost_texel;
- vec4 func_texel;
- +vec2 TexCoord;
- -texel = texture2D(texture, gl_TexCoord[0].st);
- -
- -texel+= texture2D(texture, vec2 (gl_TexCoord[0].s + sample_res, gl_TexCoord[0].t));
- -texel+= texture2D(texture, vec2 (gl_TexCoord[0].s - sample_res, gl_TexCoord[0].t));
- -texel+= texture2D(texture, vec2 (gl_TexCoord[0].s, gl_TexCoord[0].t + sample_res));
- -texel+= texture2D(texture, vec2 (gl_TexCoord[0].s, gl_TexCoord[0].t - sample_res));
- -
- -texel+= 0.75* texture2D(texture, vec2 (gl_TexCoord[0].s + sample_far * sample_res, gl_TexCoord[0].t+ sample_far * sample_res));
- -texel+= 0.75* texture2D(texture, vec2 (gl_TexCoord[0].s - sample_far * sample_res, gl_TexCoord[0].t+ sample_far * sample_res));
- -texel+= 0.75* texture2D(texture, vec2 (gl_TexCoord[0].s + sample_far * sample_res, gl_TexCoord[0].t- sample_far * sample_res));
- -texel+= 0.75* texture2D(texture, vec2 (gl_TexCoord[0].s - sample_far * sample_res, gl_TexCoord[0].t- sample_far * sample_res));
- -
- -texel+= 0.5 * texture2D(texture, vec2 (gl_TexCoord[0].s + 2.0 * sample_far * sample_res, gl_TexCoord[0].t - sample_res));
- -texel+= 0.5 * texture2D(texture, vec2 (gl_TexCoord[0].s - 2.0 * sample_far * sample_res, gl_TexCoord[0].t + sample_res));
- -texel+= 0.5 * texture2D(texture, vec2 (gl_TexCoord[0].s - sample_res, gl_TexCoord[0].t + 2.0 * sample_far * sample_res));
- -texel+= 0.5 * texture2D(texture, vec2 (gl_TexCoord[0].s + sample_res, gl_TexCoord[0].t - 2.0 * sample_far * sample_res));
- +if (use_parallax) {
- + vec2 relAngle = vec2(
- + atan(optical_relpos.y, -optical_relpos.x),
- + atan(optical_relpos.z, -optical_relpos.x)
- + );
- + TexCoord = (relAngle / vec2(radians(hud_width), radians(hud_height))) + 0.5;
- +} else {
- + TexCoord = gl_TexCoord[0].st;
- +}
- +
- +texel = texture2D(texture, TexCoord.st);
- +
- +texel+= texture2D(texture, vec2 (TexCoord.s + sample_res, TexCoord.t));
- +texel+= texture2D(texture, vec2 (TexCoord.s - sample_res, TexCoord.t));
- +texel+= texture2D(texture, vec2 (TexCoord.s, TexCoord.t + sample_res));
- +texel+= texture2D(texture, vec2 (TexCoord.s, TexCoord.t - sample_res));
- +
- +texel+= 0.75* texture2D(texture, vec2 (TexCoord.s + sample_far * sample_res, TexCoord.t+ sample_far * sample_res));
- +texel+= 0.75* texture2D(texture, vec2 (TexCoord.s - sample_far * sample_res, TexCoord.t+ sample_far * sample_res));
- +texel+= 0.75* texture2D(texture, vec2 (TexCoord.s + sample_far * sample_res, TexCoord.t- sample_far * sample_res));
- +texel+= 0.75* texture2D(texture, vec2 (TexCoord.s - sample_far * sample_res, TexCoord.t- sample_far * sample_res));
- +
- +texel+= 0.5 * texture2D(texture, vec2 (TexCoord.s + 2.0 * sample_far * sample_res, TexCoord.t - sample_res));
- +texel+= 0.5 * texture2D(texture, vec2 (TexCoord.s - 2.0 * sample_far * sample_res, TexCoord.t + sample_res));
- +texel+= 0.5 * texture2D(texture, vec2 (TexCoord.s - sample_res, TexCoord.t + 2.0 * sample_far * sample_res));
- +texel+= 0.5 * texture2D(texture, vec2 (TexCoord.s + sample_res, TexCoord.t - 2.0 * sample_far * sample_res));
- texel/=10.0;
- diff -u -r a/Shaders/hud-ALS.vert b/Shaders/hud-ALS.vert
- --- a/Shaders/hud-ALS.vert 2020-05-15 10:29:31.815960102 +0200
- +++ b/Shaders/hud-ALS.vert 2020-05-15 10:30:10.168938178 +0200
- @@ -7,6 +7,7 @@
- varying vec3 normal;
- varying vec3 light_diffuse;
- varying vec3 refl_vec;
- +varying vec3 optical_relpos;
- varying float splash_angle;
- varying float Mie;
- varying float ambient_fraction;
- @@ -19,9 +20,31 @@
- uniform float splash_y;
- uniform float splash_z;
- +uniform bool use_parallax;
- +uniform float optical_yaw;
- +uniform float optical_pitch;
- +uniform float optical_roll;
- +
- const float EarthRadius = 5800000.0;
- const float terminator_width = 200000.0;
- +
- +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 );
- +}
- +
- float light_func (in float x, in float a, in float b, in float c, in float d, in float e)
- {
- //x = x - 0.5;
- @@ -124,6 +147,21 @@
- ambient_fraction = length(light_ambient.rgb)/(length(light_diffuse.rgb +light_ambient.rgb ) + 0.01);
- +// Eye to vertex vector in the optical centerline coordinate system, for parallax correction.
- +if (use_parallax) {
- + mat4 RotMatPR;
- + mat4 RotMatH;
- + float cosRx = cos(radians(-optical_roll));
- + float sinRx = sin(radians(-optical_roll));
- + float cosRy = cos(radians(optical_pitch));
- + float sinRy = sin(radians(optical_pitch));
- + float cosRz = cos(radians(-optical_yaw));
- + float sinRz = sin(radians(-optical_yaw));
- + rotationMatrixPR(sinRx, cosRx, sinRy, cosRy, RotMatPR);
- + rotationMatrixH(sinRz, cosRz, RotMatH);
- + optical_relpos = (RotMatH * (RotMatPR * (gl_Vertex - ep))).xyz;
- +}
- +
- gl_Position = ftransform();
- gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
Add Comment
Please, Sign In to add comment