rtx: implement soft particles for additve, fix #177
This commit is contained in:
parent
a8313073d3
commit
24a07499c5
|
@ -24,8 +24,11 @@ void main() {
|
|||
const vec2 texture_uv = vertices[vi1].gl_tc * (1. - bary.x - bary.y) + vertices[vi2].gl_tc * bary.x + vertices[vi3].gl_tc * bary.y;
|
||||
const uint tex_index = kusochki[kusok_index].texture;
|
||||
const vec4 texture_color = texture(textures[nonuniformEXT(tex_index)], texture_uv);
|
||||
const vec3 color = texture_color.rgb * kusochki[kusok_index].color.rgb * texture_color.a * kusochki[kusok_index].color.a;
|
||||
|
||||
payload_additive.color += texture_color.rgb * kusochki[kusok_index].color.rgb * texture_color.a * kusochki[kusok_index].color.a;
|
||||
const float overshoot = gl_HitTEXT - payload_additive.ray_distance;
|
||||
|
||||
payload_additive.color += color * smoothstep(additive_soft_overshoot, 0., overshoot);
|
||||
|
||||
ignoreIntersectionEXT;
|
||||
}
|
||||
|
|
|
@ -272,6 +272,25 @@ vec3 computeLighting(vec3 throughput, vec3 view_dir, MaterialProperties material
|
|||
return C;
|
||||
}
|
||||
|
||||
// Additive translucency
|
||||
vec3 traceAdditive(vec3 origin, vec3 direction, float ray_distance) {
|
||||
const uint flags = 0
|
||||
/* TODO try without*/ | gl_RayFlagsCullFrontFacingTrianglesEXT
|
||||
//| gl_RayFlagsOpaqueEXT
|
||||
| gl_RayFlagsSkipClosestHitShaderEXT
|
||||
;
|
||||
const uint sbt_offset = 0;
|
||||
const uint sbt_stride = 0;
|
||||
|
||||
payload_additive.color = vec3(0.);
|
||||
payload_additive.ray_distance = ray_distance;
|
||||
traceRayEXT(tlas, flags, GEOMETRY_BIT_ADDITIVE,
|
||||
sbt_offset, sbt_stride, SHADER_OFFSET_MISS_EMPTY,
|
||||
origin, 0., direction, ray_distance + additive_soft_overshoot,
|
||||
PAYLOAD_LOCATION_ADDITIVE);
|
||||
return payload_additive.color * color_factor;
|
||||
}
|
||||
|
||||
void main() {
|
||||
rand01_state = push_constants.random_seed + gl_LaunchIDEXT.x * 1833 + gl_LaunchIDEXT.y * 31337;
|
||||
vec2 uv = (gl_LaunchIDEXT.xy + .5) / gl_LaunchSizeEXT.xy * 2. - 1.;
|
||||
|
@ -309,24 +328,7 @@ void main() {
|
|||
break;
|
||||
}
|
||||
|
||||
// Additive translucency
|
||||
{
|
||||
const uint flags = 0
|
||||
/* TODO try without*/ | gl_RayFlagsCullFrontFacingTrianglesEXT
|
||||
//| gl_RayFlagsOpaqueEXT
|
||||
| gl_RayFlagsSkipClosestHitShaderEXT
|
||||
;
|
||||
const uint sbt_offset = 0;
|
||||
const uint sbt_stride = 0;
|
||||
const float L = 10000.;
|
||||
|
||||
payload_additive.color = vec3(0.);
|
||||
traceRayEXT(tlas, flags, GEOMETRY_BIT_ADDITIVE,
|
||||
sbt_offset, sbt_stride, SHADER_OFFSET_MISS_EMPTY,
|
||||
origin, 0., direction, payload_opaque.hit_pos_t.w,
|
||||
PAYLOAD_LOCATION_ADDITIVE);
|
||||
C += throughput * payload_additive.color * color_factor;
|
||||
}
|
||||
C += throughput * traceAdditive(origin, direction, payload_opaque.hit_pos_t.w);
|
||||
|
||||
#ifdef DEBUG_LIGHT_CULLING
|
||||
// light clusters debugging
|
||||
|
|
|
@ -20,6 +20,9 @@ struct RayPayloadShadow {
|
|||
bool shadow;
|
||||
};
|
||||
|
||||
|
||||
const float additive_soft_overshoot = 16.;
|
||||
struct RayPayloadAdditive {
|
||||
vec3 color;
|
||||
float ray_distance;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue