2017-08-29 02:29:06 +00:00
|
|
|
!!permu FOG
|
|
|
|
!!samps reflectcube
|
2019-02-23 14:32:20 +00:00
|
|
|
!!cvardf r_skyfog=0.5
|
2019-07-19 02:13:19 +00:00
|
|
|
!!cvard4 r_glsl_skybox_orientation=0 0 0 0
|
2017-08-29 02:29:06 +00:00
|
|
|
#include "sys/defs.h"
|
|
|
|
#include "sys/fog.h"
|
|
|
|
|
|
|
|
//simple shader for simple skyboxes.
|
|
|
|
|
|
|
|
varying vec3 pos;
|
|
|
|
#ifdef VERTEX_SHADER
|
2019-07-19 02:13:19 +00:00
|
|
|
mat3 rotateAroundAxis(vec4 axis) //xyz axis, with angle in w
|
|
|
|
{
|
|
|
|
#define skyang axis.w*(3.14/180.0)*e_time
|
|
|
|
axis.xyz = normalize(axis.xyz);
|
|
|
|
float s = sin(skyang);
|
|
|
|
float c = cos(skyang);
|
|
|
|
float oc = 1.0 - c;
|
|
|
|
|
|
|
|
return mat3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s,
|
|
|
|
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s,
|
|
|
|
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c);
|
2019-07-21 05:00:29 +00:00
|
|
|
}
|
2017-08-29 02:29:06 +00:00
|
|
|
void main ()
|
|
|
|
{
|
|
|
|
pos = v_position.xyz - e_eyepos;
|
2019-07-19 02:13:19 +00:00
|
|
|
|
|
|
|
if (r_glsl_skybox_orientation.xyz != vec3(0.0))
|
|
|
|
pos = pos*rotateAroundAxis(r_glsl_skybox_orientation);
|
|
|
|
|
2017-08-29 02:29:06 +00:00
|
|
|
gl_Position = ftetransform();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef FRAGMENT_SHADER
|
|
|
|
void main ()
|
|
|
|
{
|
|
|
|
vec4 skybox = textureCube(s_reflectcube, pos);
|
2020-04-29 10:43:22 +00:00
|
|
|
|
|
|
|
//Fun question: should sky be fogged as if infinite, or as if an actual surface?
|
2020-05-16 13:12:58 +00:00
|
|
|
#ifdef FOG
|
|
|
|
#if 1
|
2020-07-21 07:58:54 +00:00
|
|
|
skybox.rgb = mix(skybox.rgb, w_fogcolour, float(r_skyfog)*w_fogalpha); //flat fog ignoring actual geometry
|
2020-05-16 13:12:58 +00:00
|
|
|
#else
|
|
|
|
skybox.rgb = mix(skybox.rgb, fog3(skybox.rgb), float(r_skyfog)); //fog in terms of actual geometry distance
|
|
|
|
#endif
|
2020-04-29 10:43:22 +00:00
|
|
|
#endif
|
|
|
|
gl_FragColor = skybox;
|
2017-08-29 02:29:06 +00:00
|
|
|
}
|
|
|
|
#endif
|