Skip to content

Commit

Permalink
optimized lighting partically works
Browse files Browse the repository at this point in the history
  • Loading branch information
LifeKILLED committed Jan 5, 2024
1 parent 0bc585e commit 9aa9c7c
Show file tree
Hide file tree
Showing 21 changed files with 1,746 additions and 24 deletions.
37 changes: 37 additions & 0 deletions ref/vk/shaders/lk_dnsr_blue_noise.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#version 460

#include "noise.glsl"
#include "utils.glsl"
#include "color_spaces.glsl"
#include "lk_dnsr_utils.glsl"

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

layout(set = 0, binding = 0, rgba16f) uniform writeonly image2D out_blue_noise;

#define GLSL
#include "ray_interop.h"
#undef GLSL

layout(set = 0, binding = 1) uniform UBO { UniformBuffer ubo; } ubo;
layout(set = 0, binding = 2) uniform sampler2D textures[MAX_TEXTURES];

layout(set = 0, binding = 3) uniform sampler3D blue_noise_texture;

#include "bluenoise.glsl"

void main() {
ivec2 res = ivec2(imageSize(out_blue_noise));
ivec2 pix = ivec2(gl_GlobalInvocationID);

if (any(greaterThanEqual(pix, res))) {
return;
}

const ivec2 out_pix = pix; // need a checkerboard?

vec4 blue_noise = blueNoise(ivec3(pix.xy, ubo.ubo.frame_counter));
blue_noise += blue_noise.yzwx / 256. + blue_noise.zwxy / (256. * 256.); // add extra details up to 16 bits

imageStore(out_blue_noise, out_pix, FIX_NAN(blue_noise));
}
11 changes: 11 additions & 0 deletions ref/vk/shaders/lk_dnsr_config.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

// not plane, it's sphere, but working
#define NEAR_PLANE_OFFSET 5.

// we downsample gi map and store bounces positions in neighboor texels
// downsample image dimensions by 2 = store 4 bounces
// downsample image dimensions by 3 = store 9 bounces
#define GI_DOWNSAMPLE 2

// max bounces for testing bounces visiblity
#define GI_BOUNCES_MAX 1
26 changes: 26 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_direct_poly_choose.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_ray_query: require
#extension GL_EXT_shader_atomic_float: require
#extension GL_EXT_shader_16bit_storage : require

#define RAY_QUERY

#define PRIMARY_VIEW 1

#define SRC_FIRST_POSITION refl_position_t
#define SRC_POSITION position_t
#define SRC_NORMALS normals_gs
#define SRC_MATERIAL material_rmxx
#define SRC_BASE_COLOR base_color_a

#define LIGHT_CHOOSE_PASS 1
#define OUT_LIGHTING out_light_poly_chosen_direct

#define LIGHT_POLYGON 1
#define GRAY_MATERIAL 1

//#define MAX_LIGHTS_PER_TEXEL 32
//#define ONE_LIGHT_PER_TEXEL 1

#include "lk_dnsr_lights_adaptive.glsl"
30 changes: 30 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_direct_poly_sample.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_ray_query: require
#extension GL_EXT_shader_atomic_float: require
#extension GL_EXT_shader_16bit_storage : require

#define RAY_QUERY

#define PRIMARY_VIEW 1

#define SRC_FIRST_POSITION refl_position_t
#define SRC_POSITION position_t
#define SRC_NORMALS normals_gs
#define SRC_MATERIAL material_rmxx
#define SRC_BASE_COLOR base_color_a

#define OUT_SEPARATELY 1

#define OUT_DIFFUSE out_light_poly_diffuse
#define OUT_SPECULAR out_light_poly_specular

#define LIGHT_SAMPLE_PASS 1
#define SRC_LIGHTS_CHOSEN light_poly_chosen_direct

#define LIGHT_POLYGON 1
#define GRAY_MATERIAL 1
//#define MAX_LIGHTS_PER_TEXEL 32
//#define ONE_LIGHT_PER_TEXEL 1

#include "lk_dnsr_lights_adaptive.glsl"
22 changes: 22 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_gi_point.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_shader_16bit_storage : require
#extension GL_EXT_ray_query: require

#define GLOBAL_ILLUMINATION 1

#define SRC_FIRST_POSITION position_t
#define SRC_POSITION gi_position_t
#define SRC_NORMALS gi_normals_gs
#define SRC_MATERIAL material_rmxx
#define SRC_BASE_COLOR gi_base_color_a

#define OUT_LIGHTING out_light_point_gi

#define ADAPT_LIGHTS_COUNT 1

//#define ONE_LIGHT_PER_TEXEL 1

#define RAY_QUERY
#define LIGHT_POINT 1
#include "lk_dnsr_lights_direct.glsl"
20 changes: 20 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_gi_poly.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_shader_16bit_storage : require
#extension GL_EXT_ray_query: require

#define GLOBAL_ILLUMINATION 1

#define SRC_FIRST_POSITION gi_prev_bounce_pos
#define SRC_POSITION gi_position_t
#define SRC_NORMALS gi_normals_gs
#define SRC_MATERIAL material_rmxx
#define SRC_BASE_COLOR gi_base_color_a

#define OUT_LIGHTING out_light_poly_gi

//#define ONE_LIGHT_PER_TEXEL 1

