rtx: fix additive when hitting sky

This commit is contained in:
Ivan Avdeev 2021-11-19 11:09:01 -08:00 committed by Ivan Avdeev
parent 10dab2f021
commit 335be32cff
1 changed files with 12 additions and 5 deletions

View File

@ -356,21 +356,24 @@ void main() {
const uint flags = gl_RayFlagsCullFrontFacingTrianglesEXT;
const uint sbt_offset = 0;
const uint sbt_stride = 0;
const uint miss_index = 0;
const float L = 10000.; // Why 10k?
traceRayEXT(tlas, flags, GEOMETRY_BIT_OPAQUE | GEOMETRY_BIT_REFRACTIVE,
sbt_offset, sbt_stride, miss_index,
sbt_offset, sbt_stride, SHADER_OFFSET_MISS_REGULAR,
origin, 0., direction, L,
PAYLOAD_LOCATION_OPAQUE);
vec3 additive = traceAdditive(origin, direction, payload_opaque.hit_pos_t.w <= 0. ? L : payload_opaque.hit_pos_t.w);
// Sky/envmap
if (payload_opaque.hit_pos_t.w <= 0.) {
out_accumulated += throughput * payload_opaque.base_color;
if (bounce == 0) {
out_additive += payload_opaque.emissive * color_factor + additive;
} else {
out_accumulated += throughput * (payload_opaque.emissive * color_factor + additive);
}
break;
}
vec3 additive = traceAdditive(origin, direction, payload_opaque.hit_pos_t.w);
#ifdef DEBUG_LIGHT_CULLING
// light clusters debugging
{
@ -423,7 +426,11 @@ void main() {
imageStore(out_image_normals, ivec2(gl_LaunchIDEXT.xy), vec4(geometryNormal.xy, shadingNormal.xy));
payload_opaque.base_color = vec3(1.);
//out_material_index = float(kusochki[payload_opaque.kusok_index].tex_roughness);
#if 0
//imageStore(out_image_base_color, ivec2(gl_LaunchIDEXT.xy), vec4(fract(payload_opaque.debug.xy), 0., 0.));
//imageStore(out_image_base_color, ivec2(gl_LaunchIDEXT.xy), vec4(payload_opaque.kusok_index));
imageStore(out_image_base_color, ivec2(gl_LaunchIDEXT.xy), vec4(payload_opaque.roughness));
imageStore(out_image_diffuse_gi, ivec2(gl_LaunchIDEXT.xy), vec4(0));
imageStore(out_image_specular, ivec2(gl_LaunchIDEXT.xy), vec4(0.));
imageStore(out_image_additive, ivec2(gl_LaunchIDEXT.xy), vec4(clamp(payload_opaque.normal, vec3(0.), vec3(1.)), 0.));