POV-Ray : Newsgroups : povray.beta-test : Heightfield bug (most probably an inverted normals problem) Server Time
23 Apr 2024 03:48:40 EDT (-0400)
  Heightfield bug (most probably an inverted normals problem) (Message 8 to 17 of 27)  
<<< Previous 7 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Warp
Subject: Re: More info
Date: 22 Jan 2002 12:21:40
Message: <3c4d9fa4@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
:   However, I understand that removing this inversion could actually break
: something else which currently works.

  By the way, it occurred to me what would this seriously break: If we are
looking at an object surface from one side and a light source is illuminating
the object on the other side, this normal inversion takes care that we see
a shadowed surface, not an illuminated surface. If the normal was not inverted,
then the surface would work like it was double-illuminated all the time if
the unmodified normal points at the light source and it wouldn't be illuminated
at all (no matter where you look at it) if the unmodified normal points away
from the light source.

  What a dilemma!

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Heightfield bug (most probably an inverted normals problem)
Date: 22 Jan 2002 12:37:57
Message: <chrishuff-235D1D.12385522012002@netplex.aussie.org>
I don't have the POV 3.5 source available, but in POV 3.1:

lighting.c, Determine_Apparent_Colour()

...

  VDot(Normal_Direction, Raw_Normal, Ray->Direction);

  if (Normal_Direction > 0.0)
  {
     VScaleEq(Raw_Normal, -1.0);
  }

-- 
 -- 
Christopher James Huff <chr### [at] maccom>


Post a reply to this message

From: Christopher James Huff
Subject: Re: More info (Was: Heightfield bug (most probably an inverted normals problem))
Date: 22 Jan 2002 13:07:35
Message: <chrishuff-2AD539.13083422012002@netplex.aussie.org>
In article <3c4d9de5@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   However, I understand that removing this inversion could actually break
> something else which currently works. One case could perhaps be CSG
> illumination and inverted object illumination.

Any case where you can see both sides of a surface...any object that's 
clipped, triangles, bezier patches, height fields, discs, polygons, 
isosurfaces...

The only fix would be to detect for a hit from the "outside" of the 
object that still gives a normal that points away from the ray. This 
only happens with smooth triangles as far as I can tell, so the test 
could be restricted to that case if possible. As for what you do when 
you identify this case...that's a different problem, and I don't think 
it's been solved. Artificially limit the normal to be at 90 degrees to 
the ray? I think that will just make black areas. Ignore the 
intersection entirely?
If the intersection is ignored, you have to worry about the triangles 
behind it...maybe meshes/smooth_triangles should have a "front_only" or 
"cull_backsides" option, but that would break transparent meshes. Maybe 
just ignore the intersection and the first intersection with the same 
mesh that follows it...that should work for all well-behaved meshes, but 
might be complex to code.

-- 
 -- 
Christopher James Huff <chr### [at] maccom>


Post a reply to this message

From: Christoph Hormann
Subject: Re: More info (Was: Heightfield bug (most probably an inverted normals problem))
Date: 22 Jan 2002 14:24:14
Message: <3C4DBC5C.BA61316@gmx.de>
Warp wrote:
> 
>   It's not actually a heightfield bug. It's a more general phenomenon. If the
> angle between the normal vector returned by the object (any object) and the
> incoming ray is <90 degrees, then the normal vector is inverted.
> 
> [...]

I think it would be interesting to know how other raytracers handle this.

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Simon Adameit
Subject: Re: More info (Was: Heightfield bug (most probably an inverted normals problem))
Date: 23 Jan 2002 08:15:11
Message: <3c4eb75f@news.povray.org>
>   It's not actually a heightfield bug. It's a more general phenomenon. If
the
> angle between the normal vector returned by the object (any object) and
the
> incoming ray is <90 degrees, then the normal vector is inverted.

Imho these bugs can only appear if the normal is somehow modified.
Wouldn't it be possible to just test the unmodified normal?

--
#local T=text{ttf"timrom.ttf""Simon Adameit".01,0}#local Y=1;#while(Y>-1)
#local X=0;#while(X<7)#local O=trace(T<X,Y><X,Y>+z);cylinder{<X-3,Y,5>*.01
<X-3,Y,5>*.01+5e-3,5e-5pigment{rgb 25*O}}#debug chr(83-(O.x=0)*51)#local
X=X+.05;#end#debug"\n"#local Y=Y-.05;#end


Post a reply to this message

From: Warp
Subject: A possible solution, though difficult (Was: More info)
Date: 23 Jan 2002 08:57:59
Message: <3c4ec167@news.povray.org>
Looking at the code and testing a bit it's now extremely clear why this
artifact happens. It's not a bug, it's just a side-effect of normal
perturbation in smooth triangles.

  One possible solution is to invert the normal if the angle between the
