add clouds shader

This commit is contained in:
MihailRis 2026-02-12 18:19:25 +03:00
parent 28cd59ebde
commit 8153ddde89
8 changed files with 123 additions and 16 deletions

View file

@ -8,7 +8,8 @@
"translucent",
"background",
"skybox_gen",
"shadows"
"shadows",
"clouds"
],
"post-effects": [
"default",

View file

@ -1,4 +1,4 @@
{
"clouds": 0.8
"clouds": 1.0
}

View file

@ -2,5 +2,5 @@
"fog_opacity": 0.98,
"fog_dencity": 3.6,
"fog_curve": 0.25,
"clouds": 0.8
"clouds": 0.9
}

31
res/shaders/clouds.glslf Normal file
View file

@ -0,0 +1,31 @@
layout (location = 0) out vec4 f_color;
layout (location = 1) out vec4 f_position;
layout (location = 2) out vec4 f_normal;
layout (location = 3) out vec4 f_emission;
#include <world_fragment_header>
in vec4 a_torchLight;
uniform sampler2D u_texture0;
uniform vec3 u_sunDir;
// flags
uniform bool u_alphaClip;
uniform bool u_debugLights;
uniform bool u_debugNormals;
uniform vec4 u_tint;
void main() {
f_color.rgb = max(a_torchLight.rgb, a_skyLight);
f_color.a = 1.0;
f_color *= u_tint;
#ifndef ADVANCED_RENDER
vec3 fogColor = texture(u_skybox, a_dir).rgb;
f_color = mix(f_color, vec4(fogColor, 1.0), a_fog);
#endif
f_position = vec4(a_position, 1.0);
f_normal = vec4(a_normal, 1.0);
f_emission = vec4(vec3(a_emission), 1.0);
}

49
res/shaders/clouds.glslv Normal file
View file

@ -0,0 +1,49 @@
#include <commons>
layout (location = 0) in vec3 v_position;
layout (location = 1) in vec2 v_texCoord;
layout (location = 2) in vec4 v_light;
layout (location = 3) in vec4 v_normal;
#include <world_vertex_header>
#include <lighting>
#include <fog>
#include <sky>
uniform float u_dayTime;
out vec4 a_torchLight;
void main() {
a_modelpos = u_model * vec4(v_position, 1.0f);
a_modelpos.x += sin(u_timer * 0.05 + a_modelpos.z * 0.002) * 1.5;
a_modelpos.z += sin(u_timer * 0.2 + a_modelpos.x * 0.002) * 1.5;
a_modelpos.y += sin(u_timer * 0.1 + (a_modelpos.x + a_modelpos.z) * 0.001) * 2.0;
vec3 pos3d = a_modelpos.xyz - u_cameraPos;
a_realnormal = v_normal.xyz * 2.0 - 1.0;
a_normal = calc_screen_normal(a_realnormal);
a_torchLight = vec4(calc_torch_light(
v_light.rgb, a_realnormal, a_modelpos.xyz, u_torchlightColor, u_gamma
), 1.0);
a_texCoord = v_texCoord;
a_dir = a_modelpos.xyz - u_cameraPos;
vec3 skyLightColor = pick_sky_color(u_skybox, u_dayTime);
a_skyLight = skyLightColor.rgb*v_light.a;
mat4 viewmodel = u_view * u_model;
a_distance = length(viewmodel * vec4(pos3d, 0.0));
#ifndef ADVANCED_RENDER
a_fog = calc_fog(length(viewmodel * vec4(pos3d * FOG_POS_SCALE, 0.0)) / 256.0);
#endif
a_emission = v_normal.w;
vec4 viewmodelpos = u_view * a_modelpos;
a_position = viewmodelpos.xyz;
gl_Position = u_proj * viewmodelpos;
}