Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Merge noise-info features from VGA internal branch #54

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
4 changes: 1 addition & 3 deletions shader/bmfr_fit.comp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ shared float block_min_f, block_max_f, vec_length, u_length_squared, v_dot_a;
shared float16_t u_vec[BLOCK_SIZE * BLOCK_SIZE];
shared vec3 r_mat[R_SIZE];


int get_linear_id()
{
return int(gl_LocalInvocationID.y * gl_WorkGroupSize.x + gl_LocalInvocationID.x);
Expand Down Expand Up @@ -205,7 +204,6 @@ void main()
parallel_reduction_min();
barrier();


if (id == 0)
{
const int index = (get_linear_group_id() * 6 + feature_buffer - 4) * 2;
Expand Down Expand Up @@ -411,4 +409,4 @@ void main()
weights_buffer.weights[index + offset + 10] = x_s2[id];
#endif
}
}
}
11 changes: 7 additions & 4 deletions shader/bmfr_preprocess.comp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ layout(binding = 12, set = 0) uniform uniform_buffer_t
uint frame_counter;
} uniform_buffer;

layout(binding = 15, set = 0, rgba32f) uniform image2DArray in_prob;

layout(binding = 13, set = 0) buffer tmp_buffer_t
{
float16_t data[];
Expand Down Expand Up @@ -111,6 +113,7 @@ void main()
vec4 curr_color = imageLoad(in_color, p);
vec3 curr_normal = unpack_gbuffer_normal(imageLoad(in_normal, p).xy);
vec3 curr_pos = imageLoad(in_pos, p).xyz;
vec3 probs = imageLoad(in_prob, p).xyz;
float sum_w = 0.0;
{
vec2 motion = vec2(imageLoad(in_screen_motion,p));
Expand Down Expand Up @@ -191,9 +194,9 @@ void main()
curr_normal.x,
curr_normal.y,
curr_normal.z,
curr_pos.x,
curr_pos.y,
curr_pos.z,
probs.x,
probs.x,
probs.x,
curr_pos.x * curr_pos.x,
curr_pos.y * curr_pos.y,
curr_pos.z * curr_pos.z,
Expand Down Expand Up @@ -232,4 +235,4 @@ void main()
tmp_buffer.data[location_in_data + buffer_offset] = float16_t(store_value);
}

}
}
13 changes: 9 additions & 4 deletions shader/bmfr_weighted_sum.comp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ layout(binding = 6, set = 0) buffer mins_maxs
{
float16_t minmax[];
} mins_maxs_buffer;

layout(binding = 15, set = 0, rgba32f) uniform readonly image2DArray in_prob;

layout(binding = 7, set = 0) uniform uniform_buffer_t
{
uint frame_counter;
Expand All @@ -41,14 +44,16 @@ void main()
vec3 curr_pos = imageLoad(in_pos, p).xyz;
vec3 curr_normal = unpack_gbuffer_normal(imageLoad(in_normal, p).xy);

vec3 probs = imageLoad(in_prob, p).xyz;

const float features[FEATURE_COUNT] = {
1.f,
curr_normal.x,
curr_normal.y,
curr_normal.z,
curr_pos.x,
curr_pos.y,
curr_pos.z,
probs.x,
probs.y,
probs.z,
curr_pos.x * curr_pos.x,
curr_pos.y * curr_pos.y,
curr_pos.z * curr_pos.z,
Expand Down Expand Up @@ -87,4 +92,4 @@ void main()
#ifndef DIFFUSE_ONLY
imageStore(weighted_out[1], p, vec4(color_spec.rgb, 1.0));
#endif
}
}
41 changes: 41 additions & 0 deletions shader/gbuffer.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -575,5 +575,46 @@ vec3 read_gbuffer_linear_depth(ivec3 pos) { return vec3(0.0); }

#endif

//==============================================================================
// PROB
//==============================================================================

#ifdef PROB_TARGET_BINDING
layout(binding = PROB_TARGET_BINDING, set = 0, rgba32f) uniform image2DArray prob_target;

void write_gbuffer_prob(vec3 prob, ivec3 pos)
{
if(all(equal(ivec2(gl_LaunchIDEXT.xy), ivec2(960, 540))))
{
//debugPrintfEXT("%d, %d, %d", pos.x, pos.y, pos.z);
}
imageStore(prob_target, pos, vec4(prob, 0));
//imageStore(prob_target, pos, vec4(1.0, 0.0, 1.0, 0));
}

vec3 read_gbuffer_prob(ivec3 pos)
{
return imageLoad(prob_target, pos).xyz;
}

#elif defined(PROB_TARGET_LOCATION)

layout(location = PROB_TARGET_LOCATION) out vec3 prob_target;

void write_gbuffer_prob(vec3 prob)
{
prob_target = prob;
}

#else

void write_gbuffer_prob(vec3 prob, ivec3 pos) {
debugPrintfEXT("jei");
}

void write_gbuffer_prob(vec3 prob) {}
vec3 read_gbuffer_prob(ivec3 pos) { return vec3(0); }

#endif
#endif

13 changes: 13 additions & 0 deletions shader/material.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ vec3 modulate_bsdf(sampled_material mat, bsdf_lobes bsdf)
return mat.albedo.rgb * (bsdf.metallic_reflection + bsdf.transmission + bsdf.diffuse) + bsdf.dielectric_reflection;
}

vec3 modulate_diffuse(sampled_material mat, float diffuse)
{
return diffuse * mat.albedo.rgb * (1 - mat.metallic);
}

vec3 modulate_reflection(sampled_material mat, float reflected)
{
float approx_fresnel = 0.02f;
return reflected
* mix(vec3(approx_fresnel), mat.albedo.rgb, mat.metallic)
/ mix(approx_fresnel, 1, mat.metallic);
}

vec3 modulate_color(sampled_material mat, vec3 diffuse, vec3 reflected)
{
float approx_fresnel = 0.02f;
Expand Down
Loading