use ray index for noise layer
This commit is contained in:
parent
9344c2c632
commit
5db37a9486
@ -25,11 +25,11 @@ struct cs_input {
|
|||||||
* Lighting
|
* Lighting
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
#define SAMPLES 4
|
#define SAMPLES 2
|
||||||
#define MARCHES 16
|
#define MARCHES 16
|
||||||
#define AMBIENT float4(0, 0, 0, 0)
|
#define AMBIENT float4(0, 0, 0, 0)
|
||||||
|
|
||||||
float rand_float_from_float2(float2 pos) {
|
float rand_angle(uint2 pos, uint ray_index) {
|
||||||
Texture3D<uint> noise_tex = g_noise_textures[SH_BLUE_NOISE_TEX_ID];
|
Texture3D<uint> 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);
|
// 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;
|
// pos -= g_constants.camera_offset;
|
||||||
|
|
||||||
uint3 noise_coord = uint3(pos.xy, 0);
|
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;
|
||||||
// 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);
|
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];
|
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)
|
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;
|
float4 result = 0;
|
||||||
for (uint i = 0; i < SAMPLES; ++i) {
|
for (uint i = 0; i < SAMPLES; ++i) {
|
||||||
float angle = ((((float)i + rand_float_from_float2((float2)pos + (float)i)) / SAMPLES)) * TAU;
|
float angle = rand_angle(pos, i);
|
||||||
// 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;
|
|
||||||
float2 dir = float2(cos(angle), sin(angle));
|
float2 dir = float2(cos(angle), sin(angle));
|
||||||
float4 light_in_dir = get_light_in_dir(pos, dir);
|
float4 light_in_dir = get_light_in_dir(pos, dir);
|
||||||
result += light_in_dir;
|
result += light_in_dir;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user