Offset for side/top texture

This commit is contained in:
Joshua Barretto 2022-05-09 15:53:24 +01:00
parent 3693a439ac
commit c3f30b2188
3 changed files with 10 additions and 5 deletions

View File

@ -324,7 +324,7 @@ vec3 lod_norm(vec2 f_pos/*vec3 pos*/) {
norm.xy += vec2(
textureLod(sampler2D(t_noise, s_noise), wpos / 100, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 100 + 0.5, 0).x - 0.5
) * 0.15 / pow(norm.z + 0.1, 3);
) * 0.25 / pow(norm.z + 0.1, 3);
norm = normalize(norm);
#endif
@ -373,6 +373,7 @@ vec3 lod_col(vec2 pos) {
vec3 col = textureBicubic(t_map, s_map, pos_to_tex(pos)).rgb;
/*
#ifdef EXPERIMENTAL_PROCEDURALLODDETAIL
col *= pow(vec3(
textureLod(sampler2D(t_noise, s_noise), wpos / 40, 0).x - 0.5,
@ -380,6 +381,7 @@ vec3 lod_col(vec2 pos) {
textureLod(sampler2D(t_noise, s_noise), wpos / 45 + 0.75, 0).x - 0.5
) + 1.0, vec3(0.5));
#endif
*/
return col;
}

View File

@ -21,7 +21,8 @@
layout(location = 0) in vec3 f_pos;
layout(location = 1) in vec3 f_norm;
layout(location = 2) in vec4 f_col;
layout(location = 3) in float snow_cover;
layout(location = 3) in vec3 model_pos;
layout(location = 4) in float snow_cover;
layout(location = 0) out vec4 tgt_color;
@ -75,7 +76,7 @@ void main() {
float my_alt = f_pos.z + focus_off.z;
float f_ao = 1.0;
const float VOXELIZE_DIST = 2000;
float voxelize_factor = clamp(1.0 - (distance(focus_pos.xy, f_pos.xy) - view_distance.x) / VOXELIZE_DIST, 0, 1.0);
float voxelize_factor = clamp(1.0 - (distance(focus_pos.xy, f_pos.xy) - view_distance.x) / VOXELIZE_DIST, 0, 0.65);
vec3 cam_dir = normalize(cam_pos.xyz - f_pos.xyz);
vec3 side_norm = normalize(vec3(my_norm.xy, 0));
vec3 top_norm = vec3(0, 0, 1);
@ -126,7 +127,7 @@ void main() {
vec3 side_color = mix(surf_color, vec3(1), snow_cover);
vec3 top_color = mix(surf_color, surf_color * 0.3, 0.5 + snow_cover * 0.5);
surf_color = mix(side_color, top_color, 1.0 - pow(fract((f_pos.z + focus_off.z) * 0.1), 2.0));
surf_color = mix(side_color, top_color, 1.0 - pow(fract(model_pos.z * 0.1), 2.0));
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light);

View File

@ -28,11 +28,13 @@ const uint FLAG_SNOW_COVERED = 1;
layout(location = 0) out vec3 f_pos;
layout(location = 1) out vec3 f_norm;
layout(location = 2) out vec4 f_col;
layout(location = 3) out float snow_cover;
layout(location = 3) out vec3 model_pos;
layout(location = 4) out float snow_cover;
void main() {
vec3 tree_pos = inst_pos - focus_off.xyz;
f_pos = tree_pos + v_pos;
model_pos = v_pos;
float pull_down = 1.0 / pow(distance(focus_pos.xy, tree_pos.xy) / (view_distance.x * 0.95), 150.0);
f_pos.z -= pull_down;