POV-Ray : Newsgroups : povray.beta-test : Bug in trace function, normal flipped for text and prism objects? Server Time
27 Apr 2024 00:55:03 EDT (-0400)
  Bug in trace function, normal flipped for text and prism objects? (Message 1 to 2 of 2)  
From: Wouter
Subject: Bug in trace function, normal flipped for text and prism objects?
Date: 8 Feb 2013 16:10:01
Message: <web.5115687473e8d4b2b52b265c0@news.povray.org>
Using version: 3.7.0.RC6.msvc10.win64

Hi there,

I noticed some problems with the trace function:

- when using it on a text object: when you hit the side of a letter, the normal
that is returned is flipped (the exact opposite of what it should be). When you
hit the front of a letter the normal is correct.

- when using it on a prism object: varied results, at least partly depending on
the order of the points. Sometimes the sides of the prism return the correct
normal, sometimes flipped. Top and bottom are also unpredictable.

This is scene that will show some of the problems in the Messages window:

#version 3.7;
global_settings{ assumed_gamma 1.0 }
#declare Norm = <0,0,0>;

#warning "All objects are traced from <-100, 0, 0> in the direction <1, 0, 0>,"
#warning "so the normal is expected to be in the opposite direction."
#warning ""

#declare testBox = box{<1, 1, 1>, <-1, -1, -1>};
#declare Inter = trace(testBox, <-100, 0, 0>, <1, 0, 0>, Norm);
#warning concat("Trace a box, normal is: <", vstr(3, Norm, ", ", 0, 0), "> as
expected.")
#warning ""

#declare testTextSide = text {ttf "arial.ttf", "H", 0.3, 0 scale 3 translate<-1,
-1.1, -0.5> };
#declare Inter = trace(testTextSide, <-100, 0, 0>, <1, 0, 0>, Norm);
#warning concat("Trace the side of a letter, normal is flipped: <", vstr(3,
Norm, ", ", 0, 0), ">")
#warning ""

#declare testTextFront = object {testTextSide rotate y*90}
#declare Inter = trace(testTextFront, <-100, 0, 0>, <1, 0, 0>, Norm);
#warning concat("Trace the front of a letter, normal is: <", vstr(3, Norm, ", ",
0, 0), "> as expected.")
#warning ""

#declare testPrism = prism { -1, 1, 4  <0, -1>, <0, 1>, <1, 0>, <0, -1> }
#declare Inter = trace(testPrism, <-100, 0, 0>, <1, 0, 0>, Norm);
#warning concat("Trace a prism, normal is flipped: <", vstr(3, Norm, ", ", 0,
0), ">")
#warning ""

#declare testPrism2 = prism { -1, 1, 4  <0, 1>, <0, -1>, <1, 0>, <0, 1> }
#declare Inter = trace(testPrism2, <-100, 0, 0>, <1, 0, 0>, Norm);
#warning "Trace a prism with the same points in a different order, normal is: "
#warning concat("<", vstr(3, Norm, ", ", 0, 0), "> as expected.")
#warning ""


Post a reply to this message

From: clipka
Subject: Re: Bug in trace function, normal flipped for text and prism objects?
Date: 8 Feb 2013 19:24:44
Message: <5115974c$1@news.povray.org>
Am 08.02.2013 22:07, schrieb Wouter:
> Using version: 3.7.0.RC6.msvc10.win64
>
> Hi there,
>
> I noticed some problems with the trace function:
>
> - when using it on a text object: when you hit the side of a letter, the normal
> that is returned is flipped (the exact opposite of what it should be). When you
> hit the front of a letter the normal is correct.
>
> - when using it on a prism object: varied results, at least partly depending on
> the order of the points. Sometimes the sides of the prism return the correct
> normal, sometimes flipped. Top and bottom are also unpredictable.

I can confirm this behaviour. However, a quick check shows that this is 
nothing new: 3.6.2 gives the same results.

As a workaround, you can use the following code:

     #local Origin = <-100,0,0>;
     #local Dir = <1,0,0>;
     #local Norm = <0,0,0>;
     #declare Inter = trace(Obj,Origin,Dir,Norm);
     #if (vdot(Dir,Norm) > 0)
       #local Norm = -Norm;
     #end


Post a reply to this message

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