POV-Ray : Newsgroups : povray.bugreports : Normal scaling bug(s) : Re: Normal scaling bug(s) Server Time
24 Jun 2024 08:27:34 EDT (-0400)
  Re: Normal scaling bug(s)  
From: bugreports moderator
Date: 16 Dec 1999 04:25:30
Message: <3858b00a@news.povray.org>
On Sun, 05 Dec 1999 17:29:50 -0500, Nathan Kopp <Nat### [at] Koppcom>
wrote:

Nathan Kopp <Nat### [at] Koppcom> wrote...
>       if (Intersection->Object->UV_Trans)
>       {
>
> MInvTransNormal(LayNormal,LayNormal,Intersection->Object->UV_Trans);
>         VNormalizeEq(LayNormal);
>       }
>
>       Perturb_Normal(LayNormal, Layer->Tnormal, IPoint, Intersection);
>
>       if (Intersection->Object->UV_Trans)
>       {
>         MTransNormal(LayNormal,LayNormal,Intersection->Object->UV_Trans);
>         VNormalizeEq(LayNormal);
>       }

This code is WRONG!

If you do this, than transformations prior to applying the surface
normal
will affect the surface normal.  This is BAD.

The code should look more like this (provides backwards compatibility,
too):

      if (opts.Language_Version>3.1 &&
          Layer->Tnormal->Warps &&
          Layer->Tnormal->Warps->Warp_Type==TRANSFORM_WARP)
      {
        TRANS *Tr;
        Tr=(TRANS *)(Layer->Tnormal->Warps);
        MInvTransNormal(LayNormal, LayNormal, &(Tr->Trans));
        VNormalizeEq(LayNormal);
      }

      Perturb_Normal(LayNormal, Layer->Tnormal, IPoint, Intersection);

      if (opts.Language_Version>3.1 &&
          Layer->Tnormal->Warps &&
          Layer->Tnormal->Warps->Warp_Type==TRANSFORM_WARP)
      {
        TRANS *Tr;
        Tr=(TRANS *)(Layer->Tnormal->Warps);
        MTransNormal(LayNormal, LayNormal, &(Tr->Trans));
        VNormalizeEq(LayNormal);
      }

Note that this no longer requires UVTrans (which means that it could
be
applied to the official 3.1... after much more testing, of course).

-Nathan


Post a reply to this message

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