mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
parent
a00e7831ec
commit
8308598512
@ -117,12 +117,7 @@ void texcoords(vec2 fragCoord, vec2 resolution,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vec4 aa_apply(
|
vec4 aa_apply(texture2D tex, sampler smplr, vec2 fragCoord, vec2 resolution) {
|
||||||
texture2D tex, sampler smplr,
|
|
||||||
texture2D depth_tex, sampler depth_smplr,
|
|
||||||
vec2 fragCoord,
|
|
||||||
vec2 resolution
|
|
||||||
) {
|
|
||||||
mediump vec2 v_rgbNW;
|
mediump vec2 v_rgbNW;
|
||||||
mediump vec2 v_rgbNE;
|
mediump vec2 v_rgbNE;
|
||||||
mediump vec2 v_rgbSW;
|
mediump vec2 v_rgbSW;
|
||||||
@ -130,7 +125,7 @@ vec4 aa_apply(
|
|||||||
mediump vec2 v_rgbM;
|
mediump vec2 v_rgbM;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_BETTERAA
|
#ifdef EXPERIMENTAL_BETTERAA
|
||||||
float fxaa_scale = textureSize(sampler2D(tex, smplr), 0).x / 1000.0;
|
float fxaa_scale = textureSize(sampler2D(tex, smplr), 0).x / 900.0;
|
||||||
#else
|
#else
|
||||||
float fxaa_scale = FXAA_SCALE;
|
float fxaa_scale = FXAA_SCALE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
const float THRESHOLD = 0.025;
|
|
||||||
const float DEPTH_THRESHOLD = 0.05;
|
|
||||||
|
|
||||||
bool diag(
|
|
||||||
texture2D tex, sampler smplr,
|
|
||||||
texture2D depth_tex, sampler depth_smplr,
|
|
||||||
const float line_thickness,
|
|
||||||
inout vec4 sum,
|
|
||||||
vec2 uv,
|
|
||||||
const vec2 p1,
|
|
||||||
const vec2 p2,
|
|
||||||
const float aa_scale
|
|
||||||
) {
|
|
||||||
vec4 v1 = texelFetch(sampler2D(tex, smplr), ivec2(uv + vec2(p1.x, p1.y)), 0);
|
|
||||||
vec4 v2 = texelFetch(sampler2D(tex, smplr), ivec2(uv + vec2(p2.x, p2.y)), 0);
|
|
||||||
float d1 = 1.0 / texelFetch(sampler2D(depth_tex, depth_smplr), ivec2(uv + vec2(p1.x, p1.y)), 0).x;
|
|
||||||
float d2 = 1.0 / texelFetch(sampler2D(depth_tex, depth_smplr), ivec2(uv + vec2(p2.x, p2.y)), 0).x;
|
|
||||||
if (length((v1 - v2).rb) < THRESHOLD && abs(d1 - d2) < d1 * DEPTH_THRESHOLD + 3.0) {
|
|
||||||
vec2 dir = p2 - p1;
|
|
||||||
vec2 lp = uv - (floor(uv + p1) + 0.5);
|
|
||||||
dir = normalize(vec2(dir.y, -dir.x));
|
|
||||||
float l = clamp((line_thickness - dot(lp, dir)) * aa_scale, 0.0, 1.0);
|
|
||||||
sum = mix(sum, (v1 + v2) * 0.5, l);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 aa_apply(
|
|
||||||
texture2D tex, sampler smplr,
|
|
||||||
texture2D depth_tex, sampler depth_smplr,
|
|
||||||
vec2 fragCoord,
|
|
||||||
vec2 resolution
|
|
||||||
) {
|
|
||||||
uvec2 src_sz = textureSize(sampler2D(tex, smplr), 0).xy;
|
|
||||||
|
|
||||||
vec2 upscale = resolution / src_sz;
|
|
||||||
vec2 ip = fragCoord / upscale;
|
|
||||||
//start with nearest pixel as 'background'
|
|
||||||
vec4 s = texelFetch(sampler2D(tex, smplr), ivec2(ip), 0);
|
|
||||||
|
|
||||||
float aa_scale = upscale.x * 1.5;
|
|
||||||
|
|
||||||
//draw anti aliased diagonal lines of surrounding pixels as 'foreground'
|
|
||||||
if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(-1, 0), vec2(0, 1), aa_scale)) {
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, 0), vec2(1, 1), aa_scale);
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, -1), vec2(0, 1), aa_scale);
|
|
||||||
}
|
|
||||||
if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(0, 1), vec2(1, 0), aa_scale)) {
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(0, 1), vec2(1, -1), aa_scale);
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, 1), vec2(1, 0), aa_scale);
|
|
||||||
}
|
|
||||||
if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(1, 0), vec2(0, -1), aa_scale)) {
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, 0), vec2(-1, -1), aa_scale);
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, 1), vec2(0, -1), aa_scale);
|
|
||||||
}
|
|
||||||
if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(0, -1), vec2(-1, 0), aa_scale)) {
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(0, -1), vec2(-1, 1), aa_scale);
|
|
||||||
diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, -1), vec2(-1, 0), aa_scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
@ -1,9 +1,4 @@
|
|||||||
vec4 aa_apply(
|
vec4 aa_apply(texture2D tex, sampler smplr, vec2 fragCoord, vec2 resolution) {
|
||||||
texture2D tex, sampler smplr,
|
|
||||||
texture2D depth_tex, sampler depth_smplr,
|
|
||||||
vec2 fragCoord,
|
|
||||||
vec2 resolution
|
|
||||||
) {
|
|
||||||
ivec2 texel_coord = ivec2(fragCoord.x, fragCoord.y);
|
ivec2 texel_coord = ivec2(fragCoord.x, fragCoord.y);
|
||||||
|
|
||||||
vec4 sample1 = texelFetch(sampler2DMS(tex, smplr), texel_coord, 0);
|
vec4 sample1 = texelFetch(sampler2DMS(tex, smplr), texel_coord, 0);
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
vec4 aa_apply(
|
vec4 aa_apply(texture2D tex, sampler smplr, vec2 fragCoord, vec2 resolution) {
|
||||||
texture2D tex, sampler smplr,
|
|
||||||
texture2D depth_tex, sampler depth_smplr,
|
|
||||||
vec2 fragCoord,
|
|
||||||
vec2 resolution
|
|
||||||
) {
|
|
||||||
ivec2 texel_coord = ivec2(fragCoord.x, fragCoord.y);
|
ivec2 texel_coord = ivec2(fragCoord.x, fragCoord.y);
|
||||||
|
|
||||||
vec4 sample1 = texelFetch(sampler2DMS(tex, smplr), texel_coord, 0);
|
vec4 sample1 = texelFetch(sampler2DMS(tex, smplr), texel_coord, 0);
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
vec4 aa_apply(
|
vec4 aa_apply(texture2D tex, sampler smplr, vec2 fragCoord, vec2 resolution) {
|
||||||
texture2D tex, sampler smplr,
|
|
||||||
texture2D depth_tex, sampler depth_smplr,
|
|
||||||
vec2 fragCoord,
|
|
||||||
vec2 resolution
|
|
||||||
) {
|
|
||||||
ivec2 texel_coord = ivec2(fragCoord.x, fragCoord.y);
|
ivec2 texel_coord = ivec2(fragCoord.x, fragCoord.y);
|
||||||
|
|
||||||
vec4 sample1 = texelFetch(sampler2DMS(tex, smplr), texel_coord, 0);
|
vec4 sample1 = texelFetch(sampler2DMS(tex, smplr), texel_coord, 0);
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
vec4 aa_apply(
|
vec4 aa_apply(texture2D tex, sampler smplr, vec2 fragCoord, vec2 resolution) {
|
||||||
texture2D tex, sampler smplr,
|
|
||||||
texture2D depth_tex, sampler depth_smplr,
|
|
||||||
vec2 fragCoord,
|
|
||||||
vec2 resolution
|
|
||||||
) {
|
|
||||||
return texture(sampler2D(tex, smplr), fragCoord / resolution);
|
return texture(sampler2D(tex, smplr), fragCoord / resolution);
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,9 @@ uniform texture2D t_src_color;
|
|||||||
layout(set = 1, binding = 1)
|
layout(set = 1, binding = 1)
|
||||||
uniform sampler s_src_color;
|
uniform sampler s_src_color;
|
||||||
|
|
||||||
layout(set = 1, binding = 2)
|
|
||||||
uniform texture2D t_src_depth;
|
|
||||||
layout(set = 1, binding = 3)
|
|
||||||
uniform sampler s_src_depth;
|
|
||||||
|
|
||||||
layout(location = 0) in vec2 uv;
|
layout(location = 0) in vec2 uv;
|
||||||
|
|
||||||
layout (std140, set = 1, binding = 4)
|
layout (std140, set = 1, binding = 2)
|
||||||
uniform u_locals {
|
uniform u_locals {
|
||||||
mat4 proj_mat_inv;
|
mat4 proj_mat_inv;
|
||||||
mat4 view_mat_inv;
|
mat4 view_mat_inv;
|
||||||
@ -50,111 +45,22 @@ uniform texture2D t_src_bloom;
|
|||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_BETTERAA
|
#ifdef EXPERIMENTAL_BETTERAA
|
||||||
vec3 wpos_at(vec2 uv) {
|
vec4 clever_aa_apply(texture2D tex, sampler smplr, vec2 fragCoord, vec2 resolution) {
|
||||||
float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x - 0.0001;
|
|
||||||
vec4 clip_space = vec4((uv * 2.0 - 1.0) * vec2(1, -1), buf_depth, 1.0);
|
|
||||||
mat4 all_mat_inv = view_mat_inv * proj_mat_inv;
|
|
||||||
vec4 view_space = all_mat_inv * clip_space;
|
|
||||||
view_space /= view_space.w;
|
|
||||||
if (buf_depth == 0.0) {
|
|
||||||
vec3 direction = normalize(view_space.xyz);
|
|
||||||
return direction.xyz * 524288.0625 + cam_pos.xyz;
|
|
||||||
} else {
|
|
||||||
return view_space.xyz;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float depth_at(vec2 uv) {
|
|
||||||
float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x;
|
|
||||||
return 1.0 / buf_depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
float weighted_lerp(float x, float a, float b) {
|
|
||||||
return pow(x, b / a);
|
|
||||||
/* return x; */
|
|
||||||
float xx = b * x - a * (1.0 - x);
|
|
||||||
return sign(xx) * (1.0 - 1.0 / (1.0 + abs(xx))) * 0.5 + 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
float vmax(vec3 v) {
|
|
||||||
return max(v.x, max(v.y, v.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
float vmax_but_one(vec3 v) {
|
|
||||||
float m = max(v.x, max(v.y, v.z));
|
|
||||||
if (v.x == m)
|
|
||||||
return max(v.y, v.z);
|
|
||||||
else if (v.y == m)
|
|
||||||
return max(v.x, v.z);
|
|
||||||
else
|
|
||||||
return max(v.x, v.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 better_aa_apply(texture2D tex, sampler smplr, vec2 fragCoord, vec2 resolution) {
|
|
||||||
uvec2 src_sz = textureSize(sampler2D(tex, smplr), 0).xy;
|
uvec2 src_sz = textureSize(sampler2D(tex, smplr), 0).xy;
|
||||||
|
/* vec4 interp = texture(sampler2D(tex, smplr), fragCoord / resolution); */
|
||||||
vec3 wpos = wpos_at(fragCoord / resolution);
|
/* vec4 interp = textureBicubic(tex, smplr, fragCoord * src_sz / resolution); */
|
||||||
float dist = distance(cam_pos.xyz, wpos);
|
vec4 interp = aa_apply(tex, smplr, fragCoord, resolution);
|
||||||
vec3 dir = normalize(wpos - cam_pos.xyz);
|
|
||||||
|
|
||||||
// vec4 interp = texelFetch(sampler2D(tex, smplr), ivec2(fragCoord / resolution * src_sz), 0);
|
|
||||||
// vec4 interp = texture(sampler2D(tex, smplr), fragCoord / resolution);
|
|
||||||
// vec4 interp = textureBicubic(tex, smplr, fragCoord * src_sz / resolution);
|
|
||||||
vec4 interp = aa_apply(tex, smplr, t_src_depth, s_src_depth, fragCoord, resolution);
|
|
||||||
vec4 original = texelFetch(sampler2D(tex, smplr), ivec2(fragCoord / resolution * src_sz), 0);
|
vec4 original = texelFetch(sampler2D(tex, smplr), ivec2(fragCoord / resolution * src_sz), 0);
|
||||||
|
|
||||||
// GRID
|
|
||||||
/* if (mod(fragCoord.x, resolution.x / src_sz.x) < 0.9) { return vec4(0.0, 0.0, 0.0, 0.0); } */
|
|
||||||
/* if (mod(fragCoord.y, resolution.y / src_sz.y) < 0.9) { return vec4(0.0, 0.0, 0.0, 0.0); } */
|
|
||||||
|
|
||||||
vec2 pos = fragCoord;// - 0.5 * src_sz;
|
|
||||||
|
|
||||||
// vec4 t00 = texelFetch(sampler2D(tex, smplr), ivec2(pos / resolution * src_sz + ivec2(0, 0)), 0);
|
|
||||||
// vec4 t10 = texelFetch(sampler2D(tex, smplr), ivec2(pos / resolution * src_sz + ivec2(1, 0)), 0);
|
|
||||||
// vec4 t01 = texelFetch(sampler2D(tex, smplr), ivec2(pos / resolution * src_sz + ivec2(0, 1)), 0);
|
|
||||||
// vec4 t11 = texelFetch(sampler2D(tex, smplr), ivec2(pos / resolution * src_sz + ivec2(1, 1)), 0);
|
|
||||||
vec3 w00 = wpos_at(floor(pos / resolution * vec2(src_sz) + ivec2(0, 0)) / vec2(src_sz));
|
|
||||||
vec3 w10 = wpos_at(floor(pos / resolution * vec2(src_sz) + ivec2(1, 0)) / vec2(src_sz));
|
|
||||||
vec3 w01 = wpos_at(floor(pos / resolution * vec2(src_sz) + ivec2(0, 1)) / vec2(src_sz));
|
|
||||||
vec3 w11 = wpos_at(floor(pos / resolution * vec2(src_sz) + ivec2(1, 1)) / vec2(src_sz));
|
|
||||||
float d00 = distance(w00, cam_pos.xyz);
|
|
||||||
float d10 = distance(w10, cam_pos.xyz);
|
|
||||||
float d01 = distance(w01, cam_pos.xyz);
|
|
||||||
float d11 = distance(w11, cam_pos.xyz);
|
|
||||||
|
|
||||||
vec2 px_fact = fract(pos / (resolution / vec2(src_sz)));
|
|
||||||
// vec4 t0 = mix(t00, t10, weighted_lerp(px_fact.x, d00, d10));
|
|
||||||
// vec4 t1 = mix(t01, t11, weighted_lerp(px_fact.x, d01, d11));
|
|
||||||
vec3 w0 = (w00 * d00 * (1 - px_fact.x) + w10 * d10 * px_fact.x) / (d00 * (1 - px_fact.x) + d10 * px_fact.x);
|
|
||||||
vec3 w1 = (w01 * d01 * (1 - px_fact.x) + w11 * d11 * px_fact.x) / (d01 * (1 - px_fact.x) + d11 * px_fact.x);
|
|
||||||
float d0 = mix(d00, d10, px_fact.x);
|
|
||||||
float d1 = mix(d01, d11, px_fact.x);
|
|
||||||
|
|
||||||
float d_lerped = mix(d0, d1, px_fact.y);
|
|
||||||
vec3 wpos_lerped = (w0 * d0 * (1 - px_fact.y) + w1 * d1 * px_fact.y) / (d0 * (1 - px_fact.y) + d1 * px_fact.y) + vec3(
|
|
||||||
dir.y > 0.0 ? 0.0 : 0.5,
|
|
||||||
dir.x > 0.0 ? 0.5 : 0.0,
|
|
||||||
0.5
|
|
||||||
);//mix(w0, w1, weighted_lerp(px_fact.y, 0.1 / d0, 0.1 / d1)) + 0.5;
|
|
||||||
|
|
||||||
// vec4 interp = mix(t0, t1, weighted_lerp(px_fact.y, d0, d1));
|
|
||||||
|
|
||||||
/*
|
|
||||||
vec4 closest = vec4(0.0);
|
vec4 closest = vec4(0.0);
|
||||||
float closest_dist = 100000.0;
|
float closest_dist = 100000.0;
|
||||||
for (int i = -1; i < 2; i ++) {
|
for (int i = -1; i < 2; i ++) {
|
||||||
for (int j = -1; j < 2; j ++) {
|
for (int j = -1; j < 2; j ++) {
|
||||||
ivec2 rpos = ivec2(i, j);
|
ivec2 rpos = ivec2(i, j);
|
||||||
|
|
||||||
//float l = length(normalize(vec2(rpos)) - factor);
|
|
||||||
|
|
||||||
vec4 texel = texelFetch(sampler2D(tex, smplr), ivec2(fragCoord / resolution * src_sz) + rpos, 0);
|
vec4 texel = texelFetch(sampler2D(tex, smplr), ivec2(fragCoord / resolution * src_sz) + rpos, 0);
|
||||||
|
|
||||||
float fov = 70.0;
|
float dist = distance(interp.rgb, texel.rgb);
|
||||||
float texel_at_dist = dist / resolution.x * fov;
|
|
||||||
vec3 diff = mod(wpos * texel_at_dist, vec3(1.0)) - 0.5;
|
|
||||||
|
|
||||||
float dist = distance(interp.rgb, texel.rgb);// * 0.0 + (rpos.y - diff.z) * 1.0;// * (1.0 + l * 0.5);
|
|
||||||
if (dist < closest_dist) {
|
if (dist < closest_dist) {
|
||||||
closest = texel;
|
closest = texel;
|
||||||
closest_dist = dist;
|
closest_dist = dist;
|
||||||
@ -162,85 +68,7 @@ layout(location = 0) out vec4 tgt_color;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return closest;//interp;
|
return mix(closest, interp, 0.0);
|
||||||
*/
|
|
||||||
/*
|
|
||||||
ivec2 closest = ivec2(0);
|
|
||||||
vec3 closest_wpos = vec3(0);
|
|
||||||
float closest_dist = 100000.0;
|
|
||||||
for (int i = -1; i < 2; i ++) {
|
|
||||||
for (int j = -1; j < 2; j ++) {
|
|
||||||
ivec2 rpos = ivec2(i, j);
|
|
||||||
vec3 wpos = wpos_at(((fragCoord / resolution * vec2(src_sz)) + rpos) / vec2(src_sz));
|
|
||||||
float dist = distance(cam_pos.xyz, wpos);
|
|
||||||
if (dist < closest_dist) {
|
|
||||||
closest = rpos;
|
|
||||||
closest_wpos = wpos;
|
|
||||||
closest_dist = dist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float fov = 70.0;
|
|
||||||
vec2 texel_at_dist = src_sz / (fov * closest_dist);
|
|
||||||
vec3 diff = fract(closest_wpos) * 2.0 - 1.0;
|
|
||||||
|
|
||||||
vec2 rpos = vec2(diff.y * dir.x, -diff.z * -abs(dir.x))
|
|
||||||
//+ vec2(diff.x * -dir.y, diff.z * abs(dir.y))
|
|
||||||
//+ vec2(diff.z * -dir.z * 0, diff.x * abs(dir.z))
|
|
||||||
;
|
|
||||||
|
|
||||||
vec4 texel = texelFetch(sampler2D(tex, smplr), ivec2(fragCoord / resolution * src_sz + closest + rpos), 0);
|
|
||||||
|
|
||||||
return texel;
|
|
||||||
*/
|
|
||||||
|
|
||||||
float original_dist = dist;
|
|
||||||
vec4 closest_texel = vec4(0);
|
|
||||||
vec3 closest_wpos = vec3(0);
|
|
||||||
float closest_dist = 100000.0;
|
|
||||||
vec4 weighted_sum = vec4(0.0);
|
|
||||||
float weighted_total = 0.0;
|
|
||||||
for (int i = -1; i < 2; i ++) {
|
|
||||||
for (int j = -1; j < 2; j ++) {
|
|
||||||
ivec2 rpos = ivec2(i, j);
|
|
||||||
vec3 wpos = wpos_at(floor(fragCoord / resolution * vec2(src_sz) + rpos - 1) / vec2(src_sz));
|
|
||||||
float tdist = distance(cam_pos.xyz, wpos);
|
|
||||||
|
|
||||||
//float fov = 1.2;
|
|
||||||
//float texel_at_dist = src_sz.x / (fov * tdist);
|
|
||||||
|
|
||||||
vec4 texel = texelFetch(sampler2D(tex, smplr), ivec2(fragCoord / resolution * src_sz) + rpos, 0);
|
|
||||||
//texel = texture(sampler2D(tex, smplr), floor(fragCoord / resolution * vec2(src_sz) + rpos) / vec2(src_sz));
|
|
||||||
|
|
||||||
float texel_dist;
|
|
||||||
if (true && false) {
|
|
||||||
texel_dist = distance(wpos + fract(wpos_lerped * 2.0) / 2.0, wpos_lerped);
|
|
||||||
} else if (original_dist < 15.0 || true) {
|
|
||||||
texel_dist = distance(interp.rgb, texel.rgb);
|
|
||||||
} else {
|
|
||||||
texel_dist = length(mod(wpos, vec3(1.0)) - 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (texel_dist < closest_dist) {
|
|
||||||
closest_texel = texel;
|
|
||||||
closest_wpos = wpos;
|
|
||||||
closest_dist = texel_dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
//float weight = 1.0 / distance(interp.rgb, texel.rgb);
|
|
||||||
float weight = 1.0 / distance(wpos, wpos_lerped);
|
|
||||||
|
|
||||||
weighted_sum += texel * weight;
|
|
||||||
weighted_total += weight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//return vec4(px_fact.xy, 1.0, 1.0);
|
|
||||||
//return mod(10.0 * d_lerped, 1.0).xxxx;
|
|
||||||
//return mod(wpos_lerped, 1.0).xyzx;
|
|
||||||
//return weighted_sum / weighted_total;
|
|
||||||
return closest_texel;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -357,7 +185,7 @@ vec3 _illuminate(float max_light, vec3 view_dir, /*vec3 max_light, */vec3 emitte
|
|||||||
|
|
||||||
#ifdef EXPERIMENTAL_SOBEL
|
#ifdef EXPERIMENTAL_SOBEL
|
||||||
vec3 aa_sample(vec2 uv, vec2 off) {
|
vec3 aa_sample(vec2 uv, vec2 off) {
|
||||||
return aa_apply(t_src_color, s_src_color, t_src_depth, s_src_depth, uv * screen_res.xy + off, screen_res.xy).rgb;
|
return aa_apply(t_src_color, s_src_color, uv * screen_res.xy + off, screen_res.xy).rgb;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -411,9 +239,9 @@ void main() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_BETTERAA
|
#ifdef EXPERIMENTAL_BETTERAA
|
||||||
vec4 aa_color = better_aa_apply(t_src_color, s_src_color, sample_uv * screen_res.xy, screen_res.xy);
|
vec4 aa_color = clever_aa_apply(t_src_color, s_src_color, sample_uv * screen_res.xy, screen_res.xy);
|
||||||
#else
|
#else
|
||||||
vec4 aa_color = aa_apply(t_src_color, s_src_color, t_src_depth, s_src_depth, sample_uv * screen_res.xy, screen_res.xy);
|
vec4 aa_color = aa_apply(t_src_color, s_src_color, sample_uv * screen_res.xy, screen_res.xy);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -804,15 +804,13 @@ impl<'a> Widget for Video<'a> {
|
|||||||
/* AaMode::MsaaX4,
|
/* AaMode::MsaaX4,
|
||||||
AaMode::MsaaX8,
|
AaMode::MsaaX8,
|
||||||
AaMode::MsaaX16, */
|
AaMode::MsaaX16, */
|
||||||
AaMode::Hqx,
|
|
||||||
];
|
];
|
||||||
let mode_label_list = [
|
let mode_label_list = [
|
||||||
"No anti-aliasing",
|
"No AA",
|
||||||
"FXAA",
|
"FXAA",
|
||||||
/* "MSAA x4",
|
/* "MSAA x4",
|
||||||
"MSAA x8",
|
"MSAA x8",
|
||||||
"MSAA x16 (experimental)", */
|
"MSAA x16 (experimental)", */
|
||||||
"HQX",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Get which AA mode is currently active
|
// Get which AA mode is currently active
|
||||||
@ -943,7 +941,7 @@ impl<'a> Widget for Video<'a> {
|
|||||||
|
|
||||||
let upscale_factors = [
|
let upscale_factors = [
|
||||||
// Upscaling
|
// Upscaling
|
||||||
0.01, 0.025, 0.1, 0.15, 0.2, 0.25, 0.35, 0.5, 0.65, 0.75, 0.85, 1.0,
|
0.15, 0.2, 0.25, 0.35, 0.5, 0.65, 0.75, 0.85, 1.0,
|
||||||
// Downscaling (equivalent to SSAA)
|
// Downscaling (equivalent to SSAA)
|
||||||
1.25, 1.5, 1.75, 2.0,
|
1.25, 1.5, 1.75, 2.0,
|
||||||
];
|
];
|
||||||
|
@ -93,27 +93,10 @@ pub enum AaMode {
|
|||||||
/// also struggle in the future with deferred shading, so they may be
|
/// also struggle in the future with deferred shading, so they may be
|
||||||
/// removed in the future.
|
/// removed in the future.
|
||||||
MsaaX16,
|
MsaaX16,
|
||||||
/// Fast upscaling re-aliasing.
|
|
||||||
///
|
|
||||||
/// Screen-space technique that attempts to reconstruct lines and edges
|
|
||||||
/// in the original image. Useless at internal resolutions higher than 1.0x,
|
|
||||||
/// but potentially very effective at much lower internal resolutions.
|
|
||||||
Hqx,
|
|
||||||
#[serde(other)]
|
#[serde(other)]
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AaMode {
|
|
||||||
pub fn samples(&self) -> u32 {
|
|
||||||
match self {
|
|
||||||
AaMode::None | AaMode::Fxaa | AaMode::Hqx => 1,
|
|
||||||
AaMode::MsaaX4 => 4,
|
|
||||||
AaMode::MsaaX8 => 8,
|
|
||||||
AaMode::MsaaX16 => 16,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for AaMode {
|
impl Default for AaMode {
|
||||||
fn default() -> Self { AaMode::Fxaa }
|
fn default() -> Self { AaMode::Fxaa }
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,12 @@ impl CloudsPipeline {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Clouds pipeline"),
|
label: Some("Clouds pipeline"),
|
||||||
|
@ -71,7 +71,12 @@ impl DebugPipeline {
|
|||||||
bind_group_layouts: &[&global_layouts.globals, &layout.locals],
|
bind_group_layouts: &[&global_layouts.globals, &layout.locals],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Debug pipeline"),
|
label: Some("Debug pipeline"),
|
||||||
|
@ -190,7 +190,12 @@ impl FigurePipeline {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Figure pipeline"),
|
label: Some("Figure pipeline"),
|
||||||
|
@ -70,7 +70,12 @@ impl FluidPipeline {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Fluid pipeline"),
|
label: Some("Fluid pipeline"),
|
||||||
|
@ -94,7 +94,12 @@ impl LodObjectPipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("LoD object pipeline"),
|
label: Some("LoD object pipeline"),
|
||||||
|
@ -209,7 +209,12 @@ impl LodTerrainPipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Lod terrain pipeline"),
|
label: Some("Lod terrain pipeline"),
|
||||||
|
@ -200,7 +200,12 @@ impl ParticlePipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Particle pipeline"),
|
label: Some("Particle pipeline"),
|
||||||
|
@ -53,29 +53,9 @@ impl PostProcessLayout {
|
|||||||
},
|
},
|
||||||
count: None,
|
count: None,
|
||||||
},
|
},
|
||||||
// Depth source
|
|
||||||
wgpu::BindGroupLayoutEntry {
|
|
||||||
binding: 2,
|
|
||||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
|
||||||
ty: wgpu::BindingType::Texture {
|
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
|
||||||
view_dimension: wgpu::TextureViewDimension::D2,
|
|
||||||
multisampled: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
wgpu::BindGroupLayoutEntry {
|
|
||||||
binding: 3,
|
|
||||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
|
||||||
ty: wgpu::BindingType::Sampler {
|
|
||||||
filtering: true,
|
|
||||||
comparison: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
// Locals
|
// Locals
|
||||||
wgpu::BindGroupLayoutEntry {
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding: 4,
|
binding: 2,
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||||
ty: wgpu::BindingType::Buffer {
|
ty: wgpu::BindingType::Buffer {
|
||||||
ty: wgpu::BufferBindingType::Uniform,
|
ty: wgpu::BufferBindingType::Uniform,
|
||||||
@ -90,7 +70,7 @@ impl PostProcessLayout {
|
|||||||
bind_entries.push(
|
bind_entries.push(
|
||||||
// src bloom
|
// src bloom
|
||||||
wgpu::BindGroupLayoutEntry {
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding: 5,
|
binding: 3,
|
||||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||||
ty: wgpu::BindingType::Texture {
|
ty: wgpu::BindingType::Texture {
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||||
@ -114,10 +94,8 @@ impl PostProcessLayout {
|
|||||||
&self,
|
&self,
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
src_color: &wgpu::TextureView,
|
src_color: &wgpu::TextureView,
|
||||||
src_depth: &wgpu::TextureView,
|
|
||||||
src_bloom: Option<&wgpu::TextureView>,
|
src_bloom: Option<&wgpu::TextureView>,
|
||||||
sampler: &wgpu::Sampler,
|
sampler: &wgpu::Sampler,
|
||||||
depth_sampler: &wgpu::Sampler,
|
|
||||||
locals: &Consts<Locals>,
|
locals: &Consts<Locals>,
|
||||||
) -> BindGroup {
|
) -> BindGroup {
|
||||||
let mut entries = vec![
|
let mut entries = vec![
|
||||||
@ -131,14 +109,6 @@ impl PostProcessLayout {
|
|||||||
},
|
},
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding: 2,
|
binding: 2,
|
||||||
resource: wgpu::BindingResource::TextureView(src_depth),
|
|
||||||
},
|
|
||||||
wgpu::BindGroupEntry {
|
|
||||||
binding: 3,
|
|
||||||
resource: wgpu::BindingResource::Sampler(depth_sampler),
|
|
||||||
},
|
|
||||||
wgpu::BindGroupEntry {
|
|
||||||
binding: 4,
|
|
||||||
resource: locals.buf().as_entire_binding(),
|
resource: locals.buf().as_entire_binding(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -150,7 +120,7 @@ impl PostProcessLayout {
|
|||||||
// TODO: if there is no upscaling we can do the last bloom upsampling in post
|
// TODO: if there is no upscaling we can do the last bloom upsampling in post
|
||||||
// process to save a pass and the need for the final full size bloom render target
|
// process to save a pass and the need for the final full size bloom render target
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding: 5,
|
binding: 3,
|
||||||
resource: wgpu::BindingResource::TextureView(src_bloom),
|
resource: wgpu::BindingResource::TextureView(src_bloom),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -103,7 +103,12 @@ impl RainOcclusionFigurePipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &figure_layout.locals],
|
bind_group_layouts: &[&global_layout.globals, &figure_layout.locals],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Rain occlusion figure pipeline"),
|
label: Some("Rain occlusion figure pipeline"),
|
||||||
@ -171,7 +176,12 @@ impl RainOcclusionPipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &terrain_layout.locals],
|
bind_group_layouts: &[&global_layout.globals, &terrain_layout.locals],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Rain occlusion pipeline"),
|
label: Some("Rain occlusion pipeline"),
|
||||||
|
@ -145,7 +145,12 @@ impl ShadowFigurePipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &figure_layout.locals],
|
bind_group_layouts: &[&global_layout.globals, &figure_layout.locals],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Directed shadow figure pipeline"),
|
label: Some("Directed shadow figure pipeline"),
|
||||||
@ -213,7 +218,12 @@ impl ShadowPipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &terrain_layout.locals],
|
bind_group_layouts: &[&global_layout.globals, &terrain_layout.locals],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Directed shadow pipeline"),
|
label: Some("Directed shadow pipeline"),
|
||||||
@ -283,7 +293,12 @@ impl PointShadowPipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &terrain_layout.locals],
|
bind_group_layouts: &[&global_layout.globals, &terrain_layout.locals],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Point shadow pipeline"),
|
label: Some("Point shadow pipeline"),
|
||||||
|
@ -48,7 +48,12 @@ impl SkyboxPipeline {
|
|||||||
bind_group_layouts: &[&layouts.globals, &layouts.shadow_textures],
|
bind_group_layouts: &[&layouts.globals, &layouts.shadow_textures],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Skybox pipeline"),
|
label: Some("Skybox pipeline"),
|
||||||
|
@ -267,7 +267,12 @@ impl SpritePipeline {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Sprite pipeline"),
|
label: Some("Sprite pipeline"),
|
||||||
|
@ -234,7 +234,12 @@ impl TerrainPipeline {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Terrain pipeline"),
|
label: Some("Terrain pipeline"),
|
||||||
|
@ -69,7 +69,12 @@ impl TrailPipeline {
|
|||||||
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
bind_group_layouts: &[&global_layout.globals, &global_layout.shadow_textures],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = aa_mode.samples();
|
let samples = match aa_mode {
|
||||||
|
AaMode::None | AaMode::Fxaa => 1,
|
||||||
|
AaMode::MsaaX4 => 4,
|
||||||
|
AaMode::MsaaX8 => 8,
|
||||||
|
AaMode::MsaaX16 => 16,
|
||||||
|
};
|
||||||
|
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Trail pipeline"),
|
label: Some("Trail pipeline"),
|
||||||
|
@ -28,8 +28,8 @@ use super::{
|
|||||||
ui, GlobalsBindGroup, GlobalsLayouts, ShadowTexturesBindGroup,
|
ui, GlobalsBindGroup, GlobalsLayouts, ShadowTexturesBindGroup,
|
||||||
},
|
},
|
||||||
texture::Texture,
|
texture::Texture,
|
||||||
AddressMode, FilterMode, OtherModes, PipelineModes, RenderError, RenderMode, ShadowMapMode,
|
AaMode, AddressMode, FilterMode, OtherModes, PipelineModes, RenderError, RenderMode,
|
||||||
ShadowMode, Vertex,
|
ShadowMapMode, ShadowMode, Vertex,
|
||||||
};
|
};
|
||||||
use common::assets::{self, AssetExt, AssetHandle, ReloadWatcher};
|
use common::assets::{self, AssetExt, AssetHandle, ReloadWatcher};
|
||||||
use common_base::span;
|
use common_base::span;
|
||||||
@ -798,8 +798,12 @@ impl Renderer {
|
|||||||
let upscaled = Vec2::<u32>::from(size)
|
let upscaled = Vec2::<u32>::from(size)
|
||||||
.map(|e| (e as f32 * other_modes.upscale_mode.factor) as u32)
|
.map(|e| (e as f32 * other_modes.upscale_mode.factor) as u32)
|
||||||
.into_tuple();
|
.into_tuple();
|
||||||
let (width, height) = upscaled;
|
let (width, height, sample_count) = match pipeline_modes.aa {
|
||||||
let sample_count = pipeline_modes.aa.samples();
|
AaMode::None | AaMode::Fxaa => (upscaled.0, upscaled.1, 1),
|
||||||
|
AaMode::MsaaX4 => (upscaled.0, upscaled.1, 4),
|
||||||
|
AaMode::MsaaX8 => (upscaled.0, upscaled.1, 8),
|
||||||
|
AaMode::MsaaX16 => (upscaled.0, upscaled.1, 16),
|
||||||
|
};
|
||||||
let levels = 1;
|
let levels = 1;
|
||||||
|
|
||||||
let color_view = |width, height| {
|
let color_view = |width, height| {
|
||||||
|
@ -47,10 +47,8 @@ impl Locals {
|
|||||||
let postprocess_bind = layouts.postprocess.bind(
|
let postprocess_bind = layouts.postprocess.bind(
|
||||||
device,
|
device,
|
||||||
tgt_color_pp_view,
|
tgt_color_pp_view,
|
||||||
tgt_depth_view,
|
|
||||||
bloom.as_ref().map(|b| b.final_tgt_view),
|
bloom.as_ref().map(|b| b.final_tgt_view),
|
||||||
sampler,
|
sampler,
|
||||||
depth_sampler,
|
|
||||||
&postprocess_locals,
|
&postprocess_locals,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -94,10 +92,8 @@ impl Locals {
|
|||||||
self.postprocess_bind = layouts.postprocess.bind(
|
self.postprocess_bind = layouts.postprocess.bind(
|
||||||
device,
|
device,
|
||||||
tgt_color_pp_view,
|
tgt_color_pp_view,
|
||||||
tgt_depth_view,
|
|
||||||
bloom.as_ref().map(|b| b.final_tgt_view),
|
bloom.as_ref().map(|b| b.final_tgt_view),
|
||||||
sampler,
|
sampler,
|
||||||
depth_sampler,
|
|
||||||
&self.postprocess,
|
&self.postprocess,
|
||||||
);
|
);
|
||||||
self.bloom_binds = bloom.map(|bloom| {
|
self.bloom_binds = bloom.map(|bloom| {
|
||||||
|
@ -247,7 +247,6 @@ impl ShaderModules {
|
|||||||
AaMode::MsaaX4 => "antialias.msaa-x4",
|
AaMode::MsaaX4 => "antialias.msaa-x4",
|
||||||
AaMode::MsaaX8 => "antialias.msaa-x8",
|
AaMode::MsaaX8 => "antialias.msaa-x8",
|
||||||
AaMode::MsaaX16 => "antialias.msaa-x16",
|
AaMode::MsaaX16 => "antialias.msaa-x16",
|
||||||
AaMode::Hqx => "antialias.hqx",
|
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ impl assets::Compound for Shaders {
|
|||||||
"antialias.msaa-x4",
|
"antialias.msaa-x4",
|
||||||
"antialias.msaa-x8",
|
"antialias.msaa-x8",
|
||||||
"antialias.msaa-x16",
|
"antialias.msaa-x16",
|
||||||
"antialias.hqx",
|
|
||||||
"include.cloud.none",
|
"include.cloud.none",
|
||||||
"include.cloud.regular",
|
"include.cloud.regular",
|
||||||
"figure-vert",
|
"figure-vert",
|
||||||
|
Loading…
Reference in New Issue
Block a user