mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use normal and material gbuffer to improve quality of SSR
This commit is contained in:
parent
0052af85bc
commit
26a98a3d9b
@ -46,6 +46,9 @@ uniform u_locals {
|
|||||||
mat4 all_mat_inv;
|
mat4 all_mat_inv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
layout(set = 2, binding = 5)
|
||||||
|
uniform utexture2D t_src_mat;
|
||||||
|
|
||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
|
||||||
vec3 wpos_at(vec2 uv) {
|
vec3 wpos_at(vec2 uv) {
|
||||||
@ -79,6 +82,14 @@ float depth_at(vec2 uv) {
|
|||||||
void main() {
|
void main() {
|
||||||
vec4 color = texture(sampler2D(t_src_color, s_src_color), uv);
|
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
|
||||||
|
color.rgb = vec3(mat.xyz) / 255.0;
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_BAREMINIMUM
|
#ifdef EXPERIMENTAL_BAREMINIMUM
|
||||||
tgt_color = vec4(color.rgb, 1);
|
tgt_color = vec4(color.rgb, 1);
|
||||||
return;
|
return;
|
||||||
@ -126,8 +137,8 @@ void main() {
|
|||||||
cloud_blend = 1.0 - color.a;
|
cloud_blend = 1.0 - color.a;
|
||||||
|
|
||||||
#if (FLUID_MODE >= FLUID_MODE_MEDIUM || REFLECTION_MODE >= REFLECTION_MODE_MEDIUM)
|
#if (FLUID_MODE >= FLUID_MODE_MEDIUM || REFLECTION_MODE >= REFLECTION_MODE_MEDIUM)
|
||||||
if (dir.z < 0.0) {
|
if (mat.a != MAT_SKY) {
|
||||||
vec3 surf_norm = normalize(vec3(nz * 0.3 / (1.0 + dist * 0.1), 1));
|
vec3 surf_norm = vec3(texelFetch(usampler2D(t_src_mat, s_src_depth), clamp(ivec2(uv * mat_sz), ivec2(0), ivec2(mat_sz) - 1), 0).xyz) / 127.0 - 1.0;
|
||||||
vec3 refl_dir = reflect(dir, surf_norm);
|
vec3 refl_dir = reflect(dir, surf_norm);
|
||||||
|
|
||||||
vec4 clip = (all_mat * vec4(cam_pos.xyz + refl_dir, 1.0));
|
vec4 clip = (all_mat * vec4(cam_pos.xyz + refl_dir, 1.0));
|
||||||
@ -180,11 +191,27 @@ void main() {
|
|||||||
clamp((new_dist - dist * 0.5) / (dist * 0.5), 0.0, 1.0)
|
clamp((new_dist - dist * 0.5) / (dist * 0.5), 0.0, 1.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
vec3 refl_col;
|
||||||
|
// Did we hit a surface during reflection?
|
||||||
if (merge > 0.0) {
|
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;
|
// Yes: grab the new material from screen space
|
||||||
new_col = get_cloud_color(new_col.rgb, refl_dir, wpos, time_of_day.x, distance(new_wpos, wpos.xyz), 1.0);
|
uvec4 new_mat = texelFetch(usampler2D(t_src_mat, s_src_depth), clamp(ivec2(new_uv * col_sz), ivec2(0), ivec2(col_sz) - 1), 0);
|
||||||
color.rgb = mix(color.rgb, new_col, min(merge * (color.a * 2.0), 0.75));
|
// 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
|
||||||
|
if (new_mat.a == MAT_SKY) {
|
||||||
|
refl_col = get_sky_color(refl_dir, time_of_day.x, wpos, vec3(-100000), 0.125, true, 1.0, true, 1.0);
|
||||||
|
} else {
|
||||||
|
refl_col = texelFetch(sampler2D(t_src_color, s_src_color), clamp(ivec2(new_uv * col_sz), ivec2(0), ivec2(col_sz) - 1), 0).rgb;
|
||||||
}
|
}
|
||||||
|
// Apply clouds to reflected colour
|
||||||
|
refl_col = get_cloud_color(refl_col, refl_dir, wpos, time_of_day.x, distance(new_wpos, wpos.xyz), 1.0);
|
||||||
|
} 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 - focus_off.xyz, vec3(-100000), 0.125, true, 1.0, true, 1.0), vec3(1));
|
||||||
|
// Apply clouds to reflection
|
||||||
|
refl_col = get_cloud_color(refl_col, refl_dir, wpos, time_of_day.x, 100000.0, 1.0);
|
||||||
|
}
|
||||||
|
color.rgb = mix(color.rgb, refl_col, min(color.a * 2.0, 0.75));
|
||||||
cloud_blend = 1;
|
cloud_blend = 1;
|
||||||
} else {
|
} else {
|
||||||
#else
|
#else
|
||||||
|
@ -83,6 +83,7 @@ uniform u_bones {
|
|||||||
};
|
};
|
||||||
|
|
||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// vec2 texSize = textureSize(t_col_light, 0);
|
// vec2 texSize = textureSize(t_col_light, 0);
|
||||||
@ -299,4 +300,5 @@ void main() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
tgt_color = vec4(surf_color, 1.0);
|
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 = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
#include <sky.glsl>
|
#include <sky.glsl>
|
||||||
#include <light.glsl>
|
#include <light.glsl>
|
||||||
@ -238,4 +239,5 @@ void main() {
|
|||||||
vec4 color = vec4(surf_color, opacity);
|
vec4 color = vec4(surf_color, opacity);
|
||||||
|
|
||||||
tgt_color = color;
|
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 = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
#include <cloud.glsl>
|
#include <cloud.glsl>
|
||||||
#include <light.glsl>
|
#include <light.glsl>
|
||||||
@ -82,14 +83,14 @@ vec4 wave_height(vec4 posx, vec4 posy) {
|
|||||||
posy *= 0.2;
|
posy *= 0.2;
|
||||||
const float drag_factor = 0.035;
|
const float drag_factor = 0.035;
|
||||||
const int iters = 21;
|
const int iters = 21;
|
||||||
const float scale = 25.0;
|
const float scale = 15.0;
|
||||||
#else
|
#else
|
||||||
float speed = 2.0;
|
float speed = 2.0;
|
||||||
posx *= 0.3;
|
posx *= 0.3;
|
||||||
posy *= 0.3;
|
posy *= 0.3;
|
||||||
const float drag_factor = 0.04;
|
const float drag_factor = 0.04;
|
||||||
const int iters = 11;
|
const int iters = 11;
|
||||||
const float scale = 5.0;
|
const float scale = 3.0;
|
||||||
#endif
|
#endif
|
||||||
const float iter_shift = (3.14159 * 2.0) / 7.3;
|
const float iter_shift = (3.14159 * 2.0) / 7.3;
|
||||||
|
|
||||||
@ -427,4 +428,5 @@ void main() {
|
|||||||
vec4 color = mix(vec4(reflect_color, 1.0), vec4(vec3(0), 1.0 / (1.0 + diffuse_light * 0.25)), passthrough); */
|
vec4 color = mix(vec4(reflect_color, 1.0), vec4(vec3(0), 1.0 / (1.0 + diffuse_light * 0.25)), passthrough); */
|
||||||
|
|
||||||
tgt_color = color;
|
tgt_color = color;
|
||||||
|
tgt_mat = uvec4(uvec3((norm + 1.0) * 127.0), MAT_FLUID);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,12 @@
|
|||||||
#define MEDIUM_AIR 0
|
#define MEDIUM_AIR 0
|
||||||
#define MEDIUM_WATER 1
|
#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
|
// 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).
|
// being too far that we end up with precision issues (used in clouds and elsewhere).
|
||||||
#define DIST_CAP 50000
|
#define DIST_CAP 50000
|
||||||
|
@ -25,6 +25,7 @@ layout(location = 3) in vec3 model_pos;
|
|||||||
layout(location = 4) in float snow_cover;
|
layout(location = 4) in float snow_cover;
|
||||||
|
|
||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
#include <sky.glsl>
|
#include <sky.glsl>
|
||||||
#include <light.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);
|
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light);
|
||||||
|
|
||||||
tgt_color = vec4(surf_color, 1.0);
|
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;
|
// in vec4 f_square;
|
||||||
|
|
||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
/// const vec4 sun_pos = vec4(0);
|
/// const vec4 sun_pos = vec4(0);
|
||||||
// const vec4 light_pos[2] = vec4[](vec4(0), vec4(0)/*, vec3(00), vec3(0), vec3(0), vec3(0)*/);
|
// const vec4 light_pos[2] = vec4[](vec4(0), vec4(0)/*, vec3(00), vec3(0), vec3(0), vec3(0)*/);
|
||||||
@ -687,4 +688,5 @@ void main() {
|
|||||||
// color = surf_color;
|
// color = surf_color;
|
||||||
|
|
||||||
tgt_color = vec4(surf_color, surf_alpha);
|
tgt_color = vec4(surf_color, surf_alpha);
|
||||||
|
tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_LOD);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ layout(location = 2) in vec4 f_col;
|
|||||||
layout(location = 3) in float f_reflect;
|
layout(location = 3) in float f_reflect;
|
||||||
|
|
||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
#include <sky.glsl>
|
#include <sky.glsl>
|
||||||
#include <light.glsl>
|
#include <light.glsl>
|
||||||
@ -106,4 +107,5 @@ void main() {
|
|||||||
|
|
||||||
// Temporarily disable particle transparency to avoid artifacts
|
// Temporarily disable particle transparency to avoid artifacts
|
||||||
tgt_color = vec4(surf_color, 1.0 /*f_col.a*/);
|
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) in vec3 f_pos;
|
||||||
|
|
||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
#ifdef EXPERIMENTAL_BAREMINIMUM
|
#ifdef EXPERIMENTAL_BAREMINIMUM
|
||||||
@ -56,4 +57,5 @@ void main() {
|
|||||||
vec3 wpos = cam_pos.xyz + /*normalize(f_pos)*/cam_dir * dist;
|
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_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;
|
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;
|
||||||
|
|
||||||
#include <sky.glsl>
|
#include <sky.glsl>
|
||||||
#include <light.glsl>
|
#include <light.glsl>
|
||||||
@ -125,5 +126,6 @@ void main() {
|
|||||||
surf_color += f_select * (surf_color + 0.1) * vec3(0.15, 0.15, 0.15);
|
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_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);
|
//tgt_color = vec4(-f_norm, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ uniform u_locals {
|
|||||||
};
|
};
|
||||||
|
|
||||||
layout(location = 0) out vec4 tgt_color;
|
layout(location = 0) out vec4 tgt_color;
|
||||||
|
layout(location = 1) out uvec4 tgt_mat;
|
||||||
|
|
||||||
#include <sky.glsl>
|
#include <sky.glsl>
|
||||||
#include <light.glsl>
|
#include <light.glsl>
|
||||||
@ -530,5 +531,6 @@ void main() {
|
|||||||
surf_color += f_select * (surf_color + 0.1) * vec3(0.5, 0.5, 0.5);
|
surf_color += f_select * (surf_color + 0.1) * vec3(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
tgt_color = vec4(surf_color, f_alpha);
|
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);
|
//tgt_color = vec4(f_norm, f_alpha);
|
||||||
}
|
}
|
||||||
|
@ -527,4 +527,6 @@ pub enum ExperimentalShader {
|
|||||||
NoRainbows,
|
NoRainbows,
|
||||||
/// Add extra detailing to puddles.
|
/// Add extra detailing to puddles.
|
||||||
PuddleDetails,
|
PuddleDetails,
|
||||||
|
/// Show the normal buffers.
|
||||||
|
ViewNormals,
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,17 @@ impl CloudsLayout {
|
|||||||
},
|
},
|
||||||
count: None,
|
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,
|
&self,
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
src_color: &wgpu::TextureView,
|
src_color: &wgpu::TextureView,
|
||||||
|
src_mat: &wgpu::TextureView,
|
||||||
src_depth: &wgpu::TextureView,
|
src_depth: &wgpu::TextureView,
|
||||||
sampler: &wgpu::Sampler,
|
sampler: &wgpu::Sampler,
|
||||||
depth_sampler: &wgpu::Sampler,
|
depth_sampler: &wgpu::Sampler,
|
||||||
@ -126,6 +138,10 @@ impl CloudsLayout {
|
|||||||
binding: 4,
|
binding: 4,
|
||||||
resource: locals.buf().as_entire_binding(),
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: None,
|
blend: None,
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: Some(wgpu::BlendState {
|
blend: Some(wgpu::BlendState {
|
||||||
color: wgpu::BlendComponent {
|
color: wgpu::BlendComponent {
|
||||||
@ -137,7 +138,13 @@ impl FluidPipeline {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: Some(wgpu::BlendState::REPLACE),
|
blend: Some(wgpu::BlendState::REPLACE),
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: None,
|
blend: None,
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
// TODO: use a constant and/or pass in this format on pipeline construction
|
// TODO: use a constant and/or pass in this format on pipeline construction
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: Some(wgpu::BlendState {
|
blend: Some(wgpu::BlendState {
|
||||||
@ -261,7 +262,13 @@ impl ParticlePipeline {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: Some(wgpu::BlendState {
|
blend: Some(wgpu::BlendState {
|
||||||
color: wgpu::BlendComponent::REPLACE,
|
color: wgpu::BlendComponent::REPLACE,
|
||||||
@ -102,7 +103,13 @@ impl SkyboxPipeline {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
write_mask: wgpu::ColorWrite::ALL,
|
||||||
}],
|
},
|
||||||
|
wgpu::ColorTargetState {
|
||||||
|
format: wgpu::TextureFormat::Rgba8Uint,
|
||||||
|
blend: None,
|
||||||
|
write_mask: wgpu::ColorWrite::ALL,
|
||||||
|
},
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -325,7 +325,8 @@ impl SpritePipeline {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
// TODO: can we remove sprite transparency?
|
// TODO: can we remove sprite transparency?
|
||||||
blend: Some(wgpu::BlendState {
|
blend: Some(wgpu::BlendState {
|
||||||
@ -341,7 +342,13 @@ impl SpritePipeline {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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 {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[
|
||||||
|
wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
blend: None,
|
blend: None,
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
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,
|
_win_depth: wgpu::TextureView,
|
||||||
|
|
||||||
tgt_color: wgpu::TextureView,
|
tgt_color: wgpu::TextureView,
|
||||||
|
tgt_mat: wgpu::TextureView,
|
||||||
tgt_depth: wgpu::TextureView,
|
tgt_depth: wgpu::TextureView,
|
||||||
|
|
||||||
bloom_tgts: Option<[wgpu::TextureView; bloom::NUM_SIZES]>,
|
bloom_tgts: Option<[wgpu::TextureView; bloom::NUM_SIZES]>,
|
||||||
@ -480,6 +481,7 @@ impl Renderer {
|
|||||||
clouds_locals,
|
clouds_locals,
|
||||||
postprocess_locals,
|
postprocess_locals,
|
||||||
&views.tgt_color,
|
&views.tgt_color,
|
||||||
|
&views.tgt_mat,
|
||||||
&views.tgt_depth,
|
&views.tgt_depth,
|
||||||
views.bloom_tgts.as_ref().map(|tgts| locals::BloomParams {
|
views.bloom_tgts.as_ref().map(|tgts| locals::BloomParams {
|
||||||
locals: bloom_sizes.map(|size| {
|
locals: bloom_sizes.map(|size| {
|
||||||
@ -688,6 +690,7 @@ impl Renderer {
|
|||||||
&self.device,
|
&self.device,
|
||||||
&self.layouts,
|
&self.layouts,
|
||||||
&self.views.tgt_color,
|
&self.views.tgt_color,
|
||||||
|
&self.views.tgt_mat,
|
||||||
&self.views.tgt_depth,
|
&self.views.tgt_depth,
|
||||||
bloom_params,
|
bloom_params,
|
||||||
&self.views.tgt_color_pp,
|
&self.views.tgt_color_pp,
|
||||||
@ -802,7 +805,7 @@ impl Renderer {
|
|||||||
let sample_count = pipeline_modes.aa.samples();
|
let sample_count = pipeline_modes.aa.samples();
|
||||||
let levels = 1;
|
let levels = 1;
|
||||||
|
|
||||||
let color_view = |width, height| {
|
let color_view = |width, height, format| {
|
||||||
let tex = device.create_texture(&wgpu::TextureDescriptor {
|
let tex = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
size: wgpu::Extent3d {
|
size: wgpu::Extent3d {
|
||||||
@ -813,13 +816,13 @@ impl Renderer {
|
|||||||
mip_level_count: levels,
|
mip_level_count: levels,
|
||||||
sample_count,
|
sample_count,
|
||||||
dimension: wgpu::TextureDimension::D2,
|
dimension: wgpu::TextureDimension::D2,
|
||||||
format: wgpu::TextureFormat::Rgba16Float,
|
format,
|
||||||
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT,
|
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT,
|
||||||
});
|
});
|
||||||
|
|
||||||
tex.create_view(&wgpu::TextureViewDescriptor {
|
tex.create_view(&wgpu::TextureViewDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
format: Some(wgpu::TextureFormat::Rgba16Float),
|
format: Some(format),
|
||||||
dimension: Some(wgpu::TextureViewDimension::D2),
|
dimension: Some(wgpu::TextureViewDimension::D2),
|
||||||
// TODO: why is this not Color?
|
// TODO: why is this not Color?
|
||||||
aspect: wgpu::TextureAspect::All,
|
aspect: wgpu::TextureAspect::All,
|
||||||
@ -830,8 +833,10 @@ impl Renderer {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
let tgt_color_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);
|
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;
|
let mut size_shift = 0;
|
||||||
// TODO: skip creating bloom stuff when it is disabled
|
// TODO: skip creating bloom stuff when it is disabled
|
||||||
@ -842,10 +847,9 @@ impl Renderer {
|
|||||||
size
|
size
|
||||||
});
|
});
|
||||||
|
|
||||||
let bloom_tgt_views = pipeline_modes
|
let bloom_tgt_views = pipeline_modes.bloom.is_on().then(|| {
|
||||||
.bloom
|
bloom_sizes.map(|size| color_view(size.x, size.y, wgpu::TextureFormat::Rgba16Float))
|
||||||
.is_on()
|
});
|
||||||
.then(|| bloom_sizes.map(|size| color_view(size.x, size.y)));
|
|
||||||
|
|
||||||
let tgt_depth_tex = device.create_texture(&wgpu::TextureDescriptor {
|
let tgt_depth_tex = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
@ -899,6 +903,7 @@ impl Renderer {
|
|||||||
(
|
(
|
||||||
Views {
|
Views {
|
||||||
tgt_color: tgt_color_view,
|
tgt_color: tgt_color_view,
|
||||||
|
tgt_mat: tgt_mat_view,
|
||||||
tgt_depth: tgt_depth_view,
|
tgt_depth: tgt_depth_view,
|
||||||
bloom_tgts: bloom_tgt_views,
|
bloom_tgts: bloom_tgt_views,
|
||||||
tgt_color_pp: tgt_color_pp_view,
|
tgt_color_pp: tgt_color_pp_view,
|
||||||
|
@ -223,14 +223,24 @@ impl<'frame> Drawer<'frame> {
|
|||||||
let mut render_pass =
|
let mut render_pass =
|
||||||
encoder.scoped_render_pass("first_pass", device, &wgpu::RenderPassDescriptor {
|
encoder.scoped_render_pass("first_pass", device, &wgpu::RenderPassDescriptor {
|
||||||
label: Some("first pass"),
|
label: Some("first pass"),
|
||||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
color_attachments: &[
|
||||||
|
wgpu::RenderPassColorAttachment {
|
||||||
view: &self.borrow.views.tgt_color,
|
view: &self.borrow.views.tgt_color,
|
||||||
resolve_target: None,
|
resolve_target: None,
|
||||||
ops: wgpu::Operations {
|
ops: wgpu::Operations {
|
||||||
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
||||||
store: true,
|
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 {
|
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||||
view: &self.borrow.views.tgt_depth,
|
view: &self.borrow.views.tgt_depth,
|
||||||
depth_ops: Some(wgpu::Operations {
|
depth_ops: Some(wgpu::Operations {
|
||||||
|
@ -29,6 +29,7 @@ impl Locals {
|
|||||||
clouds_locals: Consts<clouds::Locals>,
|
clouds_locals: Consts<clouds::Locals>,
|
||||||
postprocess_locals: Consts<postprocess::Locals>,
|
postprocess_locals: Consts<postprocess::Locals>,
|
||||||
tgt_color_view: &wgpu::TextureView,
|
tgt_color_view: &wgpu::TextureView,
|
||||||
|
tgt_mat_view: &wgpu::TextureView,
|
||||||
tgt_depth_view: &wgpu::TextureView,
|
tgt_depth_view: &wgpu::TextureView,
|
||||||
bloom: Option<BloomParams>,
|
bloom: Option<BloomParams>,
|
||||||
tgt_color_pp_view: &wgpu::TextureView,
|
tgt_color_pp_view: &wgpu::TextureView,
|
||||||
@ -38,6 +39,7 @@ impl Locals {
|
|||||||
let clouds_bind = layouts.clouds.bind(
|
let clouds_bind = layouts.clouds.bind(
|
||||||
device,
|
device,
|
||||||
tgt_color_view,
|
tgt_color_view,
|
||||||
|
tgt_mat_view,
|
||||||
tgt_depth_view,
|
tgt_depth_view,
|
||||||
sampler,
|
sampler,
|
||||||
depth_sampler,
|
depth_sampler,
|
||||||
@ -77,6 +79,7 @@ impl Locals {
|
|||||||
// Call when these are recreated and need to be rebound
|
// Call when these are recreated and need to be rebound
|
||||||
// e.g. resizing
|
// e.g. resizing
|
||||||
tgt_color_view: &wgpu::TextureView,
|
tgt_color_view: &wgpu::TextureView,
|
||||||
|
tgt_mat_view: &wgpu::TextureView,
|
||||||
tgt_depth_view: &wgpu::TextureView,
|
tgt_depth_view: &wgpu::TextureView,
|
||||||
bloom: Option<BloomParams>,
|
bloom: Option<BloomParams>,
|
||||||
tgt_color_pp_view: &wgpu::TextureView,
|
tgt_color_pp_view: &wgpu::TextureView,
|
||||||
@ -86,6 +89,7 @@ impl Locals {
|
|||||||
self.clouds_bind = layouts.clouds.bind(
|
self.clouds_bind = layouts.clouds.bind(
|
||||||
device,
|
device,
|
||||||
tgt_color_view,
|
tgt_color_view,
|
||||||
|
tgt_mat_view,
|
||||||
tgt_depth_view,
|
tgt_depth_view,
|
||||||
sampler,
|
sampler,
|
||||||
depth_sampler,
|
depth_sampler,
|
||||||
|
Loading…
Reference in New Issue
Block a user