diff --git a/res/sh/shade.hlsl b/res/sh/shade.hlsl index b25a0edc..6f883c90 100644 --- a/res/sh/shade.hlsl +++ b/res/sh/shade.hlsl @@ -25,11 +25,11 @@ struct cs_input { * Lighting * ========================== */ -#define SAMPLES 4 +#define SAMPLES 2 #define MARCHES 16 #define AMBIENT float4(0, 0, 0, 0) -float rand_float_from_float2(float2 pos) { +float rand_angle(uint2 pos, uint ray_index) { Texture3D noise_tex = g_noise_textures[SH_BLUE_NOISE_TEX_ID]; // pos += uint2(g_constants.frame_seed.x % g_constants.tex_width, g_constants.frame_seed.x % g_constants.tex_height); @@ -37,15 +37,15 @@ float rand_float_from_float2(float2 pos) { // pos -= g_constants.camera_offset; uint3 noise_coord = uint3(pos.xy, 0); - // noise_coord.xy += g_constants.frame_seed.xy; + // noise_coord.xy *= g_constants.frame_seed.xy; + noise_coord.z += ray_index; + // noise_coord.z += ray_index * noise_coord.x ; + // noise_coord.z += g_constants.frame_seed.x; // noise_coord.z += g_constants.frame_index; - // noise_coord.z += g_constants.frame_index; - - uint3 noise_size = uint3(SH_BLUE_NOISE_TEX_WIDTH, SH_BLUE_NOISE_TEX_HEIGHT, SH_BLUE_NOISE_TEX_DEPTH); uint noise = noise_tex[noise_coord % noise_size]; - return (float)noise / (float)0xFFFF; + return ((float)noise / (float)0xFFFF) * TAU; } INLINE float4 get_light_in_dir(uint2 ray_start, float2 ray_dir) @@ -79,12 +79,7 @@ INLINE float4 get_light_at_pos(uint2 pos) { float4 result = 0; for (uint i = 0; i < SAMPLES; ++i) { - float angle = ((((float)i + rand_float_from_float2((float2)pos + (float)i)) / SAMPLES)) * TAU; - // float angle = (rand_float_from_float2(pos)) * TAU; - - // float angle = (rand_float_from_float2(pos)) * TAU; - // float angle = (((float)i / SAMPLES)) * TAU; - // float angle = (rand_float_from_float2(pos)) * TAU; + float angle = rand_angle(pos, i); float2 dir = float2(cos(angle), sin(angle)); float4 light_in_dir = get_light_in_dir(pos, dir); result += light_in_dir;