EEVEE-Next: Volume: Add artificial backface hit to close volumes
This could happen for non manifold meshes (like a water plane) when using the accurate method. If last hit in the volume ray is a frontface, we now consider everything behind it in volume.
This commit is contained in:
parent
2d4c624a87
commit
b0eb156344
@ -16,7 +16,7 @@ bool is_front_face_hit(float stored_hit_depth)
|
||||
void main()
|
||||
{
|
||||
float hit_depths[VOLUME_HIT_DEPTH_MAX];
|
||||
float hit_ordered[VOLUME_HIT_DEPTH_MAX];
|
||||
float hit_ordered[VOLUME_HIT_DEPTH_MAX + 1];
|
||||
int hit_index[VOLUME_HIT_DEPTH_MAX];
|
||||
|
||||
ivec2 texel = ivec2(gl_FragCoord.xy);
|
||||
@ -57,9 +57,12 @@ void main()
|
||||
/* True if last interface was a volume entry. */
|
||||
/* Initialized to front facing if first hit is a backface to support camera inside the volume. */
|
||||
bool last_frontfacing = !is_front_face_hit(hit_ordered[0]);
|
||||
/* Add artificial backfacing hit to close volumes we entered but never exited.
|
||||
* Fixes issues with non-manifold meshes or things like water planes. */
|
||||
hit_ordered[hit_count] = -1.0;
|
||||
/* Bit index of the last interface. */
|
||||
int last_bit = 0;
|
||||
for (int i = 0; i < hit_count; i++) {
|
||||
for (int i = 0; i <= hit_count; i++) {
|
||||
bool frontfacing = is_front_face_hit(hit_ordered[i]);
|
||||
if (last_frontfacing == frontfacing) {
|
||||
/* Same facing, do not treat as a volume interface. */
|
||||
|
Loading…
Reference in New Issue
Block a user