mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Trying LOD noise.
This commit is contained in:
parent
682a3d74c8
commit
4c6da3ed16
@ -234,11 +234,14 @@ vec3 lod_norm(vec2 f_pos/*vec3 pos*/) {
|
|||||||
|
|
||||||
vec3 lod_pos(vec2 pos, vec2 focus_pos) {
|
vec3 lod_pos(vec2 pos, vec2 focus_pos) {
|
||||||
// Remove spiking by "pushing" vertices towards local optima
|
// Remove spiking by "pushing" vertices towards local optima
|
||||||
vec2 hpos = focus_pos + splay(pos);
|
vec2 delta = splay(pos);
|
||||||
|
vec2 hpos = focus_pos + delta;
|
||||||
vec2 nhpos = hpos;
|
vec2 nhpos = hpos;
|
||||||
|
// vec2 lod_shift = splay(abs(pos) - 1.0 / view_distance.y);
|
||||||
|
float shift = 15.0;// min(lod_shift.x, lod_shift.y) * 0.5;
|
||||||
for (int i = 0; i < 3; i ++) {
|
for (int i = 0; i < 3; i ++) {
|
||||||
// vec4 square = focus_pos.xy + vec4(splay(pos - vec2(1.0, 1.0), splay(pos + vec2(1.0, 1.0))));
|
// vec4 square = focus_pos.xy + vec4(splay(pos - vec2(1.0, 1.0), splay(pos + vec2(1.0, 1.0))));
|
||||||
nhpos -= lod_norm(hpos).xy * 15.0;
|
nhpos -= lod_norm(hpos).xy * shift;
|
||||||
}
|
}
|
||||||
hpos = hpos + normalize(nhpos - hpos + 0.001) * min(length(nhpos - hpos), 32);
|
hpos = hpos + normalize(nhpos - hpos + 0.001) * min(length(nhpos - hpos), 32);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ const float PI = 3.141592;
|
|||||||
const vec3 SKY_DAY_TOP = vec3(0.1, 0.5, 0.9);
|
const vec3 SKY_DAY_TOP = vec3(0.1, 0.5, 0.9);
|
||||||
const vec3 SKY_DAY_MID = vec3(0.02, 0.28, 0.8);
|
const vec3 SKY_DAY_MID = vec3(0.02, 0.28, 0.8);
|
||||||
const vec3 SKY_DAY_BOT = vec3(0.1, 0.2, 0.3);
|
const vec3 SKY_DAY_BOT = vec3(0.1, 0.2, 0.3);
|
||||||
const vec3 DAY_LIGHT = vec3(1.2, 1.0, 1.0) * 6.0;
|
const vec3 DAY_LIGHT = vec3(1.2, 1.0, 1.0);
|
||||||
const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0);
|
const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0);
|
||||||
|
|
||||||
const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20);
|
const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20);
|
||||||
@ -123,12 +123,13 @@ void get_sun_diffuse(vec3 norm, float time_of_day, vec3 dir, vec3 k_a, vec3 k_d,
|
|||||||
// Returns computed maximum intensity.
|
// Returns computed maximum intensity.
|
||||||
float get_sun_diffuse2(vec3 norm, vec3 sun_dir, vec3 moon_dir, vec3 dir, vec3 k_a, vec3 k_d, vec3 k_s, float alpha, out vec3 emitted_light, out vec3 reflected_light) {
|
float get_sun_diffuse2(vec3 norm, vec3 sun_dir, vec3 moon_dir, vec3 dir, vec3 k_a, vec3 k_d, vec3 k_s, float alpha, out vec3 emitted_light, out vec3 reflected_light) {
|
||||||
const float SUN_AMBIANCE = 0.23 / 3.0;/* / 1.8*/;// 0.1 / 3.0;
|
const float SUN_AMBIANCE = 0.23 / 3.0;/* / 1.8*/;// 0.1 / 3.0;
|
||||||
|
const float SUN_COLOR_FACTOR = 6.0;
|
||||||
const float MOON_AMBIANCE = 0.23;//0.1;
|
const float MOON_AMBIANCE = 0.23;//0.1;
|
||||||
|
|
||||||
float sun_light = get_sun_brightness(sun_dir);
|
float sun_light = get_sun_brightness(sun_dir);
|
||||||
float moon_light = get_moon_brightness(moon_dir);
|
float moon_light = get_moon_brightness(moon_dir);
|
||||||
|
|
||||||
vec3 sun_color = get_sun_color(sun_dir);
|
vec3 sun_color = get_sun_color(sun_dir) * SUN_COLOR_FACTOR;
|
||||||
vec3 moon_color = get_moon_color(moon_dir);
|
vec3 moon_color = get_moon_color(moon_dir);
|
||||||
|
|
||||||
vec3 sun_chroma = sun_color * sun_light;
|
vec3 sun_chroma = sun_color * sun_light;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
in vec3 f_pos;
|
in vec3 f_pos;
|
||||||
in vec3 f_norm;
|
in vec3 f_norm;
|
||||||
|
in vec2 v_pos_orig;
|
||||||
// in vec4 f_shadow;
|
// in vec4 f_shadow;
|
||||||
// in vec4 f_square;
|
// in vec4 f_square;
|
||||||
|
|
||||||
@ -116,6 +117,7 @@ void main() {
|
|||||||
// vec3 light, diffuse_light, ambient_light;
|
// vec3 light, diffuse_light, ambient_light;
|
||||||
// get_sun_diffuse(f_norm, time_of_day.x, light, diffuse_light, ambient_light, 1.0);
|
// get_sun_diffuse(f_norm, time_of_day.x, light, diffuse_light, ambient_light, 1.0);
|
||||||
// vec3 surf_color = illuminate(f_col, light, diffuse_light, ambient_light);
|
// vec3 surf_color = illuminate(f_col, light, diffuse_light, ambient_light);
|
||||||
|
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.05; // Small-scale noise
|
||||||
vec3 surf_color = /*illuminate(emitted_light, reflected_light)*/illuminate(f_col * emitted_light, f_col * reflected_light);
|
vec3 surf_color = /*illuminate(emitted_light, reflected_light)*/illuminate(f_col * emitted_light, f_col * reflected_light);
|
||||||
|
|
||||||
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||||
|
@ -13,6 +13,7 @@ uniform u_locals {
|
|||||||
|
|
||||||
out vec3 f_pos;
|
out vec3 f_pos;
|
||||||
out vec3 f_norm;
|
out vec3 f_norm;
|
||||||
|
out vec2 v_pos_orig;
|
||||||
// out vec4 f_square;
|
// out vec4 f_square;
|
||||||
// out vec4 f_shadow;
|
// out vec4 f_shadow;
|
||||||
// out float f_light;
|
// out float f_light;
|
||||||
@ -23,6 +24,7 @@ void main() {
|
|||||||
vec2 dims = vec2(1.0 / view_distance.y);
|
vec2 dims = vec2(1.0 / view_distance.y);
|
||||||
vec4 f_square = focus_pos.xyxy + vec4(splay(v_pos - dims), splay(v_pos + dims));
|
vec4 f_square = focus_pos.xyxy + vec4(splay(v_pos - dims), splay(v_pos + dims));
|
||||||
f_norm = lod_norm(f_pos.xy, f_square);
|
f_norm = lod_norm(f_pos.xy, f_square);
|
||||||
|
v_pos_orig = v_pos;
|
||||||
|
|
||||||
// f_pos = lod_pos(focus_pos.xy + splay(v_pos) * /*1000000.0*/(1 << 20), square);
|
// f_pos = lod_pos(focus_pos.xy + splay(v_pos) * /*1000000.0*/(1 << 20), square);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user