raytracing quality

Help
rendetto
2007-05-14
2013-04-25
  • rendetto
    rendetto
    2007-05-14

    Hi! Im using raytraced shadows and pixie's mirror shader in a test scene.
    I've noticed that the shadows and reflections look some kind aliased.
    Antialiasing filters doesn't solve the problem. I've read that using shading rate of 1 is normal for quality. But aliasing artefacts are present on shading rate 1. Only using values low than 0.5 solved the quality problem, but the rendertime became unreasonable long.
    Is there a way to solve this without lowering the shading rate.

    You can download my scene from here:

    http://85.187.2.208/ray.rar

    The blenderspot light, I've used, is the one from blender2pixie exporter from Cedric PAILLE, it is very similar to pixie's shadowspot.

    Thanks.

    rendetto

     
    • George Harker
      George Harker
      2007-05-14

      Hi Rendetto,

      As with all things renderman, this requires a little bit of tweaking.

      For the surface shader, we shade only once for each shading point - the number of which can be increased using the ShadingRate Ri call.  But as you point out this is rather a sledgehammer to crack a nut.

      One thing that would certainly help is to turn on jittering in the hider.  Appologies, I don't know the blender exporter very well (though I wish I did).  This RIB line:

         Hider "hidden" "float jitter" 0.0

      is better with jittering on

         Hider "hidden" "float jitter" 1.0

      Secondly, avoid the trace() call which is amongst the dumbest in SL.  You can't specify multiple samples for it, and it gives very little control.  However, you're already doing this.

      Finally, you achieve ray antialiasing by firing more samples, and by allowing Pixie to jitter their direction.

      surface mirror(float Ka=1,Ks=1,Kr=1,roughness=.1,samples=1,blur=0; string texname="raytrace") {
      //....
          Ci = Os * (Cs * ( Ka*ambient() + Ks*specular(Nf,-I,roughness) ) +
                    Kr*environment(texname,R,"samples",samples,"blur",blur));
      }

      In the current shader, blur controls the jittering of the rays.  A value of 0 means all rays go the same way, and 1 means rays fire over a solid hemisphere.

      You may find the samplecone parameter easier to deal with, which is a number of degrees in radians to jitter rays

      surface mirror(float Ka=1,Ks=1,Kr=1,roughness=.1,samples=1,samplecone=0; string texname="raytrace") {
      //...
          Ci = Os * (Cs * ( Ka*ambient() + Ks*specular(Nf,-I,roughness) ) +
                    Kr*environment(texname,R,"samples",samples,"samplecone",samplecone));
      }

      Don't use both samplecone and blur because they control the same thing.

      Finally, the mirror shaders should have their number of samples turned up, and the coneangle set appropritately.  For example:

               Surface "mirror.sdr"  "string texname" ["raytrace"] "float Ks" [1.0] "float Kr" [1.0] "float samples" [8.0] "float Ka" [1.0] "float roughness" [0.1] "float blur" [0.0] "samplecone"  0.008

      Seems to work OK for your example - maybe a bit too blurry though.

      In terms of the shadows, you could do similarly (the shadow call also takes a blur parameter).  Or you could just edge up the blur and the number of samples.

      Note that increasing blur without increasing the samples will just add noise.  Conversely, increasing the number of samples without giving Pixie room to blur will just take longer for very little benefit.

      Hope that helps.

      Cheers

      George

       
    • George Harker
      George Harker
      2007-05-14

      You may also find that rays are sneaking inside the prism and taking a long time bouncing round.  It might be worth making it one sided.

      Cheers

      George

       
    • rendetto
      rendetto
      2007-05-15

      Thanks George,

      While digging around I found some interesting things about pixie's raytracing behaviour.
      The problem with aliased raytraced shadows and reflections is solved in. But all seems to be complicated in some way.

      I did saw the blur(or conetrace) technique in the cornellbox example while ago,
      It seems to produce just blurred reflections, rather than antialiasing the reflections.
      When I want to have sharp reflection I have to use smaller blur values.
      Small blur values (under 0.0005) combined even with higher samples values can't remove aliasing, just partially.
      The artefact stays present until I use higher blur values  - but doing that I miss sharp reflections :) Only when I use shading rate below 0.5 jagged edges are refined.

      All it seem to be characteristic of hider "hidden", When I invoke the "raytrace" hider instead, the shadows and reflections became perfectly antialiased, even setting "jitter" to 0.0

      When using hider "raytrace" the shading rate values doesn't affect the filal quality of the image, only global antialiasing filter samples and pixel samples affect the image quality, Can you explain that behaviour.

      I'm curious why samples seen in blurred reflections(and blurred shadows) are different for these two hiders? Raytrace hider samples look finer than those used with "hidden" hider.     

      I couldn't compare lower shading rates with just using raytrace hider because the rndr option "-t" doesn't works in 2.1.1 I hope you turn it back in the next release.

      You can download another test scene that I used from:

      http://85.187.2.208/spheres.tar.gz
       
      Thanks,

      rendetto

       
      • Okan Arikan
        Okan Arikan
        2007-05-15

           Hi Rendetto,

           You're right, if the hider is set to "raytrace", the shading rate is ignored. For every ray we shoot we shade the intersection point. This is why raytrace hider gets pretty inefficient for high pixel samples.

           In general, you should use raytrace only when you need to bake some computation only for the visible points from the camera (because only those points will be shaded with the raytrace hider).

           I'm aware of the aliasing problem with the default. I'm working on this problem.

           Okan

         
    • rendetto
      rendetto
      2007-05-16

      Thanks Okan,

      By the way I was wrong about the -t option. It is working.

      Keep up the good work,

      rendetto

       
      • George Harker
        George Harker
        2007-05-16

        Hi Rendetto.

        As Okan says, we're working on a solution to ensure that when multiple samples are used, the ray origin is jittered slightly (so you don't have to set the cone if you want sharp reflections).

        One thing I really should have mentioned, is that when using multiple samples, with lots of reflective surfaces, you can end up in a situation where you fire 8 rays, they all hit a mirrored surface and fire 8 more - giving a exponential growth of rays.  You can coarsely control this with:

           Option "trace" "maxdepth" 10

        To control the maximum depth at whcih rays are still cast.

        But it's far better to explicity control it in your shader like so:

            uniform float samp = samples;
            if (raydepth() > 2) samp = 1;
           
            Oi = Os;
            Ci = Os * (Cs * ( Ka*ambient() + Ks*specular(Nf,-I,roughness) ) +
                      Kr*environment(texname,R,"samples",samp,/*"blur",blur,*/"samplecone",samplecone));

        Or even control the depth at which you stop bothering to trace at all.

        This makes a _big_ speed difference.

        cheers

        George

         
    • rendetto
      rendetto
      2007-05-20

      Thanks George,

      Using maxdepth is really time saving, especially for blurred reflections.
      But I don't really understand what means: if (raydepth() > 2) samp = 1;
      Does it mean that after a ray hits 2 reflective surfaces with blurred reflections,
      when it hits a third blurred surface it won't calculate blurring?
      Using this "if" statement in the mirror shader produces strange behaviour - some of surfaces with the shader
      didn't reflect at all.

      Thanks,

      rendetto

       
      • George Harker
        George Harker
        2007-05-20

        Hi Rendetto,

        The numbers I picked are probably pretty dumb - but the point was to demonstrate that after some number of blurred reflections, the fidelity of 4th/5th/6th bounces is not so important.  The first and second bounces will have already blurred out detail that you might get with higher sample counts at greater ray depths.

        Obviously if _every_ ray hits another reflective surface then you have an expansion factor of the number of samples at each depth.  That pretty quickly gets expensive.  The idea here is to limit that expansion in cases where visually it shouldn't matter.

        In fact it's likely there's a bug that can prevent this working right in the current release.  There is working code in svn and we're working towards a release.

        Cheers

        George