POV-Ray : Newsgroups : povray.general : Bug in waves in 3.5? : Bug in waves in 3.5? Server Time
4 Aug 2024 22:17:15 EDT (-0400)
  Bug in waves in 3.5?  
From: Not My Real Email Address
Date: 10 Feb 2003 08:17:13
Message: <3e47a659@news.povray.org>
/*
OK, there is something different about the waves pattern in PovRay 3.5.

I found the following texture renders markedly differently in 3.5 compared
with both 3.0.20-10 debian and megapovplus 0.5.0.2.5a-1 (3.1 equivalent),
which both render the images similarly to each other.

It looks to me like the grade between 0 and 1.0 in the texture map of the
older versions is quite different to the grade in 3.5 .. for example as
if one used a linear gradient and the other an exponential one. I hope
someone understand what I mean.

In fact as outlined below, I found the cause is in the waves function,
not in the texture_map per se.

I don't see this particular case explained in the documentation or in the
bugs so far listed in povray.general or povray.bugreports, or by googling
old usenet postings.

I should have been more specific about the version I guess .. this is
3.50c for linux downloaded from povray.org as binary.

The problem occurs regardless of whether I declare #version 3.0 (or 3.1)
or just render it without the version declaration. It also occurs 
regardless of which of the three noise_generators are used.

*/
#include "colors.inc"
#version 3.0

//test.pov                  
//bah there is some bug in the 3.5 textures i think         
//Simeon Scott 2003-02-01 ////////////////////////
//Something like a blue agate.
/////////////////////////////


background
  { color White }

global_settings
{
  ambient_light 0.05
  assumed_gamma 1
//  noise_generator 1   /* line commented out
                          because it doen't fix it
                          and it breaks older versions.
                          Of course you should try it both
                          ways if you render the scene
                          in 3.5 to verify */
}

camera
{
  location <0, 0, -3>
  look_at <0, 0, 0>
  scale 0.2
}

light_source
  {  <2, 4, -3> color White scale 0.4 }

#declare Sim_Blue_Agate = texture
{
  waves
  texture_map	
  {
    [  0.15 pigment { color White }        ]
    [  1.0  pigment { color <0, 0, 0.3> }  ]
  }
  turbulence <10, 10, 0.3>
  scale 0.1
}

sphere
  {  <0, 0, 0>, 0.3	texture {  Sim_Blue_Agate } }

