transparent roughness and diffuse settings from app
This commit is contained in:
parent
fbc21ba523
commit
1ecd1c7403
7 changed files with 39 additions and 17 deletions
shaders
Binary file not shown.
|
@ -16,6 +16,10 @@ layout(binding = 0) uniform UniformBufferObject {
|
|||
bool[16] use_geom_shader;
|
||||
} ubo;
|
||||
|
||||
// 0 - location for the maximum number of lights referenced per chunk (also will be the invalid memory allocation for pointing to a nonexistant neighbor)
|
||||
// 1 - location for the max iterations per light
|
||||
// 2 - diffuse raster samples (2*n + 1) * (2*n + 1) so as to always have at least the central fragment covered
|
||||
// 3 - diffuse raster size (float, needs to be decoded)
|
||||
layout(binding = 2) buffer SceneInfoBuffer{
|
||||
uint infos[];
|
||||
} scene_info;
|
||||
|
@ -350,8 +354,8 @@ vec3 diffuse_tracing(uint volume_start, uvec2 raster_pos, vec3 pos, uint f) {
|
|||
vec3 normal = normal_for_facing(f);
|
||||
|
||||
// diffuse raytracing using a quadratic raster of rays
|
||||
int raster_half_steps = 0;
|
||||
float raster_distance = 0.01;
|
||||
int raster_half_steps = int(scene_info.infos[2]);
|
||||
float raster_distance = uintBitsToFloat(scene_info.infos[3]);
|
||||
int raster_points = (2 * raster_half_steps + 1) * (2 * raster_half_steps + 1);
|
||||
|
||||
vec3 color_sum = vec3(0.0, 0.0, 0.0);
|
||||
|
@ -389,18 +393,21 @@ vec3 clamp_to_volume(uint volume_start, vec3 position) {
|
|||
|
||||
void main() {
|
||||
vec3 clamped_pos = clamp_to_volume(fragVolumeStart, origPosition);
|
||||
uvec4 color_roughness = sample_color_from_scene_info(fragVolumeStart, fragRasterPos, facing);
|
||||
vec3 orig_color_sample = vec3(float(color_roughness.x) / 255.0, float(color_roughness.y) / 255.0, float(color_roughness.z) / 255.0);
|
||||
vec3 color_sum = diffuse_tracing(fragVolumeStart, fragRasterPos, clamped_pos, facing);
|
||||
|
||||
uint orig_neighbor = sample_neighbor_from_scene_info(fragVolumeStart, fragRasterPos, facing);
|
||||
if (orig_neighbor != 0) {
|
||||
float pos_infinity = uintBitsToFloat(0x7F800000);
|
||||
Tracing t = trace_ray(fragVolumeStart, ubo.camera_pos, clamped_pos - ubo.camera_pos, 100.0, 0, 20);
|
||||
float opacity = float(color_roughness.w) / 255.0;
|
||||
if (t.has_hit) {
|
||||
color_sum += diffuse_tracing(t.end_volume, t.end_raster, t.end_pos, t.end_facing);
|
||||
color_sum = opacity * color_sum + (1.0 - opacity) * diffuse_tracing(t.end_volume, t.end_raster, t.end_pos, t.end_facing) * orig_color_sample;
|
||||
}
|
||||
else {
|
||||
// Todo: hit sky box
|
||||
color_sum += vec3(0.0, 0.0, 0.0);
|
||||
color_sum = opacity * color_sum + (1.0 - opacity) * vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue