POV-Ray : Newsgroups : povray.programming : Smooth mesh 'bug' inverted normals (+Patch) : Re: Smooth mesh 'bug' inverted normals (+Patch) Server Time
21 May 2024 15:07:00 EDT (-0400)
  Re: Smooth mesh 'bug' inverted normals (+Patch)  
From: Jurjen
Date: 12 Aug 2002 04:10:02
Message: <web.3d576c99956bba3ea3c6bc9f0@news.povray.org>
Christopher James Huff wrote:
>Pseudocode:
>
>if true-normal faces toward ray
>    (ray origin is on outside)
>
>    if interpolated-normal faces away from ray
>        skip intersection
>        (it shouldn't be visible anyway)
>
>        set flag to skip next
>        (it is part of the interior visible through
>            the skipped intersection)
>    end
>else
>    (ray origin is on inside, flip the normal
>        directions and do the same thing as above)
>end

I am willing to try and modify my patch to support this concept.
There is a some small technical problem that needs to be solved though:

There is no ordering in the set of triangles of the mesh till all the
intersections are calculated.

So my implementation will be something like:
In test_hit:

if smooth
  {calc}
  if true normal faces towards ray
    flip directions of extra normals
  end
  {calc}
  if inverted
    register call but with invalid mark
  else
    current registering call
  end
else
  current registering call
end

In the function that determines the frontmost intersections:

extra loop:

Invalid=false
do
  if Invalid
    {calculate the front intersection}
    remove intersection from list
    {calculate the front intersection}
    Invalid=false
  else
    {calculate the front intersection}
  endif
  if marked
    remove intersection from list
    Invalid=true
  end
while not Invalid


This way there is not much overhead when there are no triangles skipped.
But this routine can handle the situation where 4 triangles (2 times 2) need
to be skipped.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.