POV-Ray : Newsgroups : povray.general : Help in optimizing a scene Server Time
30 Jul 2024 02:19:33 EDT (-0400)
  Help in optimizing a scene (Message 1 to 4 of 4)  
From: ruy
Subject: Help in optimizing a scene
Date: 14 Apr 2010 14:10:01
Message: <web.4bc6040077295221ad2eb90@news.povray.org>
Hello again,

If this is too much to ask, or if there is a tutorial that may help me figure
things out by myself, please just give the word, OK?

I could use some help with optimization. The way the scene listed below is coded
at the moment  makes it all but impossible to render with the resources I have
at hand.

Of course I had to use a lot of things that are time-consuming, like radiosity
and glass, but I sense that there is some room for improvement. If someone could
help I would be very grateful.


orange areas). I believe this is due to the very high density of blob points in
this region, but I am not sure. I tried to mitigate this problem by reducing the
points in the lower 1/7th of the spiral, and it seems to have helped to some
extent.

Still, a 320x240 render is taking over 8 hours in a Core2Duo with 4GB of RAM
(Windows 7, with little else running in parallel).

Any tips on how to optimize this scene?

Thanks in advance,

Ruy

/*************************************************************************/
/*                                                                       */

/*                                                                       */
/*  All Rights Reserved                                                  */
/*                                                                       */

/*                                                                       */
/*************************************************************************/

#include "colors.inc"
#include "functions.inc"

// My own macro fro changing HSV into RGB
// Differs from the one in colors.inc because it allows for a transmission
// of 0.5 (makes it "glassy"),which unfortunately makes it also extremely
// slow to render.
#macro R_CHSV2RGB(Color)
   #local HSVFT = color Color;
   #local H = (HSVFT.red);
   #local S = (HSVFT.green);
   #local V = (HSVFT.blue);
   #local SatRGB = CH2RGB(H);
   #local RGB = ( ((1-S)*<1,1,1> + S*SatRGB) * V );
   <RGB.red,RGB.green,RGB.blue,(HSVFT.filter),0.5>// (HSVFT.transmit)>
#end

// I'm not sure these focal blur settings are affecting the render time too
// negatively. It doesn't seem so, and quality seems to be OK.
camera{
 location < 0, 150, -1000 >
 look_at < 0, 0, 0.000 >
 angle 1.000

 focal_point < 0, 20, 0.000 >
 aperture 10
 blur_samples 50
}

// Single frontal light source, placed in order to create a nice light trail
// on the water surface.
light_source{<100, 50, 3000> rgb 1}


// Radiosity settings is something I haven't mastered yet. The effect seems
// to be OK, and comparing their rendering process with the rendering of the
// glassy blob seems to indicate that my problems lie elsewhere.
global_settings{
  adc_bailout 0.0039
  ambient_light rgb <255/255,255/255,255/255>
  assumed_gamma 2.200
  hf_gray_16 0
  irid_wavelength rgb <68/255,46/255,36/255>
  max_intersections 64
  max_trace_level 10
  number_of_waves 1

  radiosity {
    pretrace_start 0.08
    pretrace_end   0.005
    count 400
    error_bound 0.5
    recursion_limit 1
    low_error_factor .15
    gray_threshold 0.0
    minimum_reuse 0.015
    brightness 1
    adc_bailout 0.01/2
  }
}

// A simple sky sphere. light blue hue is used mostly for the effect on the
// water surface.
sphere {
  <0, 0, 0>, 1
  texture {
    pigment {
      gradient y
      color_map {
        [0.0 color rgb < 0.90, 01.0, 1.0 >]
        [0.0 color rgb < 0.90, 01.0, 1.0 >]
      }
    }
    finish { diffuse 0 ambient 1 }
  }
  hollow on
  no_shadow
  scale 30000
}


// The water, with a material taken from the tutorial by Christoph Hormann.
// I do like it, but it seems to be inverted, that is: instead of crests I
// see grooves. I could be wrong.
plane { y, -1.0
  material {
    texture {
      pigment {
        color rgbt <.1, .1, .1, .1>
      }
      finish {
        ambient 0.0
        diffuse 0.0

        reflection {
          0.0, 1.0
          fresnel on
        }

        specular 0.8
        roughness 0.001
      }
      normal {
        function {
          f_ridged_mf(x, y, z, 0.1, 3.0, 7, 0.7, 0.7, 2)
        } 0.8
        scale 3
      }
    }
    interior {
      ior 1.3
    }
  }
}