incoming ray and the unmodified triangle normal is <90 and the angle between
the modified normal and the incoming ray is >90, or the other way around.
That is, for example in the heighfield function which returns the normal
vector for a certain point, in the block where it is calculated for a smooth
heightfield, something like this is done:

  if(dotProduct(incomingRay,unmodifiedNormal)*dotProduct(incomingRay,Result)<0)
    invert(Result);

  The effect of this is that when the problematic case happens, the normal
is inverted inside the heightfield code. Then it's inverted again at the upper
level, thus nullifying the inversion.

  However, there's one big problem here: As far as I can see, the normal
calculation function has no access to the incoming ray.
  Any ideas?

-- 
#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: Jérôme Grimbert
Subject: Re: A possible solution, though difficult (Was: More info)
Date: 23 Jan 2002 10:03:36
Message: <3C4ED0D6.4084AD3C@atosorigin.com>
Warp wrote:

>   However, there's one big problem here: As far as I can see, the normal
> calculation function has no access to the incoming ray.
>   Any ideas?

Two...: 
 -(bad) Put the incoming ray in a global... not on the head, not on the head

 - Add a ray parameter to all the involved functions going from the function
   where it is needed upto the function it is already available.
   But you might end up with having to update all the objects (at least,
   the prototype of the functions). And stack size is not infinite...
    (ok, it can be just a pointer to the ray structure, that's not that big).


-- 
Non Sine Numine
http://grimbert.cjb.net/


Post a reply to this message

From: Christopher James Huff
Subject: Re: A possible solution, though difficult (Was: More info)
Date: 23 Jan 2002 10:31:50
Message: <chrishuff-92598E.10324823012002@netplex.aussie.org>
In article <3C4ED0D6.4084AD3C@atosorigin.com>,
 Jerome Grimbert <jer### [at] atosorigincom> wrote:

> Two...: 
>  -(bad) Put the incoming ray in a global... not on the head, not on the head

Not quite so bad, but still not good: put the incoming ray in the mesh 
struct. There shouldn't be anything that bothers it while the normal 
calculation is being done.


>  - Add a ray parameter to all the involved functions going from the function
>    where it is needed upto the function it is already available.
>    But you might end up with having to update all the objects (at least,
>    the prototype of the functions). And stack size is not infinite...
>     (ok, it can be just a pointer to the ray structure, that's not that big).

The best solution, but a pain to do.

-- 
 -- 
Christopher James Huff <chr### [at] maccom>


Post a reply to this message

From: Christopher James Huff
Subject: Re: A possible solution, though difficult (Was: More info)
Date: 23 Jan 2002 10:40:55
Message: <chrishuff-01879B.10415223012002@netplex.aussie.org>
In article <3c4ec167@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   The effect of this is that when the problematic case happens, the normal
> is inverted inside the heightfield code. Then it's inverted again at the 
> upper level, thus nullifying the inversion.

Yuck.

Any idea what the visual effects of this will be? I don't think it will 
look correct. You will be seeing a surface with the normal pointing away 
from you, I think that unless you toss an "fabs()" into the mix, you 
will end up with negative diffuse values.
Hmm, using "fabs()" might be a better method than inverting the normal 
anyway...

I still like my method: If the triangle normal is pointing towards you, 
but the interpolated normal is pointing away, ignore the intersection 
and the next one with the same object. The effect should be that you 
just don't see the corners that you shouldn't be seeing...it might even 
round out the outline a little.
This would probably be quite difficult to code, though...

-- 
 -- 
Christopher James Huff <chr### [at] maccom>


Post a reply to this message

From: Warp
Subject: Re: A possible solution, though difficult
Date: 23 Jan 2002 13:13:01
Message: <3c4efd2d@news.povray.org>
Christopher James Huff <chr### [at] maccom> wrote:
: Any idea what the visual effects of this will be?

  It will look correct (well, not 100% correct, but smooth triangle shading
is never 100% correct anyways).

: You will be seeing a surface with the normal pointing away 
: from you

  That doesn't matter because it's only used for the illumination, nothing
else.

: I think that unless you toss an "fabs()" into the mix, you 
: will end up with negative diffuse values.

  How so? From the point of view of the light source, nothing strange is
happening.
  It should work correctly in the way I proposed.

  And where do you propose to put the fabs()? I don't understand it.

: I still like my method: If the triangle normal is pointing towards you, 
: but the interpolated normal is pointing away, ignore the intersection 
: and the next one with the same object. The effect should be that you 
: just don't see the corners that you shouldn't be seeing...it might even 
: round out the outline a little.

  This will result in big holes in the mesh in some cases (note that the
normal vectors at the vertices of the triangles do *not* necessarily have to
be the average of the adjacent triangle normals; they can be anything).

-- 
#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

<<< Previous 7 Messages Goto Latest 10 Messages Next 10 Messages >>>

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