rt: rename traceAdditive to traceSimpleBlending

This is to more clearly distinguish between simple blended things that
don't participate in lighting, and future more involved blending with
refraction and being affected by light
This commit is contained in:
Ivan Avdeev 2023-04-27 10:37:48 -07:00 committed by Ivan Avdeev
parent 847777fb6b
commit 8ac1a76259
3 changed files with 13 additions and 12 deletions

View File

@ -40,7 +40,7 @@ layout(set=0, binding=21, rgba16f) uniform writeonly image2D out_indirect_specul
#define BINDING_LIGHT_CLUSTERS 18
#include "light.glsl"
#include "trace_additive.glsl"
#include "trace_simple_blending.glsl"
void readNormals(ivec2 uv, out vec3 geometry_normal, out vec3 shading_normal) {
const vec4 n = imageLoad(normals_gs, uv);
@ -169,7 +169,7 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
vec3 background = ldiffuse + lspecular;
vec3 emissive = vec3(0.);
traceAdditive(pos, bounce_direction, payload.hit_t.w, emissive, background);
traceSimpleBlending(pos, bounce_direction, payload.hit_t.w, emissive, background);
const vec3 final_color = emissive + background;
if (brdf_type == DIFFUSE_TYPE)

View File

@ -23,7 +23,7 @@ RAY_PRIMARY_OUTPUTS(X)
layout(set = 0, binding = 1) uniform accelerationStructureEXT tlas;
#include "trace_additive.glsl"
#include "trace_simple_blending.glsl"
struct Ray {
vec3 origin, direction;
@ -102,7 +102,7 @@ void main() {
L = rayQueryGetIntersectionTEXT(rq, true);
}
traceAdditive(ray.origin, ray.direction, L, payload.emissive.rgb, payload.base_color_a.rgb);
traceSimpleBlending(ray.origin, ray.direction, L, payload.emissive.rgb, payload.base_color_a.rgb);
imageStore(out_position_t, pix, payload.hit_t);
imageStore(out_base_color_a, pix, payload.base_color_a);

View File

@ -1,8 +1,9 @@
#ifndef TRACE_ADDITIVE_GLSL_INCLUDED
#define TRACE_ADDITIVE_GLSL_INCLUDED
#ifndef TRACE_SIMPLE_BLENDING_GLSL_INCLUDED
#define TRACE_SIMPLE_BLENDING_GLSL_INCLUDED
void traceAdditive(vec3 pos, vec3 dir, float L, inout vec3 emissive, inout vec3 background) {
const float additive_soft_overshoot = 16.;
// Traces geometry with simple blending. Simple means that it's only additive or mix/coverage, and it doesn't participate in lighting, and it doesn't reflect/refract rays.
void traceSimpleBlending(vec3 pos, vec3 dir, float L, inout vec3 emissive, inout vec3 background) {
const float glow_soft_overshoot = 16.;
// TODO probably a better way would be to sort only MIX entries.
// ADD/GLOW are order-independent relative to each other, but not to MIX
@ -23,7 +24,7 @@ void traceAdditive(vec3 pos, vec3 dir, float L, inout vec3 emissive, inout vec3
//| gl_RayFlagsSkipClosestHitShaderEXT
| gl_RayFlagsNoOpaqueEXT // force all to be non-opaque
;
rayQueryInitializeEXT(rq, tlas, flags, GEOMETRY_BIT_BLEND, pos, 0., dir, L + additive_soft_overshoot);
rayQueryInitializeEXT(rq, tlas, flags, GEOMETRY_BIT_BLEND, pos, 0., dir, L + glow_soft_overshoot);
while (rayQueryProceedEXT(rq)) {
const MiniGeometry geom = readCandidateMiniGeometry(rq);
const Kusok kusok = getKusok(geom.kusok_index);
@ -36,7 +37,7 @@ void traceAdditive(vec3 pos, vec3 dir, float L, inout vec3 emissive, inout vec3
#ifdef DEBUG_BLEND_MODES
if (kusok.material.mode == MATERIAL_MODE_BLEND_GLOW) {
emissive += vec3(1., 0., 0.);
//ret += color * smoothstep(additive_soft_overshoot, 0., overshoot);
//ret += color * smoothstep(glow_soft_overshoot, 0., overshoot);
} else if (kusok.material.mode == MATERIAL_MODE_BLEND_ADD) {
emissive += vec3(0., 1., 0.);
} else if (kusok.material.mode == MATERIAL_MODE_BLEND_MIX) {
@ -53,7 +54,7 @@ void traceAdditive(vec3 pos, vec3 dir, float L, inout vec3 emissive, inout vec3
if (kusok.material.mode == MATERIAL_MODE_BLEND_GLOW) {
// Glow is additive + small overshoot
const float overshoot_factor = smoothstep(additive_soft_overshoot, 0., overshoot);
const float overshoot_factor = smoothstep(glow_soft_overshoot, 0., overshoot);
color *= overshoot_factor;
alpha = 0.;
} else if (kusok.material.mode == MATERIAL_MODE_BLEND_ADD) {
@ -111,4 +112,4 @@ void traceAdditive(vec3 pos, vec3 dir, float L, inout vec3 emissive, inout vec3
background *= revealage;
}
#endif //ifndef TRACE_ADDITIVE_GLSL_INCLUDED
#endif //ifndef TRACE_SIMPLE_BLENDING_GLSL_INCLUDED