/*

http://bur.st/~shevek/test_3.0.jpg
http://bur.st/~shevek/test_mega0.5.jpg
http://bur.st/~shevek/test_3.5.jpg

Here is some of what I could garner from the documentation. Some people
suggested maybe the change in the noise_generator is what is causing my
problem. Changing to use noise_generator 1 doesn't fix the problem. But
who knows, maybe noise_generator 1 is what is broken. To try to find 
out, here is some stuff from the documentation:

    2.6.14  Changed features that may 'break' old scenes

    ...

    Noise:
    New noise functions have been added in POV-Ray 3.5. Noise functions 
    are internaly used in patterns. The default function in 3.5 is not 
    the same as it was in 3.1 and earlier. This may affect the appearence
    of textures in old scenes.
    Solution: put noise_generator 1 in global_settings{}.

    6.7.12.4  Noise Generators

    There are three noise generators implemented. Changing the 
    noise_generator will change the appearence of noise based patterns, 
    like bozo and granite.

    * noise_generator 1 the noise that was used in POV_Ray 3.1
    * noise_generator 2 'range corrected' version of the old noise, it 
      does not show the plateaus seen with noise_generator 1
    * noise_generator 3 generates Perlin noise

    The default is noise_generator 2

    Note: The noise_generator can also be set in global_settings

So it looks like indeed the 'noise generator' MAY be applicable, if it
is used in the waves function or in turbulence. Note that bozo is 
mentioned as definitely being affected. So let's compare bozo/granite 
and waves in functions.inc. But first, please note that setting 
noise_generator 1 does not recitfy the output.

From functions.inc

#declare f_bozo = function {f_noise3d(x, y, z)}
#declare f_granite = function {pattern {granite}}
#declare f_waves = function {pattern {waves}}

Well, that isn't very enlightening. The case is still open. So 
resorting to the source code, in patterns.cpp we find:

static DBL granite_pattern (VECTOR EPoint, TPATTERN *TPat)
{
  register int i;
  register DBL temp, noise = 0.0, freq = 1.0;
  VECTOR tv1,tv2;

  VScale(tv1,EPoint,4.0);

  int noise_generator;
  if (TPat != NULL)
    noise_generator = (TPat->Flags & NOISE_FLAGS) >> 4;
  if (!noise_generator)
    noise_generator=opts.Noise_Generator;

  for (i = 0; i < 6 ; freq *= 2.0, i++)
  {
    VScale(tv2,tv1,freq);
    if(noise_generator==1)
    {
      temp = 0.5 - Noise (tv2, TPat);
      temp = fabs(temp);
    }
    else
    {
      temp = 1.0 - 2.0 * Noise (tv2, TPat);
      temp = fabs(temp);
      if (temp>0.5) temp=0.5;
    }

    

    noise += temp / freq;
  }

  return(noise);
}


static DBL waves_pattern (VECTOR EPoint, TPATTERN *TPat)
{
  register unsigned int i;
  register DBL length, index;
  DBL scalar = 0.0;
  VECTOR point;

  for (i = 0 ; i < Number_Of_Waves ; i++)
  {
    VSub (point, EPoint, Wave_Sources[i]);
    VLength (length, point);

    if (length == 0.0)
    {
      length = 1.0;
    }

    index = length * TPat->Frequency * frequency[i] + TPat->Phase;

    scalar += cycloidal(index)/frequency[i];
  }

  scalar = 0.2*(2.5+(scalar / (DBL)Number_Of_Waves));

  return(scalar);
}


Looks to me like waves doesn't use the noise_generator. I wouldn't
testify in court because I didn't go through the whole code and 
I'm not exactly an expert at C/C++, but from that code, and the 
description in the manual, I'd say, waves doesn't use the noise 
generator.

Now what about turbulence? The documentation doesn't tell me 
whether it depends on noise_generator. But the source does:

DBL Turbulence(VECTOR EPoint,TURB *Turb,TPATTERN *TPat)
{
  int i;
  DBL Lambda, Omega, l, o, value;
  VECTOR temp;
  int Octaves=Turb->Octaves;
  int noise_generator = 0;
  
  
  if (TPat != NULL)
    noise_generator = (TPat->Flags & NOISE_FLAGS) >> 4;
  if (noise_generator == 0)
    noise_generator = opts.Noise_Generator;

  if ((noise_generator>1) && opts.Language_Version >= 350) {
      value = (2.0 * Noise(EPoint, TPat) - 0.5);
      value = min(max(value,0.0),1.0);
        } else {
      value = Noise(EPoint, TPat);
        }

  l = Lambda = Turb->Lambda;
  o = Omega  = Turb->Omega;

  for (i = 2; i <= Octaves; i++)
  {
    VScale(temp,EPoint,l);
    if ((noise_generator>1) && opts.Language_Version >= 350) {
      value += o * (2.0 * Noise(temp, TPat) - 0.5);
        } else {
      value += o * Noise(temp, TPat);
        }
    if (i < Octaves)
    {
      l *= Lambda;
      o *= Omega;
    }
  }
  return (value);
}

So I render the scene without turbulence. Guess what? Marked 
difference. You can see for yourself.

http://bur.st/~shevek/test_noturb_mega0.5.png
http://bur.st/~shevek/test_noturb_3.0.png
http://bur.st/~shevek/test_noturb_3.5.png

So the problem is not turbulence, which also means it is not 
noise_generator. It is waves, or it is texture_map.

So, render a texture_map using some different pattern than waves, 
and compare.

#declare Sim_Blue_Agate = texture
{
  agate
  texture_map	
  {
    [  0.15 pigment { color White }        ]
    [  1.0  pigment { color <0, 0, 0.3> }  ]
  }
//  turbulence <10, 10, 0.3>
  scale 0.1
}

Well, waddayaknow? The images are exactly the same. Problem solved, 
there IS SOMETHING DIFFERENT WITH THE WAVES FUNCTION IN POVRAY 3.5.
This is not documented in the manual, which means either the 
behaviour is a bug, or the manual has a bug.

http://bur.st/~shevek/test_notwaves_mega0.5.png
http://bur.st/~shevek/test_notwaves_3.0.png
http://bur.st/~shevek/test_notwaves_3.5.png

Simeon
*/


Post a reply to this message

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