POV-Ray : Newsgroups : povray.programming : Smooth mesh 'bug' inverted normals (+Patch) Server Time
28 Jul 2024 12:33:43 EDT (-0400)
  Smooth mesh 'bug' inverted normals (+Patch) (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: Smooth mesh 'bug' inverted normals (+Patch)
Date: 11 Aug 2002 22:39:28
Message: <3d571fe0@news.povray.org>
Christopher James Huff <chr### [at] maccom> wrote:
> Ok, I see what you are saying. I'm not sure that would be part of a 
> "well behaved" mesh though, the normals don't match the surface 
> geometry.

  I know that *usually* you don't get normal vectors oriented like that
from any mesh creation program. However, it's not impossible, nor even
improbable that such program could produce such meshes. For example
a program which tesselates an isosurface could produce such meshes
(if it calculates the normal vectors from the function itself, as it should,
instead of just averaging triangle normals; in this case the normal vectors
are oriented according to the original isosurface, even though the triangles
are less precise due to low tesselation resolution).

> Even double_illuminate won't always work.

  double_illuminate works most of the time, but it produces serious
problems in some cases, eg. when the mesh is shadowless (in which case
*all* light sources illuminate all triangles, producing unwanted lighting).
  However, the original solution I have proposed (ie. invert the normal
vector only if the true normal vector of the surface and the returned
normal vector agree in their direction relative to the ray) works better
than double_illuminate.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: ABX
Subject: Re: Smooth mesh 'bug' inverted normals (+Patch)
Date: 12 Aug 2002 03:05:20
Message: <hcnelugc9pp34dhg57icj3vc1b91lb9u98@4ax.com>
On Sat, 10 Aug 2002 15:15:38 EDT, "Jurjen" <jjs### [at] hotmailcom>
wrote:
> Here is some code that will change the behaviour of smooth-triangles

Added to http://abx.art.pl/pov/patches/patches.php.

ABX
-- 
disc{z,-z#macro O()asc(substr("-+((1*(,1,/.-,*/(,&.323/'1"e 1))/10-4#declare
e=e-1;#end#local e=26;5pigment{#local g=function(_){ceil(_)-_}function#local
k=function{pattern{object{sphere_sweep{linear_spline 13#while(e)<O()O()>.01#
end}}}}{k(g(atan2(x,y)),g(ln(pow(x+y,2)+1e-5)),0)}}finish{ambient 1}}//ABX35


Post a reply to this message

From: Jurjen
Subject: Re: Smooth mesh 'bug' inverted normals (+Patch)
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

From: ABX
Subject: Re: Smooth mesh 'bug' inverted normals (+Patch)
Date: 22 Oct 2002 10:10:59
Message: <ppmarucm9629f9rdc39jba10asf6ivf3c4@4ax.com>
On Sat, 10 Aug 2002 15:15:38 EDT, "Jurjen" <jjs### [at] hotmailcom>
wrote:
> It could be handy to make a flag on the
> mesh so that this 'feature' can be turned off for people that don't approve
> on this restriction.

I have incorporated this patch to PoPOV with keyword inverted_normals [on|off]
in mesh modificators. When inverted_normals is not specified then default
value for this switch is ON which means old behaviour. For inverted_normals
off new behaviour is activated.

ABX


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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