better way to show glitter

This commit is contained in:
Isse 2023-11-02 15:19:23 +01:00
parent 664fe61b83
commit 7a8e363df1
2 changed files with 13 additions and 10 deletions

View File

@ -58,6 +58,9 @@
#define MAT_FIGURE 3
#define MAT_LOD 4
#define BLOCK_SNOW 0x21
#define BLOCK_ART_SNOW 0x22
// An arbitrary value that represents a very far distance (at least as far as the player should be able to see) without
// being too far that we end up with precision issues (used in clouds and elsewhere).
#define DIST_CAP 50000

View File

@ -54,9 +54,6 @@ uniform utexture2D t_kind;
layout(set = 2, binding = 3)
uniform sampler s_kind;
const uint SNOW = 0x21;
const uint ART_SNOW = 0x22;
layout (std140, set = 3, binding = 0)
uniform u_locals {
mat4 model_mat;
@ -542,16 +539,19 @@ void main() {
// vec3 col = /*srgb_to_linear*/(f_col + hash(vec4(floor(f_pos * 3.0 - f_norm * 0.5), 0)) * 0.01); // Small-scale noise
vec3 surf_color = illuminate(max_light, view_dir, col * emitted_light, col * reflected_light);
#ifdef EXPERIMENTAL_SNOWGLITTER
if (f_kind == SNOW || f_kind == ART_SNOW) {
if (f_kind == BLOCK_SNOW || f_kind == BLOCK_ART_SNOW) {
float cam_distance = distance(cam_pos.xyz, f_pos);
vec4 pos = vec4(f_pos + focus_off.xyz, 0.0);
vec3 pos = f_pos + focus_off.xyz;
vec4 dir = vec4(view_dir, 0.0);
float map = max(snoise(pos * 2.0 - dir * 3.0), 0.0);
float map = max(noise_3d(pos), 0.0);
float rand = hash(floor(pos * 30.0 + hash(pos * 2.0) + dir * 2.0));
float random = max(rand - 0.99, 0.0) * 100.0;
surf_color += pow(random, 10) * map * 10.0 / max(1.0, cam_distance * 0.1);
vec4 lpos = vec4(floor(pos * 35.0), 0.0);
vec3 n = normalize(vec3(hash(lpos + 128), hash(lpos - 435), hash(lpos + 982)));
float s = pow(abs(dot(n, view_dir)), 4.0);
surf_color += pow(map * s, 10.0) * 5.0 / max(1.0, cam_distance * 0.5);
}
#endif