diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-06-28 09:10:51 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-06-28 09:11:21 -0300 |
commit | b1aa24ea3c259fd018dde8370ef45678c7ef00ec (patch) | |
tree | fed2ea1e0b2eef9df8ac20eeb3de416246b876df /servers/rendering | |
parent | e1ef3f2da6bdfe53f08aee4e154584b14f09c0aa (diff) |
Slight occlusion improvements.
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl | 10 | ||||
-rw-r--r-- | servers/rendering/rasterizer_rd/shaders/sdfgi_preprocess.glsl | 99 |
2 files changed, 7 insertions, 102 deletions
diff --git a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl index 9a94a7914e..d6a56b2543 100644 --- a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl +++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl @@ -2519,11 +2519,15 @@ FRAGMENT_SHADER_CODE vec3(0, -1, 0), vec3(0, 0, -1)); - vec3 cam_normal = mat3(scene_data.camera_matrix) * normal; + vec3 cam_normal = mat3(scene_data.camera_matrix) * normalize(normal_interp); + + float closest_dist = -1e20; for (uint i = 0; i < 6; i++) { - if (dot(cam_normal, aniso_dir[i]) > 0.001) { - facing_bits |= (1 << i); + float d = dot(cam_normal, aniso_dir[i]); + if (d > closest_dist) { + closest_dist = d; + facing_bits = (1 << i); } } diff --git a/servers/rendering/rasterizer_rd/shaders/sdfgi_preprocess.glsl b/servers/rendering/rasterizer_rd/shaders/sdfgi_preprocess.glsl index 7a523d3a3c..d7d19897e3 100644 --- a/servers/rendering/rasterizer_rd/shaders/sdfgi_preprocess.glsl +++ b/servers/rendering/rasterizer_rd/shaders/sdfgi_preprocess.glsl @@ -655,105 +655,6 @@ void main() { groupMemoryBarrier(); barrier(); } - /* - for(int s=0;s<8;s++) { - ivec3 local_pos = pos * 2 + ((ivec3(s) >> ivec3(2,1,0)) & ivec3(1,1,1)); - for(int i=0;i<8;i++) { - ivec3 offset = local_pos + ((ivec3(i) >> ivec3(2,1,0)) & ivec3(1,1,1)) * OCCLUSION_SIZE; - - ivec3 global_offset = region_offset + offset; - - if (any(lessThan(global_offset,ivec3(0))) || any(greaterThanEqual(global_offset,ivec3(params.grid_size)))) { - continue; // do not process - } - - ivec3 proc_pos = offset - ivec3(OCCLUSION_SIZE); - proc_pos += mix(ivec3(0),ivec3(1),greaterThanEqual(proc_pos,ivec3(0))); - - ivec3 proc_abs = abs(proc_pos); - ivec3 proc_pass = proc_abs - ivec3(1); - - if (proc_pass.x+proc_pass.y+proc_pass.z != step) { - continue; - } - - offset = global_offset; - - float occ; - - uint facing = imageLoad(src_facing,offset).r; //any bit present in facing means this is solid - - if (facing != 0) { //solid - occ = 0.0; - } else if (step==0) { - occ = 1.0; //first step - } else { - ivec3 read_dir = -sign(proc_pos); - - ivec3 major_axis; - if (proc_pass.x < proc_pass.y) { - if (proc_pass.z < proc_pass.y) { - major_axis = ivec3(0,1,0); - } else { - major_axis = ivec3(0,0,1); - } - } else { - if (proc_pass.z < proc_pass.x) { - major_axis = ivec3(1,0,0); - } else { - major_axis = ivec3(0,0,1); - } - } - - float avg = 0.0; - occ = 0.0; - - ivec3 read_x = offset + ivec3(read_dir.x,0,0) + (proc_pass.x == 0 ? major_axis * read_dir : ivec3(0)); - ivec3 read_y = offset + ivec3(0,read_dir.y,0) + (proc_pass.y == 0 ? major_axis * read_dir : ivec3(0)); - ivec3 read_z = offset + ivec3(0,0,read_dir.z) + (proc_pass.z == 0 ? major_axis * read_dir : ivec3(0)); - - if (all(greaterThanEqual(read_x,ivec3(0))) && all(lessThan(read_x,ivec3(params.grid_size)))) { - - uint f = imageLoad(src_facing,read_x).r; - if (f==0) { //non solid - occ += imageLoad(dst_occlusion[params.occlusion_index],read_x).r; - avg+=1.0; - } - } - - if (all(greaterThanEqual(read_y,ivec3(0))) && all(lessThan(read_y,ivec3(params.grid_size)))) { - - uint f = imageLoad(src_facing,read_y).r; - if (f==0) {//non solid - occ += imageLoad(dst_occlusion[params.occlusion_index],read_y).r; - avg+=1.0; - } - } - - if (all(greaterThanEqual(read_z,ivec3(0))) && all(lessThan(read_z,ivec3(params.grid_size)))) { - - uint f = imageLoad(src_facing,read_z).r; - if (f==0) {//non solid - occ += imageLoad(dst_occlusion[params.occlusion_index],read_z).r; - avg+=1.0; - } - } - - if (avg > 0.0) { - occ/=avg; - } - } - - imageStore(dst_occlusion[params.occlusion_index],offset,vec4(occ)); - - } - } - - groupMemoryBarrier(); - barrier(); - - } -*/ #if 1 //bias solid voxels away |