mirror of
https://port.numenaute.org/aleajactaest/khanat-client.git
synced 2024-11-09 16:59:03 +00:00
43 lines
No EOL
1.1 KiB
GLSL
43 lines
No EOL
1.1 KiB
GLSL
shader_type spatial;
|
|
render_mode unshaded, cull_disabled, blend_mix;
|
|
|
|
uniform float mist_level = 0.0;
|
|
uniform vec4 mist_color : hint_color = vec4( 1.0, 0.0, 1.0, 1.0 );
|
|
uniform float mist_height = 0.0;
|
|
uniform float mist_distance = 25.0;
|
|
|
|
varying mat4 CAMERA;
|
|
|
|
void vertex()
|
|
{
|
|
POSITION = vec4(VERTEX, 1.0);
|
|
CAMERA = CAMERA_MATRIX;
|
|
}
|
|
|
|
void fragment()
|
|
{
|
|
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).x;
|
|
vec3 ndc = vec3(SCREEN_UV, depth) * 2.0 - 1.0;
|
|
|
|
vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
|
view.xyz /= view.w;
|
|
float linear_depth = -view.z;
|
|
|
|
vec4 world = CAMERA * INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
|
vec3 world_position = world.xyz / world.w;
|
|
|
|
if ( linear_depth*mist_level <= mist_distance )
|
|
{
|
|
ALBEDO = vec3( 1.0, 0.0, 1.0 ) * mist_level;
|
|
ALPHA = (linear_depth*mist_level)/mist_distance;
|
|
}
|
|
else
|
|
{
|
|
ALBEDO = vec3( 1.0, 0.0, 1.0 );
|
|
ALPHA = 1.0;
|
|
}
|
|
// if ( world_position.y > 0.2 && world_position.y >= mist_height )
|
|
// {
|
|
// ALPHA *= mist_height/world_position.y;
|
|
// }
|
|
} |