POV-Ray : Newsgroups : povray.advanced-users : triangle with smooth trasparency : Re: triangle with smooth trasparency Server Time
28 Jul 2024 18:21:07 EDT (-0400)
  Re: triangle with smooth trasparency  
From: Slime
Date: 8 Jun 2004 00:45:09
Message: <40c54455@news.povray.org>
> I must agree, seems to be the small size making it impossible for the
smooth
> transition of transparency.

After experimenting with the scene a bit, I've discovered that if his mesh
is made just three times as large, then the interpolation is smooth, so I
assume this is definitely a size issue.

But what's interesting is what happens when his mesh is made exactly twice
as large. Here's the code I'm using if you want to see for yourself (read
on, more text after code):

// CODE START

#declare scalar = 2;

#declare texture_1 = texture { pigment {color rgb 0 transmit 0 }}
#declare texture_2 = texture { pigment {color rgb 0 transmit 1 }}
#declare texture_3 = texture { pigment {color rgb 0 transmit .5 }}
#declare texture_4 = texture { pigment {color rgb 0 transmit 1 }}
#declare texture_5 = texture { pigment {color rgb 0 transmit 1 }}
#declare texture_6 = texture { pigment {color rgb 0 transmit .5 }}
#declare texture_7 = texture { pigment {color rgb 0 transmit 0 }}
#declare texture_8 = texture { pigment {color rgb 0 transmit 0 }}
#declare texture_9 = texture { pigment {color rgb 0 transmit 1 }}
#declare obj = mesh {
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0033,scalar*0.3,-sca
lar*0.0033>,<scalar*0.0065,scalar*0.2999,-scalar*0.0033>
texture_list { texture_1  texture_2  texture_6 } }
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0033,scalar*0.2999,-
scalar*0.0065>,<scalar*0.0033,scalar*0.3,-scalar*0.0033>
texture_list { texture_1  texture_9  texture_2 } }
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0065,scalar*0.2999,-
scalar*0.0033>,<scalar*0.0098,scalar*0.2998,-scalar*0.0033>
texture_list { texture_1  texture_6  texture_3 } }
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0098,scalar*0.2998,-
scalar*0.0033>,<scalar*0.0098,scalar*0.2998,-scalar*0.0065>
texture_list { texture_1  texture_3  texture_7 } }
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0098,scalar*0.2998,-
scalar*0.0065>,<scalar*0.0098,scalar*0.2997,-scalar*0.0098>
texture_list { texture_1  texture_7  texture_4 } }
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0098,scalar*0.2997,-
scalar*0.0098>,<scalar*0.0065,scalar*0.2998,-scalar*0.0098>
texture_list { texture_1  texture_4  texture_8 } }
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0065,scalar*0.2998,-
scalar*0.0098>,<scalar*0.0033,scalar*0.2998,-scalar*0.0098>
texture_list { texture_1  texture_8  texture_5 } }
   triangle
{<scalar*0.0065,scalar*0.2999,-scalar*0.0065>,<scalar*0.0033,scalar*0.2998,-
scalar*0.0098>,<scalar*0.0033,scalar*0.2999,-scalar*0.0065>
texture_list { texture_1  texture_5  texture_9 } }
   }

object {obj}
camera {
 location (min_extent(obj) + max_extent(obj))/2 + y*0.01*scalar
 look_at (min_extent(obj) + max_extent(obj))/2
}

background {rgb 1}

// CODE END


Modify the "scalar" value at the top to try different sizes.

When the mesh is this size, the transparency is solid only near the vertices
of the triangles. There's definitely some sort of check somewhere, maybe
against an epsilon value. After looking at the source for a while I can't
pin it down. I'd think it'd be either this line

if (Weight_List[i] < ADC_Bailout)

in lighting.cpp (though this should be fine since the sum of
Weight_List[0..2] at this point should be 1) or these lines

  if(a*a<EPSILON) {
    if(b*b<EPSILON) {
      if(c*c<EPSILON) {

in Calculate_Smooth_T() in triangle.cpp. Even that, though, shouldn't be a
problem, since EPSILON is 1e-10 and we're dealing with values which, when
squared, won't be any smaller than 1e-7 or so.

(As a side note, I'd like to point out that there are a lot of values in
Calculate_Smooth_T which are potentially never used. Their calculations
could probably be moved into the if() blocks to optimize.)

Strange results are also obtained when "scalar" is 1000 or 10000; I'm not
sure what the cause of this is.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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