POV-Ray : Newsgroups : povray.binaries.images : Question regarding mesh and texture_list Server Time
6 Nov 2024 02:21:37 EST (-0500)
  Question regarding mesh and texture_list (Message 1 to 3 of 3)  
From: BayashiPascal
Subject: Question regarding mesh and texture_list
Date: 24 May 2021 00:30:00
Message: <web.60ab28c3e105b2bda3e088d5e0f8c582@news.povray.org>
Hi everyone,
I have a question regarding texture_list applied to mesh of very small size.
I've noticed that in such case artifacts appear in the texture. I can avoid the
problem by scaling up the input mesh (generated by another app), and scaling it
back down in the POV-Ray script, but if possible I'd like to avoid that.
I guess this is a problem related to numerical accuracy, so maybe there is a
parameter somewhere that would help ?? Or, is there something else I'm not aware
of, and doing wrong ?
Please find below a small script reproducing the problem. In the rendered image,
both triangles should look the same. The left one has initial coordinates of
order 0.01, while the right one has initial coordinates of order 0.1 and is
scaled by 0.1. These doesn't look to me as unreasonably small values...
(The same artifact occurs if using mesh2)

Thanks in advance for your help.
Pascal



#version 3.7;

#declare tex0 = texture {pigment{rgb x}};
#declare tex1 = texture {pigment{rgb y}};
#declare tex2 = texture {pigment{rgb z}};

#declare meshA = mesh {
  triangle{
    <0.7,0.06,-0.06> ,<0.66,0.06,-0.1> ,<0.7,0.06,-0.1>
    texture_list {tex0 tex1 tex2}
  }
}

#declare meshB = mesh {
  triangle{
    <0.07,0.006,-0.006> ,<0.066,0.006,-0.01> ,<0.07,0.006,-0.01>
    texture_list {tex0 tex1 tex2}
  }
}

camera { location 0.01 look_at 0.005*x }
light_source { 1 color rgb 1 }

object {
  meshA
  scale 0.1
  translate <0.07,0.006,-0.006>*-1
}

object {
  meshB
  translate <0.07,0.006,-0.006>*-1
  translate x*0.01
}


Post a reply to this message


Attachments:
Download 'bugmeshtexture.png' (15 KB)

Preview of image 'bugmeshtexture.png'
bugmeshtexture.png


 

From: William F Pokorny
Subject: Re: Question regarding mesh and texture_list
Date: 24 May 2021 02:45:59
Message: <60ab4ba7$1@news.povray.org>
On 5/24/21 12:25 AM, BayashiPascal wrote:
> Hi everyone,
> I have a question regarding texture_list applied to mesh of very small size.
> I've noticed that in such case artifacts appear in the texture. I can avoid the
> problem by scaling up the input mesh (generated by another app), and scaling it
> back down in the POV-Ray script, but if possible I'd like to avoid that.
> I guess this is a problem related to numerical accuracy, so maybe there is a
> parameter somewhere that would help ?? Or, is there something else I'm not aware
> of, and doing wrong ?

Yes, numerical accuracy it is.

In the POV-Ray source there is a defined EPSILON value of 1e-10 which 
over time tended to be used whenever someone had need of a small 
'epsilon' value.

However, there isn't a one size fits all EPSILON value. It depends on 
the math being done. In triangle.cpp there is a function:

SmoothTriangle::Calculate_Smooth_T(..._)

with some code which reads:

     if(dm1*dm1<EPSILON)
     {
         if(dm2*dm2<EPSILON)
         {
             if(dm3*dm3 < EPSILON)
             {...

Using an 'epsilon' value of gkDBL_epsilon (~4.4e-16) which is generally 
good for simpler double math, the textures for both your triangles 
interpolate well.

The updated code looks like:

     if(dm1*dm1 < gkDBL_epsilon)
     {
         if(dm2*dm2 < gkDBL_epsilon)
         {
             if(dm3*dm3 < gkDBL_epsilon)
             {...

Note. There's still a numerical limit to hit if you make things small 
enough. In fact, in the very corners of each triangle it's probably 
still tripped sometimes for the conditionals above; We just can't see it.

Bill P.


Post a reply to this message

From: BayashiPascal
Subject: Re: Question regarding mesh and texture_list
Date: 24 May 2021 03:45:00
Message: <web.60ab59244094e1f1a3e088d5e0f8c582@news.povray.org>
Thanks for your reply !


William F Pokorny <ano### [at] anonymousorg> wrote:
> On 5/24/21 12:25 AM, BayashiPascal wrote:
> > Hi everyone,
> > I have a question regarding texture_list applied to mesh of very small size.
> > I've noticed that in such case artifacts appear in the texture. I can avoid the
> > problem by scaling up the input mesh (generated by another app), and scaling it
> > back down in the POV-Ray script, but if possible I'd like to avoid that.
> > I guess this is a problem related to numerical accuracy, so maybe there is a
> > parameter somewhere that would help ?? Or, is there something else I'm not aware
> > of, and doing wrong ?
>
> Yes, numerical accuracy it is.
>
> In the POV-Ray source there is a defined EPSILON value of 1e-10 which
> over time tended to be used whenever someone had need of a small
> 'epsilon' value.
>
> However, there isn't a one size fits all EPSILON value. It depends on
> the math being done. In triangle.cpp there is a function:
>
> SmoothTriangle::Calculate_Smooth_T(..._)
>
> with some code which reads:
>
>      if(dm1*dm1<EPSILON)
>      {
>          if(dm2*dm2<EPSILON)
>          {
>              if(dm3*dm3 < EPSILON)
>              {...
>
> Using an 'epsilon' value of gkDBL_epsilon (~4.4e-16) which is generally
> good for simpler double math, the textures for both your triangles
> interpolate well.
>
> The updated code looks like:
>
>      if(dm1*dm1 < gkDBL_epsilon)
>      {
>          if(dm2*dm2 < gkDBL_epsilon)
>          {
>              if(dm3*dm3 < gkDBL_epsilon)
>              {...
>
> Note. There's still a numerical limit to hit if you make things small
> enough. In fact, in the very corners of each triangle it's probably
> still tripped sometimes for the conditionals above; We just can't see it.
>
> Bill P.


Post a reply to this message

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