mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/gbuffers-ssr' into 'master'
Use normal and material gbuffer to improve quality of SSR See merge request veloren/veloren!3734
This commit is contained in:
commit
b127cff26c
@ -39,13 +39,16 @@ uniform texture2D t_src_depth;
|
||||
layout(set = 2, binding = 3)
|
||||
uniform sampler s_src_depth;
|
||||
|
||||
layout(location = 0) in vec2 uv;
|
||||
|
||||
layout (std140, set = 2, binding = 4)
|
||||
uniform u_locals {
|
||||
mat4 all_mat_inv;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec2 uv;
|
||||
|
||||
layout(set = 2, binding = 5)
|
||||
uniform utexture2D t_src_mat;
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
|
||||
vec3 wpos_at(vec2 uv) {
|
||||
@ -79,6 +82,25 @@ float depth_at(vec2 uv) {
|
||||
void main() {
|
||||
vec4 color = texture(sampler2D(t_src_color, s_src_color), uv);
|
||||
|
||||
uvec2 mat_sz = textureSize(usampler2D(t_src_mat, s_src_depth), 0);
|
||||
uvec4 mat = texelFetch(usampler2D(t_src_mat, s_src_depth), clamp(ivec2(uv * mat_sz), ivec2(0), ivec2(mat_sz) - 1), 0);
|
||||
|
||||
#ifdef EXPERIMENTAL_VIEWNORMALS
|
||||
tgt_color = vec4(vec3(mat.xyz) / 255.0, 1);
|
||||
return;
|
||||
#endif
|
||||
#ifdef EXPERIMENTAL_VIEWMATERIALS
|
||||
const vec3 mat_colors[5] = vec3[](
|
||||
vec3(0, 1, 1), // MAT_SKY
|
||||
vec3(1, 1, 0), // MAT_BLOCK
|
||||
vec3(0, 0, 1), // MAT_FLUID
|
||||
vec3(1, 0, 1), // MAT_FIGURE
|
||||
vec3(0.5, 1, 0) // MAT_LOD
|
||||
);
|
||||
tgt_color = vec4(mat_colors[mat.a % 5u], 1);
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef EXPERIMENTAL_BAREMINIMUM
|
||||
tgt_color = vec4(color.rgb, 1);
|
||||
return;
|
||||
@ -126,8 +148,8 @@ void main() {
|
||||
cloud_blend = 1.0 - color.a;
|
||||
|
||||
#if (FLUID_MODE >= FLUID_MODE_MEDIUM || REFLECTION_MODE >= REFLECTION_MODE_MEDIUM)
|
||||
if (dir.z < 0.0) {
|
||||
vec3 surf_norm = normalize(vec3(nz * 0.3 / (1.0 + dist * 0.1), 1));
|
||||
if (mat.a != MAT_SKY) {
|
||||
vec3 surf_norm = vec3(mat.xyz) / 127.0 - 1.0;
|
||||
vec3 refl_dir = reflect(dir, surf_norm);
|
||||
|
||||
vec4 clip = (all_mat * vec4(cam_pos.xyz + refl_dir, 1.0));
|
||||
@ -169,22 +191,59 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EXPERIMENTAL_SMEARREFLECTIONS
|
||||
const float SMEAR_FRAC = 0.2;
|
||||
vec2 anew_uv = abs(new_uv - 0.5) * 2;
|
||||
new_uv = mix(
|
||||
anew_uv,
|
||||
1.0 - SMEAR_FRAC + (1.0 - 1.0 / (1.0 + (anew_uv - 1.0 + SMEAR_FRAC))) * SMEAR_FRAC,
|
||||
lessThan(vec2(1.0 - SMEAR_FRAC), anew_uv)
|
||||
) * sign(new_uv - 0.5) * 0.5 + 0.5;
|
||||
#else
|
||||
new_uv = clamp(new_uv, vec2(0), vec2(1));
|
||||
#endif
|
||||
|
||||
vec3 new_wpos = wpos_at(new_uv);
|
||||
float new_dist = distance(new_wpos, cam_pos.xyz);
|
||||
float merge = min(
|
||||
// Off-screen merge factor
|
||||
clamp((1.0 - abs(new_uv.y - 0.5) * 2) * 3.0, 0, 1),
|
||||
#ifdef EXPERIMENTAL_SMEARREFLECTIONS
|
||||
1.0,
|
||||
#else
|
||||
clamp((1.0 - max(abs(new_uv.y - 0.5), abs(new_uv.x - 0.5)) * 2) * 6.0, 0, 1),
|
||||
#endif
|
||||
// Depth merge factor
|
||||
clamp((new_dist - dist * 0.5) / (dist * 0.5), 0.0, 1.0)
|
||||
);
|
||||
|
||||
vec3 refl_col;
|
||||
float not_underground = 1.0;
|
||||
// Make underground water look more correct
|
||||
#if (REFLECTION_MODE >= REFLECTION_MODE_HIGH)
|
||||
float f_alt = alt_at(wpos.xy);
|
||||
not_underground = clamp((wpos.z - f_alt) / 32.0 + 1.0, 0.0, 1.0);
|
||||
#endif
|
||||
// Did we hit a surface during reflection?
|
||||
if (merge > 0.0) {
|
||||
vec3 new_col = texelFetch(sampler2D(t_src_color, s_src_color), clamp(ivec2(new_uv * col_sz), ivec2(0), ivec2(col_sz) - 1), 0).rgb;
|
||||
new_col = get_cloud_color(new_col.rgb, refl_dir, wpos, time_of_day.x, distance(new_wpos, wpos.xyz), 1.0);
|
||||
color.rgb = mix(color.rgb, new_col, min(merge * (color.a * 2.0), 0.75));
|
||||
// Yes: grab the new material from screen space
|
||||
uvec4 new_mat = texelFetch(usampler2D(t_src_mat, s_src_depth), clamp(ivec2(new_uv * mat_sz), ivec2(0), ivec2(mat_sz) - 1), 0);
|
||||
// If it's the sky, just go determine the sky color analytically to avoid sampling the incomplete skybox
|
||||
// Otherwise, pull the color from the screen-space color buffer
|
||||
vec3 sky_col = min(get_sky_color(refl_dir, time_of_day.x, wpos, vec3(-100000), 0.125, false, 0.0, true, 0.0), vec3(1)) * not_underground;
|
||||
if (new_mat.a == MAT_SKY) {
|
||||
refl_col = sky_col;
|
||||
} else {
|
||||
refl_col = mix(sky_col, texelFetch(sampler2D(t_src_color, s_src_color), clamp(ivec2(new_uv * col_sz), ivec2(0), ivec2(col_sz) - 1), 0).rgb, merge);
|
||||
}
|
||||
// Apply clouds to reflected colour
|
||||
refl_col = mix(refl_col, get_cloud_color(refl_col, refl_dir, wpos, time_of_day.x, distance(new_wpos, wpos.xyz), 1.0), not_underground);
|
||||
} else {
|
||||
// No: assume that anything off-screen is the colour of the sky
|
||||
refl_col = min(get_sky_color(refl_dir, time_of_day.x, wpos, vec3(-100000), 0.125, true, 1.0, true, 1.0) * not_underground, vec3(1));
|
||||
// Apply clouds to reflection
|
||||
refl_col = mix(refl_col, get_cloud_color(refl_col, refl_dir, wpos, time_of_day.x, 100000.0, 1.0), not_underground);
|
||||
}
|
||||
color.rgb = mix(color.rgb, refl_col, color.a);
|
||||
cloud_blend = 1;
|
||||
} else {
|
||||
#else
|
||||
@ -233,7 +292,8 @@ void main() {
|
||||
vec3 wpos = cam_pos.xyz + dir * wpos_dist;
|
||||
|
||||
if (wpos_dist > dist) { break; }
|
||||
if (length((fract(wall_pos.xz) - 0.5)) < 0.1 + pow(max(0.0, wpos_dist - (dist - 0.25)) / 0.25, 4.0) * 0.2) {
|
||||
vec2 wall_pos_half = fract(wall_pos.xz) - 0.5;
|
||||
if (dot(wall_pos_half, wall_pos_half) < 0.01 + pow(max(0.0, wpos_dist - (dist - 0.25)) / 0.25, 4.0) * 0.2) {
|
||||
float density = rain_density * rain_occlusion_at(wpos);
|
||||
if (fract(hash_two(uvec2(wall_pos.xz) + 1000u)) >= density) { continue; }
|
||||
|
||||
|
@ -27,13 +27,12 @@ uniform texture2D t_col_light;
|
||||
layout(set = 2, binding = 1)
|
||||
uniform sampler s_col_light;
|
||||
|
||||
layout (location = 0)
|
||||
out vec4 tgt_color;
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
void main() {
|
||||
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
|
||||
vec3 view_dir = -cam_to_frag;
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
|
||||
#if (SHADOW_MODE == SHADOW_MODE_CHEAP || SHADOW_MODE == SHADOW_MODE_MAP || FLUID_MODE == FLUID_MODE_SHINY)
|
||||
float f_alt = alt_at(f_pos.xy);
|
||||
@ -49,8 +48,8 @@ void main() {
|
||||
#endif
|
||||
float moon_shade_frac = 1.0;
|
||||
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac);
|
||||
|
||||
vec3 surf_color = f_color.xyz;
|
||||
float alpha = 1.0;
|
||||
@ -74,8 +73,13 @@ void main() {
|
||||
max_light += get_sun_diffuse2(sun_info, moon_info, f_norm, view_dir, f_pos, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
|
||||
|
||||
max_light += lights_at(f_pos, f_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
reflected_light *= point_shadow;
|
||||
emitted_light *= point_shadow;
|
||||
|
||||
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light * 1.0);
|
||||
|
||||
tgt_color = vec4(surf_color, 1.0);
|
||||
//tgt_color = vec4(f_norm, 1.0);
|
||||
tgt_color = vec4(surf_color, f_color.a);
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_FIGURE);
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ uniform u_bones {
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
void main() {
|
||||
// vec2 texSize = textureSize(t_col_light, 0);
|
||||
@ -159,9 +160,8 @@ void main() {
|
||||
// float shade_frac = /*1.0;*/sun_shade_frac + moon_shade_frac;
|
||||
|
||||
// DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos);
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac/*, light_pos*/);
|
||||
|
||||
vec3 surf_color;
|
||||
// If the figure is large enough to be 'terrain-like', we apply a noise effect to it
|
||||
@ -241,23 +241,30 @@ void main() {
|
||||
// TODO: Hack to add a small amount of underground ambient light to the scene
|
||||
reflected_light += vec3(0.01, 0.02, 0.03) * (1.0 - not_underground);
|
||||
|
||||
float ao = f_ao * sqrt(f_ao);//0.25 + f_ao * 0.75; ///*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
|
||||
// Apply baked lighting from emissive blocks
|
||||
float glow_mag = length(model_glow.xyz);
|
||||
vec3 glow = pow(model_glow.w, 2) * 4
|
||||
* glow_light(f_pos)
|
||||
* (max(dot(f_norm, model_glow.xyz / glow_mag) * 0.5 + 0.5, 0.0) + max(1.0 - glow_mag, 0.0));
|
||||
emitted_light += glow * cam_attenuation;
|
||||
|
||||
// Apply baked AO
|
||||
float ao = f_ao * sqrt(f_ao);//0.25 + f_ao * 0.75; ///*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
|
||||
reflected_light *= ao;
|
||||
emitted_light *= ao;
|
||||
|
||||
// Apply point light AO
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
reflected_light *= point_shadow;
|
||||
emitted_light *= point_shadow;
|
||||
|
||||
// Apply emissive glow
|
||||
// For now, just make glowing material light be the same colour as the surface
|
||||
// TODO: Add a way to control this better outside the shaders
|
||||
if ((material & (1u << 0u)) > 0u) {
|
||||
emitted_light += 20 * surf_color;
|
||||
}
|
||||
|
||||
float glow_mag = length(model_glow.xyz);
|
||||
vec3 glow = pow(model_glow.w, 2) * 4
|
||||
* glow_light(f_pos)
|
||||
* (max(dot(f_norm, model_glow.xyz / glow_mag) * 0.5 + 0.5, 0.0) + max(1.0 - glow_mag, 0.0));
|
||||
|
||||
emitted_light += glow * cam_attenuation;
|
||||
|
||||
reflected_light *= ao;
|
||||
emitted_light *= ao;
|
||||
/* reflected_light *= cloud_shadow(f_pos); */
|
||||
/* vec3 point_light = light_at(f_pos, f_norm);
|
||||
emitted_light += point_light;
|
||||
@ -299,4 +306,5 @@ void main() {
|
||||
// }
|
||||
|
||||
tgt_color = vec4(surf_color, 1.0);
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_FIGURE);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ uniform u_locals {
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
#include <sky.glsl>
|
||||
#include <light.glsl>
|
||||
@ -131,9 +132,8 @@ void main() {
|
||||
// float shade_frac = /*1.0;*/sun_shade_frac + moon_shade_frac;
|
||||
|
||||
// DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos);
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac/*, light_pos*/);
|
||||
|
||||
float fluid_alt = f_pos.z;//max(ceil(f_pos.z), floor(f_alt));// f_alt;//max(f_alt - f_pos.z, 0.0);
|
||||
|
||||
@ -190,6 +190,11 @@ void main() {
|
||||
|
||||
// Global illumination when underground (silly)
|
||||
emitted_light += (1.0 - not_underground) * 0.05;
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
reflected_light *= point_shadow;
|
||||
emitted_light *= point_shadow;
|
||||
|
||||
// reflected_light *= f_light * point_shadow * shade_frac;
|
||||
// emitted_light *= f_light * point_shadow * max(shade_frac, MIN_SHADOW);
|
||||
// max_light *= f_light * point_shadow * shade_frac;
|
||||
@ -238,4 +243,5 @@ void main() {
|
||||
vec4 color = vec4(surf_color, opacity);
|
||||
|
||||
tgt_color = color;
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_FLUID);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ uniform u_locals {
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
#include <cloud.glsl>
|
||||
#include <light.glsl>
|
||||
@ -82,14 +83,14 @@ vec4 wave_height(vec4 posx, vec4 posy) {
|
||||
posy *= 0.2;
|
||||
const float drag_factor = 0.035;
|
||||
const int iters = 21;
|
||||
const float scale = 25.0;
|
||||
const float scale = 15.0;
|
||||
#else
|
||||
float speed = 2.0;
|
||||
posx *= 0.3;
|
||||
posy *= 0.3;
|
||||
const float drag_factor = 0.04;
|
||||
const int iters = 11;
|
||||
const float scale = 5.0;
|
||||
const float scale = 3.0;
|
||||
#endif
|
||||
const float iter_shift = (3.14159 * 2.0) / 7.3;
|
||||
|
||||
@ -269,8 +270,10 @@ void main() {
|
||||
|
||||
vec3 reflect_color;
|
||||
#if (REFLECTION_MODE >= REFLECTION_MODE_MEDIUM)
|
||||
reflect_color = get_sky_color(ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac);
|
||||
reflect_color = get_cloud_color(reflect_color, ray_dir, f_pos.xyz, time_of_day.x, 100000.0, 0.1);
|
||||
// This is now done in the post-process cloud shader
|
||||
/* reflect_color = get_sky_color(ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac); */
|
||||
/* reflect_color = get_cloud_color(reflect_color, ray_dir, f_pos.xyz, time_of_day.x, 100000.0, 0.1); */
|
||||
reflect_color = vec3(0);
|
||||
#else
|
||||
reflect_color = get_sky_color(ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac);
|
||||
#endif
|
||||
@ -283,9 +286,8 @@ void main() {
|
||||
reflect_color *= not_underground;
|
||||
|
||||
// DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos);
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac/*, light_pos*/);
|
||||
|
||||
// Hack to determine water depth: color goes down with distance through water, so
|
||||
// we assume water color absorption from this point a to some other point b is the distance
|
||||
@ -343,6 +345,9 @@ void main() {
|
||||
|
||||
// Global illumination when underground (silly)
|
||||
emitted_light += (1.0 - not_underground) * 0.05;
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
reflected_light *= point_shadow;
|
||||
// Apply cloud layer to sky
|
||||
// reflected_light *= /*water_color_direct * */reflect_color * f_light * point_shadow * shade_frac;
|
||||
// emitted_light *= /*water_color_direct*//*ambient_attenuation * */f_light * point_shadow * max(shade_frac, MIN_SHADOW);
|
||||
@ -362,7 +367,7 @@ void main() {
|
||||
|
||||
max_light += lights_at(f_pos, cam_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, /*k_d*//*vec3(0.0)*/k_d, /*vec3(0.0)*/k_s, alpha, f_norm, 1.0, emitted_light, /*diffuse_light*/reflected_light);
|
||||
|
||||
float reflected_light_point = length(reflected_light);///*length*/(diffuse_light_point.r) + f_light * point_shadow;
|
||||
//float reflected_light_point = length(reflected_light);///*length*/(diffuse_light_point.r) + f_light * point_shadow;
|
||||
// TODO: See if we can be smarter about this using point light distances.
|
||||
// reflected_light += k_d * (diffuse_light_point/* + f_light * point_shadow * shade_frac*/) + /*water_color_ambient*/specular_light_point;
|
||||
|
||||
@ -427,4 +432,5 @@ void main() {
|
||||
vec4 color = mix(vec4(reflect_color, 1.0), vec4(vec3(0), 1.0 / (1.0 + diffuse_light * 0.25)), passthrough); */
|
||||
|
||||
tgt_color = color;
|
||||
tgt_mat = uvec4(uvec3((norm + 1.0) * 127.0), MAT_FLUID);
|
||||
}
|
||||
|
@ -52,6 +52,12 @@
|
||||
#define MEDIUM_AIR 0
|
||||
#define MEDIUM_WATER 1
|
||||
|
||||
#define MAT_SKY 0
|
||||
#define MAT_BLOCK 1
|
||||
#define MAT_FLUID 2
|
||||
#define MAT_FIGURE 3
|
||||
#define MAT_LOD 4
|
||||
|
||||
// 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
|
||||
|
@ -94,9 +94,7 @@ vec3 light_at(vec3 wpos, vec3 wnorm) {
|
||||
float shadow_at(vec3 wpos, vec3 wnorm) {
|
||||
float shadow = 1.0;
|
||||
|
||||
#if (SHADOW_MODE == SHADOW_MODE_NONE || SHADOW_MODE == SHADOW_MODE_MAP)
|
||||
return shadow;
|
||||
#elif (SHADOW_MODE == SHADOW_MODE_CHEAP)
|
||||
#if (SHADOW_MODE == SHADOW_MODE_CHEAP || (SHADOW_MODE == SHADOW_MODE_MAP && defined(EXPERIMENTAL_POINTSHADOWSWITHSHADOWMAPPING)))
|
||||
for (uint i = 0u; i < light_shadow_count.y; i ++) {
|
||||
|
||||
// Only access the array once
|
||||
@ -106,11 +104,13 @@ float shadow_at(vec3 wpos, vec3 wnorm) {
|
||||
float radius = S.shadow_pos_radius.w;
|
||||
|
||||
vec3 diff = shadow_pos - wpos;
|
||||
#if (SHADOW_MODE == SHADOW_MODE_CHEAP)
|
||||
if (diff.z >= 0.0) {
|
||||
diff.z = -sign(diff.z) * diff.z * 0.1;
|
||||
}
|
||||
#endif
|
||||
|
||||
float shade = max(pow(diff.x * diff.x + diff.y * diff.y + diff.z * diff.z, 0.35) / pow(radius * radius * 0.5, 0.5), 0.5);
|
||||
float shade = max(pow(diff.x * diff.x + diff.y * diff.y + diff.z * diff.z, 0.3) / pow(radius * radius * 0.5, 0.5), 0.5);
|
||||
// float shade = max(pow(dot(diff, diff) / (radius * radius * 0.5), 0.25), 0.5);
|
||||
// float shade = dot(diff, diff) / (radius * radius * 0.5);
|
||||
|
||||
@ -119,6 +119,8 @@ float shadow_at(vec3 wpos, vec3 wnorm) {
|
||||
// NOTE: Squared to compenate for prior saturation.
|
||||
return min(shadow, 1.0);
|
||||
// return min(shadow * shadow, 1.0);
|
||||
#else
|
||||
return shadow;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ layout(location = 3) in vec3 model_pos;
|
||||
layout(location = 4) in float snow_cover;
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
#include <sky.glsl>
|
||||
#include <light.glsl>
|
||||
@ -123,4 +124,5 @@ void main() {
|
||||
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light);
|
||||
|
||||
tgt_color = vec4(surf_color, 1.0);
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_LOD);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ layout(location = 2) in float pull_down;
|
||||
// in vec4 f_square;
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
/// const vec4 sun_pos = vec4(0);
|
||||
// const vec4 light_pos[2] = vec4[](vec4(0), vec4(0)/*, vec3(00), vec3(0), vec3(0), vec3(0)*/);
|
||||
@ -649,7 +650,9 @@ void main() {
|
||||
// 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.5) * 0.05; // Small-scale noise
|
||||
vec3 surf_color;
|
||||
float surf_alpha = 1.0;
|
||||
uint mat;
|
||||
if (length(f_col_raw - vec3(0.02, 0.06, 0.22)) < 0.025 && dot(vec3(0, 0, 1), f_norm) > 0.9) {
|
||||
mat = MAT_FLUID;
|
||||
vec3 reflect_ray = cam_to_frag * vec3(1, 1, -1);
|
||||
#if (FLUID_MODE >= FLUID_MODE_MEDIUM)
|
||||
vec3 water_color = (1.0 - MU_WATER) * MU_SCATTER;
|
||||
@ -678,6 +681,7 @@ void main() {
|
||||
surf_color = get_sky_color(reflect_ray, time_of_day.x, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac);
|
||||
#endif
|
||||
} else {
|
||||
mat = MAT_LOD;
|
||||
surf_color = illuminate(max_light, view_dir, f_col * emitted_light, f_col * reflected_light);
|
||||
}
|
||||
|
||||
@ -687,4 +691,5 @@ void main() {
|
||||
// color = surf_color;
|
||||
|
||||
tgt_color = vec4(surf_color, surf_alpha);
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), mat);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ layout(location = 2) in vec4 f_col;
|
||||
layout(location = 3) in float f_reflect;
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
#include <sky.glsl>
|
||||
#include <light.glsl>
|
||||
@ -56,9 +57,8 @@ void main() {
|
||||
#endif
|
||||
float moon_shade_frac = 1.0;
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac);
|
||||
|
||||
vec3 surf_color = f_col.rgb;
|
||||
float alpha = 1.0;
|
||||
@ -98,6 +98,10 @@ void main() {
|
||||
|
||||
max_light += lights_at(f_pos, f_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
reflected_light *= point_shadow;
|
||||
emitted_light *= point_shadow;
|
||||
|
||||
// Allow particles to glow at night
|
||||
// TODO: Not this
|
||||
emitted_light += max(f_col.rgb - 1.0, vec3(0));
|
||||
@ -106,4 +110,5 @@ void main() {
|
||||
|
||||
// Temporarily disable particle transparency to avoid artifacts
|
||||
tgt_color = vec4(surf_color, 1.0 /*f_col.a*/);
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_BLOCK);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
layout(location = 0) in vec3 f_pos;
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
void main() {
|
||||
#ifdef EXPERIMENTAL_BAREMINIMUM
|
||||
@ -56,4 +57,5 @@ void main() {
|
||||
vec3 wpos = cam_pos.xyz + /*normalize(f_pos)*/cam_dir * dist;
|
||||
|
||||
tgt_color = vec4(cam_attenuation * get_sky_color(normalize(f_pos), time_of_day.x, cam_pos.xyz, wpos, 1.0, true, refractionIndex, false, 1.0), 1.0);
|
||||
tgt_mat = uvec4(uvec3(0), MAT_SKY);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ layout(set = 2, binding = 1)
|
||||
uniform sampler s_col_light;
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
#include <sky.glsl>
|
||||
#include <light.glsl>
|
||||
@ -65,9 +66,8 @@ void main() {
|
||||
#endif
|
||||
float moon_shade_frac = 1.0;
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac);
|
||||
|
||||
vec3 surf_color = f_col;
|
||||
float alpha = 1.0;
|
||||
@ -117,13 +117,18 @@ void main() {
|
||||
emitted_light += glow * cam_attenuation;
|
||||
|
||||
float ao = f_ao;
|
||||
emitted_light *= ao;
|
||||
reflected_light *= ao;
|
||||
emitted_light *= ao;
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
reflected_light *= point_shadow;
|
||||
emitted_light *= point_shadow;
|
||||
|
||||
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light);
|
||||
|
||||
surf_color += f_select * (surf_color + 0.1) * vec3(0.15, 0.15, 0.15);
|
||||
|
||||
tgt_color = vec4(surf_color, 1.0 - clamp((distance(focus_pos.xy, f_pos.xy) - (sprite_render_distance - FADE_DIST)) / FADE_DIST, 0, 1));
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_FIGURE);
|
||||
//tgt_color = vec4(-f_norm, 1.0);
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ uniform u_locals {
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
layout(location = 1) out uvec4 tgt_mat;
|
||||
|
||||
#include <sky.glsl>
|
||||
#include <light.glsl>
|
||||
@ -320,9 +321,8 @@ void main() {
|
||||
// float shade_frac = /*1.0;*/sun_shade_frac + moon_shade_frac;
|
||||
|
||||
// DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, light_pos);
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, point_shadow * sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, point_shadow * moon_shade_frac/*, light_pos*/);
|
||||
DirectionalLight sun_info = get_sun_info(sun_dir, sun_shade_frac, /*sun_pos*/f_pos);
|
||||
DirectionalLight moon_info = get_moon_info(moon_dir, moon_shade_frac/*, light_pos*/);
|
||||
|
||||
#ifdef EXPERIMENTAL_DIRECTIONALSHADOWMAPTEXELGRID
|
||||
float offset_scale = 0.5;
|
||||
@ -401,7 +401,12 @@ void main() {
|
||||
|
||||
max_light += lights_at(f_pos, f_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
|
||||
|
||||
reflected_light *= 0.4 + f_ao * 0.6;
|
||||
emitted_light *= mix(1.0, f_ao, 0.5);
|
||||
reflected_light *= mix(1.0, f_ao, 0.5);
|
||||
|
||||
float point_shadow = shadow_at(f_pos, f_norm);
|
||||
reflected_light *= point_shadow;
|
||||
emitted_light *= point_shadow;
|
||||
|
||||
#ifndef EXPERIMENTAL_NOCAUSTICS
|
||||
#if (FLUID_MODE >= FLUID_MODE_MEDIUM)
|
||||
@ -530,5 +535,6 @@ void main() {
|
||||
surf_color += f_select * (surf_color + 0.1) * vec3(0.5, 0.5, 0.5);
|
||||
|
||||
tgt_color = vec4(surf_color, f_alpha);
|
||||
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_BLOCK);
|
||||
//tgt_color = vec4(f_norm, f_alpha);
|
||||
}
|
||||
|
@ -527,4 +527,13 @@ pub enum ExperimentalShader {
|
||||
NoRainbows,
|
||||
/// Add extra detailing to puddles.
|
||||
PuddleDetails,
|
||||
/// Show gbuffer surface normals.
|
||||
ViewNormals,
|
||||
/// Show gbuffer materials.
|
||||
ViewMaterials,
|
||||
/// Rather than fading out screen-space reflections at view space borders,
|
||||
/// smear screen space to cover the reflection vector.
|
||||
SmearReflections,
|
||||
/// Apply the point shadows from cheap shadows on top of shadow mapping.
|
||||
PointShadowsWithShadowMapping,
|
||||
}
|
||||
|
@ -88,6 +88,17 @@ impl CloudsLayout {
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
// Materials source
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 5,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Uint,
|
||||
view_dimension: wgpu::TextureViewDimension::D2,
|
||||
multisampled: false,
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}
|
||||
@ -97,6 +108,7 @@ impl CloudsLayout {
|
||||
&self,
|
||||
device: &wgpu::Device,
|
||||
src_color: &wgpu::TextureView,
|
||||
src_mat: &wgpu::TextureView,
|
||||
src_depth: &wgpu::TextureView,
|
||||
sampler: &wgpu::Sampler,
|
||||
depth_sampler: &wgpu::Sampler,
|
||||
@ -126,6 +138,10 @@ impl CloudsLayout {
|
||||
binding: 4,
|
||||
resource: locals.buf().as_entire_binding(),
|
||||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 5,
|
||||
resource: wgpu::BindingResource::TextureView(src_mat),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -130,11 +130,18 @@ impl DebugPipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::empty(),
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -233,11 +233,18 @@ impl FigurePipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -122,7 +122,8 @@ impl FluidPipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: Some(wgpu::BlendState {
|
||||
color: wgpu::BlendComponent {
|
||||
@ -137,7 +138,13 @@ impl FluidPipeline {
|
||||
},
|
||||
}),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -137,11 +137,18 @@ impl LodObjectPipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: Some(wgpu::BlendState::REPLACE),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -252,11 +252,18 @@ impl LodTerrainPipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -245,7 +245,8 @@ impl ParticlePipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
// TODO: use a constant and/or pass in this format on pipeline construction
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: Some(wgpu::BlendState {
|
||||
@ -261,7 +262,13 @@ impl ParticlePipeline {
|
||||
},
|
||||
}),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -91,7 +91,8 @@ impl SkyboxPipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: Some(wgpu::BlendState {
|
||||
color: wgpu::BlendComponent::REPLACE,
|
||||
@ -102,7 +103,13 @@ impl SkyboxPipeline {
|
||||
},
|
||||
}),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -326,7 +326,8 @@ impl SpritePipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
// TODO: can we remove sprite transparency?
|
||||
blend: Some(wgpu::BlendState {
|
||||
@ -342,7 +343,13 @@ impl SpritePipeline {
|
||||
},
|
||||
}),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -276,11 +276,18 @@ impl TerrainPipeline {
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fs_module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
},
|
||||
wgpu::ColorTargetState {
|
||||
format: wgpu::TextureFormat::Rgba8Uint,
|
||||
blend: None,
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -85,6 +85,7 @@ struct Views {
|
||||
_win_depth: wgpu::TextureView,
|
||||
|
||||
tgt_color: wgpu::TextureView,
|
||||
tgt_mat: wgpu::TextureView,
|
||||
tgt_depth: wgpu::TextureView,
|
||||
|
||||
bloom_tgts: Option<[wgpu::TextureView; bloom::NUM_SIZES]>,
|
||||
@ -480,6 +481,7 @@ impl Renderer {
|
||||
clouds_locals,
|
||||
postprocess_locals,
|
||||
&views.tgt_color,
|
||||
&views.tgt_mat,
|
||||
&views.tgt_depth,
|
||||
views.bloom_tgts.as_ref().map(|tgts| locals::BloomParams {
|
||||
locals: bloom_sizes.map(|size| {
|
||||
@ -688,6 +690,7 @@ impl Renderer {
|
||||
&self.device,
|
||||
&self.layouts,
|
||||
&self.views.tgt_color,
|
||||
&self.views.tgt_mat,
|
||||
&self.views.tgt_depth,
|
||||
bloom_params,
|
||||
&self.views.tgt_color_pp,
|
||||
@ -802,7 +805,7 @@ impl Renderer {
|
||||
let sample_count = pipeline_modes.aa.samples();
|
||||
let levels = 1;
|
||||
|
||||
let color_view = |width, height| {
|
||||
let color_view = |width, height, format| {
|
||||
let tex = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: None,
|
||||
size: wgpu::Extent3d {
|
||||
@ -813,13 +816,13 @@ impl Renderer {
|
||||
mip_level_count: levels,
|
||||
sample_count,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Rgba16Float,
|
||||
format,
|
||||
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT,
|
||||
});
|
||||
|
||||
tex.create_view(&wgpu::TextureViewDescriptor {
|
||||
label: None,
|
||||
format: Some(wgpu::TextureFormat::Rgba16Float),
|
||||
format: Some(format),
|
||||
dimension: Some(wgpu::TextureViewDimension::D2),
|
||||
// TODO: why is this not Color?
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
@ -830,8 +833,10 @@ impl Renderer {
|
||||
})
|
||||
};
|
||||
|
||||
let tgt_color_view = color_view(width, height);
|
||||
let tgt_color_pp_view = color_view(width, height);
|
||||
let tgt_color_view = color_view(width, height, wgpu::TextureFormat::Rgba16Float);
|
||||
let tgt_color_pp_view = color_view(width, height, wgpu::TextureFormat::Rgba16Float);
|
||||
|
||||
let tgt_mat_view = color_view(width, height, wgpu::TextureFormat::Rgba8Uint);
|
||||
|
||||
let mut size_shift = 0;
|
||||
// TODO: skip creating bloom stuff when it is disabled
|
||||
@ -842,10 +847,9 @@ impl Renderer {
|
||||
size
|
||||
});
|
||||
|
||||
let bloom_tgt_views = pipeline_modes
|
||||
.bloom
|
||||
.is_on()
|
||||
.then(|| bloom_sizes.map(|size| color_view(size.x, size.y)));
|
||||
let bloom_tgt_views = pipeline_modes.bloom.is_on().then(|| {
|
||||
bloom_sizes.map(|size| color_view(size.x, size.y, wgpu::TextureFormat::Rgba16Float))
|
||||
});
|
||||
|
||||
let tgt_depth_tex = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: None,
|
||||
@ -899,6 +903,7 @@ impl Renderer {
|
||||
(
|
||||
Views {
|
||||
tgt_color: tgt_color_view,
|
||||
tgt_mat: tgt_mat_view,
|
||||
tgt_depth: tgt_depth_view,
|
||||
bloom_tgts: bloom_tgt_views,
|
||||
tgt_color_pp: tgt_color_pp_view,
|
||||
|
@ -223,14 +223,24 @@ impl<'frame> Drawer<'frame> {
|
||||
let mut render_pass =
|
||||
encoder.scoped_render_pass("first_pass", device, &wgpu::RenderPassDescriptor {
|
||||
label: Some("first pass"),
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
color_attachments: &[
|
||||
wgpu::RenderPassColorAttachment {
|
||||
view: &self.borrow.views.tgt_color,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
||||
store: true,
|
||||
},
|
||||
}],
|
||||
},
|
||||
wgpu::RenderPassColorAttachment {
|
||||
view: &self.borrow.views.tgt_mat,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
||||
store: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||
view: &self.borrow.views.tgt_depth,
|
||||
depth_ops: Some(wgpu::Operations {
|
||||
|
@ -29,6 +29,7 @@ impl Locals {
|
||||
clouds_locals: Consts<clouds::Locals>,
|
||||
postprocess_locals: Consts<postprocess::Locals>,
|
||||
tgt_color_view: &wgpu::TextureView,
|
||||
tgt_mat_view: &wgpu::TextureView,
|
||||
tgt_depth_view: &wgpu::TextureView,
|
||||
bloom: Option<BloomParams>,
|
||||
tgt_color_pp_view: &wgpu::TextureView,
|
||||
@ -38,6 +39,7 @@ impl Locals {
|
||||
let clouds_bind = layouts.clouds.bind(
|
||||
device,
|
||||
tgt_color_view,
|
||||
tgt_mat_view,
|
||||
tgt_depth_view,
|
||||
sampler,
|
||||
depth_sampler,
|
||||
@ -77,6 +79,7 @@ impl Locals {
|
||||
// Call when these are recreated and need to be rebound
|
||||
// e.g. resizing
|
||||
tgt_color_view: &wgpu::TextureView,
|
||||
tgt_mat_view: &wgpu::TextureView,
|
||||
tgt_depth_view: &wgpu::TextureView,
|
||||
bloom: Option<BloomParams>,
|
||||
tgt_color_pp_view: &wgpu::TextureView,
|
||||
@ -86,6 +89,7 @@ impl Locals {
|
||||
self.clouds_bind = layouts.clouds.bind(
|
||||
device,
|
||||
tgt_color_view,
|
||||
tgt_mat_view,
|
||||
tgt_depth_view,
|
||||
sampler,
|
||||
depth_sampler,
|
||||
|
Loading…
Reference in New Issue
Block a user