Commit f5c07191 authored by Florian Oetke's avatar Florian Oetke
Browse files

implemented more efficent position-reconstruction; removed almost all aliasing...

implemented more efficent position-reconstruction; removed almost all aliasing (fixed TAA); tweaked GI
parent f9699a0c
......@@ -25,7 +25,7 @@ vec3 calculate_gi(vec2 uv, vec3 radiance, vec3 specular,
vec3 N = decode_normal(mat_data.rg);
float depth = textureLod(depth_sampler, uv, 0.0).r;
vec3 P = depth * vertex_out.view_ray;
vec3 P = position_from_ldepth(vertex_out.tex_coords, depth);
vec3 V = -normalize(P);
float NdotV = clamp(dot(N, V), 0.0, 1.0);
......
......@@ -41,7 +41,7 @@ void main() {
float depth = textureLod(depth_sampler, vertex_out.tex_coords, 0.0).r;
vec3 pos = depth * vertex_out.view_ray;
vec3 pos = position_from_ldepth(vertex_out.tex_coords, depth);
mat4 prev_projection = pcs.prev_projection;
prev_projection[0][3] = 0;
......@@ -65,7 +65,26 @@ void main() {
out_specular = vec4(0, 0, 0, 1);
out_weight = vec4(0, 0, 0, 1);
if(prev_uv.x>0.0 && prev_uv.x<1.0 && prev_uv.y>0.0 && prev_uv.y<1.0) {
float global_weight = 1.0;
if(prev_uv.x<0) {
global_weight *= 1 + prev_uv.x*20.0;
prev_uv.x = 0;
} else if(prev_uv.x>1) {
global_weight *= 1 + (prev_uv.x-1)*20.0;
prev_uv.x = 1;
}
if(prev_uv.y<0) {
global_weight *= 1 + prev_uv.y*20.0;
prev_uv.y = 0;
} else if(prev_uv.x>1) {
global_weight *= 1 + (prev_uv.y-1)*20.0;
prev_uv.y = 1;
}
global_weight = clamp(global_weight, 0, 1);
if(prev_uv.x>=0.0 && prev_uv.x<=1.0 && prev_uv.y>=0.0 && prev_uv.y<=1.0) {
// load diff + spec GI
vec3 radiance = upsampled_result(prev_depth_sampler, mat_data_sampler, history_diff_sampler, 0, 0, prev_uv.xy, 1.0).rgb;
vec3 specular = upsampled_result(prev_depth_sampler, mat_data_sampler, history_spec_sampler, 0, 0, prev_uv.xy, 1.0).rgb;
......@@ -83,7 +102,7 @@ void main() {
float prev_depth = textureLod(prev_depth_sampler, prev_uv.xy, 0.0).r * global_uniforms.proj_planes.y;
out_diffuse.rgb = radiance;
out_specular.rgb = specular;
out_weight.r = 1.0 - smoothstep(0.005, 0.1, abs(prev_depth-proj_prev_depth));
out_weight.r = (1.0 - smoothstep(0.005, 0.1, abs(prev_depth-proj_prev_depth))) * global_weight;
out_input *= out_weight.r;
}
}
......@@ -88,7 +88,7 @@ vec3 gi_sample(int lod) {
vec4 mat_data = texelFetch(mat_data_sampler, uv, 0);
vec3 N = decode_normal(mat_data.rg);
vec3 P = depth * vertex_out.view_ray;
vec3 P = position_from_ldepth(vertex_out.tex_coords, depth);
vec3 c = vec3(0,0,0);
float samples_used = 0.0;
......@@ -143,7 +143,7 @@ vec3 to_view_space(vec2 uv, float depth) {
vec3 calc_illumination_from(int lod, vec2 tex_size, ivec2 src_uv, vec2 shaded_uv, float shaded_depth,
vec3 shaded_point, vec3 shaded_normal, out float weight) {
float depth = texelFetch(depth_sampler, src_uv, 0).r;
vec3 P = to_view_space(src_uv / tex_size, depth);// x_i
vec3 P = position_from_ldepth(src_uv / tex_size, depth);// x_i
vec3 Pn = normalize(P);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment