Added figure noise

This commit is contained in:
Joshua Barretto 2022-10-22 15:01:23 +01:00
parent 5c4090f099
commit a7c24ed518
4 changed files with 32 additions and 10 deletions

View File

@ -163,12 +163,15 @@ void main() {
color.rgb = mix(color.rgb, new_col, merge);
cloud_blend = 1;
is_reflection = true;
} else {
cloud_blend = 1;
}
} else {
#else
{
#endif
dist = DIST_CAP;
cloud_blend = 1;
//dist = DIST_CAP;
}
}
/* color.rgb = vec3(sin(depth_at(uv) * 3.14159 * 2) * 0.5 + 0.5); */

View File

@ -32,6 +32,8 @@ layout(location = 0) in vec3 f_pos;
// flat in uint f_pos_norm;
layout(location = 1) flat in vec3 f_norm;
/*centroid */layout(location = 2) in vec2 f_uv_pos;
layout(location = 3) in vec3 m_pos;
layout(location = 4) in float scale;
// in float f_alt;
// in vec4 f_shadow;
// in vec3 light_pos[2];
@ -161,7 +163,21 @@ void main() {
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos);
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/);
vec3 surf_color = /*srgb_to_linear*/f_col;
vec3 surf_color;
// If the figure is large enough to be 'terrain-like', we apply a noise effect to it
if (scale >= 0.5) {
float noise = hash(vec4(floor(m_pos * 3.0 - f_norm * 0.5), 0));
const float A = 0.055;
const float W_INV = 1 / (1 + A);
const float W_2 = W_INV * W_INV;
const float NOISE_FACTOR = 0.015;
vec3 noise_delta = (sqrt(f_col) * W_INV + noise * NOISE_FACTOR);
surf_color = noise_delta * noise_delta * W_2;
} else {
surf_color = f_col;
}
float alpha = 1.0;
const float n2 = 1.5;

View File

@ -70,6 +70,8 @@ layout(location = 0) out vec3 f_pos;
layout(location = 1) flat out vec3 f_norm;
// float dummy;
/*centroid */layout(location = 2) out vec2 f_uv_pos;
layout(location = 3) out vec3 m_pos;
layout(location = 4) out float scale;
// out vec3 f_col;
// out float f_ao;
// out float f_alt;
@ -90,6 +92,9 @@ void main() {
// vec4 bone_pos = bones[bone_idx].bone_mat * vec4(pos, 1);
m_pos = pos;
scale = length(bones[bone_idx].bone_mat[0]);
f_pos = (
bones[bone_idx].bone_mat *
vec4(pos, 1.0)

View File

@ -649,8 +649,8 @@ void main() {
// f_col = f_col + (hash(vec4(floor(vec3(focus_pos.xy + splay(v_pos_orig), f_pos.z)) * 3.0 - round(f_norm) * 0.5, 0)) - 0.5) * 0.05; // Small-scale noise
vec3 surf_color;
float surf_alpha = 1.0;
#if (FLUID_MODE >= FLUID_MODE_MEDIUM)
if (length(f_col_raw - vec3(0.02, 0.06, 0.22)) < 0.025 && dot(vec3(0, 0, 1), f_norm) > 0.9) {
if (length(f_col_raw - vec3(0.02, 0.06, 0.22)) < 0.025 && dot(vec3(0, 0, 1), f_norm) > 0.9) {
#if (FLUID_MODE >= FLUID_MODE_MEDIUM)
vec3 water_color = (1.0 - MU_WATER) * MU_SCATTER;
vec3 reflect_ray = cam_to_frag * vec3(1, 1, -1);
@ -672,13 +672,11 @@ void main() {
const vec3 underwater_col = vec3(0.0);
float min_refl = min(emitted_light.r, min(emitted_light.g, emitted_light.b));
surf_color = mix(underwater_col, surf_color, (1.0 - passthrough) * 1.0 / (1.0 + min_refl));
surf_alpha = 0.99;
} else {
surf_color = illuminate(max_light, view_dir, f_col * emitted_light, f_col * reflected_light);
}
#else
#endif
surf_alpha = 0.99;
} else {
surf_color = illuminate(max_light, view_dir, f_col * emitted_light, f_col * reflected_light);
#endif
}
// float mist_factor = max(1 - (f_pos.z + (texture(t_noise, f_pos.xy * 0.0005 + time_of_day.x * 0.0003).x - 0.5) * 128.0) / 400.0, 0.0);
// //float mist_factor = f_norm.z * 2.0;