#define RAY_QUERY
#define LIGHT_POLYGON 1
#include "lk_dnsr_lights_direct.glsl"
25 changes: 25 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_gi_poly_choose.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_ray_query: require
#extension GL_EXT_shader_atomic_float: require
#extension GL_EXT_shader_16bit_storage : require

#define RAY_QUERY

#define GLOBAL_ILLUMINATION 1

#define SRC_FIRST_POSITION position_t
#define SRC_POSITION gi_position_t
#define SRC_NORMALS gi_normals_gs
#define SRC_MATERIAL material_rmxx
#define SRC_BASE_COLOR gi_base_color_a

#define LIGHT_CHOOSE_PASS 1
#define OUT_LIGHTING out_light_poly_chosen_gi

#define LIGHT_POLYGON 1


//#define ONE_LIGHT_PER_TEXEL 1

#include "lk_dnsr_lights_adaptive.glsl"
25 changes: 25 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_gi_poly_sample.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_ray_query: require
#extension GL_EXT_shader_atomic_float: require
#extension GL_EXT_shader_16bit_storage : require

#define RAY_QUERY

#define GLOBAL_ILLUMINATION 1

#define SRC_FIRST_POSITION position_t
#define SRC_POSITION gi_position_t
#define SRC_NORMALS gi_normals_gs
#define SRC_MATERIAL material_rmxx
#define SRC_BASE_COLOR gi_base_color_a

#define OUT_LIGHTING out_light_poly_gi

#define LIGHT_SAMPLE_PASS 1
#define SRC_LIGHTS_CHOSEN light_poly_chosen_gi

#define LIGHT_POLYGON 1
//#define ONE_LIGHT_PER_TEXEL 1

#include "lk_dnsr_lights_adaptive.glsl"
24 changes: 24 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_refl_point.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_shader_16bit_storage : require
#extension GL_EXT_ray_query: require

#define REFLECTIONS 1

#define SRC_FIRST_POSITION position_t
#define SRC_POSITION refl_position_t
#define SRC_NORMALS refl_normals_gs
#define SRC_MATERIAL refl_material_rmxx
#define SRC_BASE_COLOR refl_base_color_a

#define OUT_LIGHTING out_light_point_refl

#define ADAPT_LIGHTS_COUNT 1

//#define MAX_LIGHTS_PER_TEXEL 32
//#define REUSE_SCREEN_LIGHTING 1
//#define ONE_LIGHT_PER_TEXEL 1

#define RAY_QUERY
#define LIGHT_POINT 1
#include "lk_dnsr_lights_direct.glsl"
24 changes: 24 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_refl_poly.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_shader_16bit_storage : require
#extension GL_EXT_ray_query: require

#define REFLECTIONS 1

#define SRC_FIRST_POSITION position_t
#define SRC_POSITION refl_position_t
#define SRC_NORMALS refl_normals_gs
#define SRC_MATERIAL refl_material_rmxx
#define SRC_BASE_COLOR refl_base_color_a

#define OUT_LIGHTING out_light_poly_refl

//#define REUSE_SCREEN_LIGHTING 1

//#define MAX_LIGHTS_PER_TEXEL 32
//#define REUSE_SCREEN_LIGHTING 1
//#define ONE_LIGHT_PER_TEXEL 1

#define RAY_QUERY
#define LIGHT_POLYGON 1
#include "lk_dnsr_lights_direct.glsl"
28 changes: 28 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_refl_poly_choose.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_ray_query: require
#extension GL_EXT_shader_atomic_float: require
#extension GL_EXT_shader_16bit_storage : require

#define RAY_QUERY

#define REFLECTIONS 1

#define SRC_FIRST_POSITION position_t
#define SRC_POSITION refl_position_t
#define SRC_NORMALS refl_normals_gs
#define SRC_MATERIAL refl_material_rmxx
#define SRC_BASE_COLOR refl_base_color_a

#define LIGHT_CHOOSE_PASS 1
#define OUT_LIGHTING out_light_poly_chosen_refl

#define LIGHT_POLYGON 1

//#define REUSE_SCREEN_LIGHTING 1

//#define MAX_LIGHTS_PER_TEXEL 32
//#define REUSE_SCREEN_LIGHTING 1
//#define ONE_LIGHT_PER_TEXEL 1

#include "lk_dnsr_lights_adaptive.glsl"
29 changes: 29 additions & 0 deletions ref/vk/shaders/lk_dnsr_light_refl_poly_sample.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#version 460 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_ray_query: require
#extension GL_EXT_shader_atomic_float: require
#extension GL_EXT_shader_16bit_storage : require

#define RAY_QUERY

#define REFLECTIONS 1

#define SRC_FIRST_POSITION position_t
#define SRC_POSITION refl_position_t
#define SRC_NORMALS refl_normals_gs
#define SRC_MATERIAL refl_material_rmxx
#define SRC_BASE_COLOR refl_base_color_a

#define OUT_LIGHTING out_light_poly_refl

#define LIGHT_SAMPLE_PASS 1
#define SRC_LIGHTS_CHOSEN light_poly_chosen_refl

#define LIGHT_POLYGON 1
//#define REUSE_SCREEN_LIGHTING 1

//#define MAX_LIGHTS_PER_TEXEL 32
//#define REUSE_SCREEN_LIGHTING 1
//#define ONE_LIGHT_PER_TEXEL 1

#include "lk_dnsr_lights_adaptive.glsl"
Loading

0 comments on commit 9aa9c7c

Please sign in to comment.