Merge branch 'zesterer/bare-minimum' into 'master'

Added BareMinimum shader effect

See merge request veloren/veloren!3188
This commit is contained in:
Joshua Barretto 2022-02-09 23:29:17 +00:00
commit b2d6b06e2e
16 changed files with 94 additions and 25 deletions

View File

@ -65,6 +65,11 @@ vec3 wpos_at(vec2 uv) {
void main() {
vec4 color = texture(sampler2D(t_src_color, s_src_color), uv);
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(color.rgb, 1);
return;
#endif
vec3 wpos = wpos_at(uv);
float dist = distance(wpos, cam_pos.xyz);
vec3 dir = (wpos - cam_pos.xyz) / dist;

View File

@ -95,6 +95,12 @@ void main() {
float f_ao, f_glow;
uint material = 0xFFu;
vec3 f_col = greedy_extract_col_light_attr(t_col_light, s_col_light, f_uv_pos, f_ao, f_glow, material);
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(simple_lighting(f_pos.xyz, f_col, f_ao), 1);
return;
#endif
// float /*f_light*/f_ao = textureProj(t_col_light, vec3(f_uv_pos, texSize)).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
// vec3 my_chunk_pos = (vec3((uvec3(f_pos_norm) >> uvec3(0, 9, 18)) & uvec3(0x1FFu)) - 256.0) / 2.0;

View File

@ -51,6 +51,11 @@ layout(location = 0) out vec4 tgt_color;
#include <lod.glsl>
void main() {
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(simple_lighting(f_pos.xyz, MU_SCATTER, 1.0), 0.5);
return;
#endif
// tgt_color = vec4(1.0 - MU_WATER, 1.0);
// return;
// First 3 normals are negative, next 3 are positive

View File

@ -89,6 +89,11 @@ float wave_height(vec3 pos) {
}
void main() {
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(simple_lighting(f_pos.xyz, MU_SCATTER, 1.0), 0.5);
return;
#endif
// First 3 normals are negative, next 3 are positive
vec3 normals[6] = vec3[](vec3(-1,0,0), vec3(1,0,0), vec3(0,-1,0), vec3(0,1,0), vec3(0,0,-1), vec3(0,0,1));

View File

@ -336,14 +336,17 @@ vec3 lod_pos(vec2 pos, vec2 focus_pos) {
// Remove spiking by "pushing" vertices towards local optima
vec2 delta = splay(pos);
vec2 hpos = focus_pos + delta;
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 ++) {
// 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 * shift;
}
hpos = hpos + normalize(nhpos - hpos + 0.001) * min(length(nhpos - hpos), 32);
#ifndef EXPERIMENTAL_BAREMINIMUM
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 ++) {
// 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 * shift;
}
hpos = hpos + normalize(nhpos - hpos + 0.001) * min(length(nhpos - hpos), 32);
#endif
return vec3(hpos, alt_at_real(hpos));
}

View File

@ -689,4 +689,10 @@ vec3 illuminate(float max_light, vec3 view_dir, /*vec3 max_light, */vec3 emitted
// return /*srgb_to_linear*/(/*0.5*//*0.125 * */vec3(pow(color.x, gamma), pow(color.y, gamma), pow(color.z, gamma)));
}
vec3 simple_lighting(vec3 pos, vec3 col, float shade) {
// Bad fake lantern so we can see in caves
vec3 d = pos.xyz - focus_pos.xyz;
return col * clamp(2.5 / dot(d, d), shade * (get_sun_brightness() + 0.01), 1);
}
#endif

View File

@ -46,6 +46,11 @@ void main() {
// vec4 vert_pos4 = view_mat * vec4(f_pos, 1.0);
// vec3 view_dir = normalize(-vec3(vert_pos4)/* / vert_pos4.w*/);
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(simple_lighting(f_pos.xyz, lod_col(f_pos.xy), 1.0), 1);
return;
#endif
float my_alt = /*f_pos.z;*/alt_at_real(f_pos.xy);
// vec3 f_pos = vec3(f_pos.xy, max(my_alt, f_pos.z));
/* gl_Position =

View File

@ -33,9 +33,11 @@ layout(location = 2) out float pull_down;
void main() {
// Find distances between vertices. Pull down a tiny bit more to reduce z fighting near the ocean.
f_pos = lod_pos(v_pos, focus_pos.xy) - vec3(0, 0, 0.1);
vec2 dims = vec2(1.0 / view_distance.y);
vec4 f_square = focus_pos.xyxy + vec4(splay(v_pos - dims), splay(v_pos + dims));
f_norm = lod_norm(f_pos.xy, f_square);
#ifndef EXPERIMENTAL_BAREMINIMUM
vec2 dims = vec2(1.0 / view_distance.y);
vec4 f_square = focus_pos.xyxy + vec4(splay(v_pos - dims), splay(v_pos + dims));
f_norm = lod_norm(f_pos.xy, f_square);
#endif
// v_pos_orig = v_pos;
// f_pos = lod_pos(focus_pos.xy + splay(v_pos) * /*1000000.0*/(1 << 20), square);

View File

@ -34,6 +34,11 @@ layout(location = 0) out vec4 tgt_color;
const float FADE_DIST = 32.0;
void main() {
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(simple_lighting(f_pos.xyz, f_col.rgb, 1.0), 1);
return;
#endif
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
vec3 view_dir = -cam_to_frag;

View File

@ -161,6 +161,11 @@ vec3 aa_sample(vec2 uv, vec2 off) {
#endif
void main() {
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(texture(sampler2D(t_src_color, s_src_color), uv).rgb, 1);
return;
#endif
/* if (medium.x == 1u) {
uv = clamp(uv + vec2(sin(uv.y * 16.0 + tick.x), sin(uv.x * 24.0 + tick.x)) * 0.005, 0, 1);
} */

View File

@ -25,8 +25,10 @@ layout(location = 0) in vec3 f_pos;
layout(location = 0) out vec4 tgt_color;
void main() {
// tgt_color = vec4(MU_SCATTER, 1.0);
// return;
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(get_sky_color(), 1);
return;
#endif
vec3 cam_dir = normalize(f_pos - cam_pos.xyz);

View File

@ -43,6 +43,11 @@ void main() {
float f_ao, f_glow;
vec3 f_col = greedy_extract_col_light_glow(t_col_light, s_col_light, f_uv_pos, f_ao, f_glow);
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(simple_lighting(f_pos.xyz, f_col, f_ao), 1);
return;
#endif
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
vec3 view_dir = -cam_to_frag;

View File

@ -82,21 +82,25 @@ void main() {
// Transform info world space
f_pos += chunk_offs;
// Terrain 'pop-in' effect
f_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
#ifndef EXPERIMENTAL_BAREMINIMUM
// Terrain 'pop-in' effect
f_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
#endif
#ifdef EXPERIMENTAL_CURVEDWORLD
f_pos.z -= pow(distance(f_pos.xy + focus_off.xy, focus_pos.xy + focus_off.xy) * 0.05, 2);
#endif
// Wind sway effect
f_pos += model_wind_sway * vec3(
sin(tick.x * 1.5 + f_pos.y * 0.1) * sin(tick.x * 0.35),
sin(tick.x * 1.5 + f_pos.x * 0.1) * sin(tick.x * 0.25),
0.0
// NOTE: could potentially replace `v_pos.z * model_z_scale` with a calculation using `inst_chunk_pos` from below
//) * pow(abs(v_pos.z * model_z_scale), 1.3) * SCALE_FACTOR;
) * v_pos.z * model_z_scale * SCALE_FACTOR;
#ifndef EXPERIMENTAL_BAREMINIMUM
// Wind sway effect
f_pos += model_wind_sway * vec3(
sin(tick.x * 1.5 + f_pos.y * 0.1) * sin(tick.x * 0.35),
sin(tick.x * 1.5 + f_pos.x * 0.1) * sin(tick.x * 0.25),
0.0
// NOTE: could potentially replace `v_pos.z * model_z_scale` with a calculation using `inst_chunk_pos` from below
//) * pow(abs(v_pos.z * model_z_scale), 1.3) * SCALE_FACTOR;
) * v_pos.z * model_z_scale * SCALE_FACTOR;
#endif
// Determine normal
// TODO: do changes here effect perf on vulkan

View File

@ -86,6 +86,12 @@ void main() {
// float f_light = textureProj(t_col_light, vec3(f_uv_pos + 0.5, textureSize(t_col_light, 0))).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
float f_light, f_glow;
vec3 f_col = greedy_extract_col_light_glow(t_col_light, s_col_light, f_uv_pos, f_light, f_glow);
#ifdef EXPERIMENTAL_BAREMINIMUM
tgt_color = vec4(simple_lighting(f_pos.xyz, f_col, f_light), 1);
return;
#endif
//float f_light = (uint(texture(t_col_light, (f_uv_pos + 0.5) / textureSize(t_col_light, 0)).r * 255.0) & 0x1Fu) / 31.0;
// vec2 texSize = textureSize(t_col_light, 0);
// float f_light = texture(t_col_light, f_uv_pos/* + vec2(atlas_offs.xy)*/).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;

View File

@ -80,8 +80,10 @@ void main() {
vec3 v_pos = f_pos;
// Terrain 'pop-in' effect
v_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
// f_pos.z -= min(32.0, 25.0 * pow(distance(focus_pos.xy, f_pos.xy) / view_distance.x, 20.0));
#ifndef EXPERIMENTAL_BAREMINIMUM
v_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
// f_pos.z -= min(32.0, 25.0 * pow(distance(focus_pos.xy, f_pos.xy) / view_distance.x, 20.0));
#endif
#ifdef EXPERIMENTAL_CURVEDWORLD
v_pos.z -= pow(distance(v_pos.xy + focus_off.xy, focus_pos.xy + focus_off.xy) * 0.05, 2);

View File

@ -453,4 +453,7 @@ pub enum ExperimentalShader {
NonSrgbDither,
/// Use triangle PDF noise for dithering instead of uniform noise.
TriangleNoiseDither,
/// Removes as many effects (including lighting) as possible in the name of
/// performance.
BareMinimum,
}