// The ascending spiral, the main object in the scene. I believe my problem
// lies in the fact that the initial points are too condensed together in
// the base of the spiral, and hence the use of only every fifth point in
// the bottom 1/7 of the spiral.
blob {
    threshold .0005

    #declare Cr = 0;
    #declare Mx = 2430;
    #declare Me = Mx/2;
    #declare Rd = 0.1;
    #declare Ap = 1;
    #declare As = 1;
    #declare Vl = 1;
    #while (Cr <= Mx)
      #if (Cr<(Mx/7))
        #if (mod (Cr,5) = 0)
               sphere { <0,0,0>, 1.3 ,1
                 translate <Cr*Ap*Rd*Rd, Cr*Vl*Rd*Rd*1.3, Cr*As*Rd*Rd>
                 rotate y*Cr*Vl
                 texture {
                         pigment{rgbft R_CHSV2RGB(<(Cr/Mx)*300, 1.0, 1.0>)
                         }
                         finish {
                                ambient 0.4
                                diffuse 0.1
                                reflection .25
                                specular 1
                                roughness .001
                          }
                 }
               }
        #end
      #else
               sphere { <0,0,0>, 1.3 ,1
                 translate <Cr*Ap*Rd*Rd, Cr*Vl*Rd*Rd*1.3, Cr*As*Rd*Rd>
                 rotate y*Cr*Vl
                 texture {
                         pigment{rgbft R_CHSV2RGB(<(Cr/Mx)*300, 1.0, 1.0>)
                         }
                         finish {
                                ambient 0.4
                                diffuse 0.1
                                reflection .25
                                specular 1
                                roughness .001
                          }
                 }
               }
      #end
      #declare Cr = Cr + 1;
    #end
    no_shadow
    interior { ior 1.2 }
  }


Post a reply to this message

From: clipka
Subject: Re: Help in optimizing a scene
Date: 14 Apr 2010 14:21:29
Message: <4bc607a9$1@news.povray.org>
Am 14.04.2010 20:08, schrieb ruy:


> orange areas). I believe this is due to the very high density of blob points in
> this region, but I am not sure. I tried to mitigate this problem by reducing the
> points in the lower 1/7th of the spiral, and it seems to have helped to some
> extent.

You're using a blob with refractive and reflective members. I'm not sure 
about 3.6, but until recently 3.7 betas were prone to run into endless 
recursions there.

If 3.6 suffers from the same ailment, it should suffice to give the blob 
as a whole a reflective and refractive texture as well; with all members 
having their individual textures, this will have no further effect 
except forcing a flag that prevents the endless recursions.

In current 3.7 betas, this problem should be fixed.


Post a reply to this message

From: ruy
Subject: Re: Help in optimizing a scene
Date: 15 Apr 2010 08:10:01
Message: <web.4bc7018ab216ab30ab3787c40@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> You're using a blob with refractive and reflective members. I'm not sure
> about 3.6, but until recently 3.7 betas were prone to run into endless
> recursions there.
>
> If 3.6 suffers from the same ailment, it should suffice to give the blob
> as a whole a reflective and refractive texture as well; with all members
> having their individual textures, this will have no further effect
> except forcing a flag that prevents the endless recursions.
>
> In current 3.7 betas, this problem should be fixed.

Excellent advice!

I simply took the "finish" blocks out of the #while loop, and this alone made it
around 7 times faster, by my calculations.

I don't know if there are other tweaks to the scene (I'm looking into radiosity
right now, as it seems to be a good candidate for optimization), bu this already
makes it feasible to render the scene.

Thanks a lot! :D


Post a reply to this message

From: Alain
Subject: Re: Help in optimizing a scene
Date: 15 Apr 2010 14:15:44
Message: <4bc757d0@news.povray.org>

> Hello again,
>
> If this is too much to ask, or if there is a tutorial that may help me figure
> things out by myself, please just give the word, OK?
>
> I could use some help with optimization. The way the scene listed below is coded
> at the moment  makes it all but impossible to render with the resources I have
> at hand.
>
> Of course I had to use a lot of things that are time-consuming, like radiosity
> and glass, but I sense that there is some room for improvement. If someone could
> help I would be very grateful.
>

> orange areas). I believe this is due to the very high density of blob points in
> this region, but I am not sure. I tried to mitigate this problem by reducing the
> points in the lower 1/7th of the spiral, and it seems to have helped to some
> extent.
>
> Still, a 320x240 render is taking over 8 hours in a Core2Duo with 4GB of RAM
> (Windows 7, with little else running in parallel).
>
> Any tips on how to optimize this scene?
>
> Thanks in advance,
>
> Ruy
>

Sometimes, you can increase adc_bailout to around 0.01. Depending on the 
scene, the effect can be imperciptible and speed things up noticably.
Toghether with a larger adc_bailout, you can increase max_trace_level. A 
value of 10 don't look like is't large enough.

Move your finish to the end of the blob so that it's applied once to the 
whole blob instead of to each individual components.

As this is a radiosity scene, your spiral is lighting it's surrounding. 
Be sure to set ambient 0 for everything else.

You use an extremely small threshold value for the blob. This can cause 
some artefacts. Try using a larger one and increase the radius 
acordingly. It will also give you smoother surface.



Alain


Post a reply to this message

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