Image bump & displacement not working?

Help
fxnut
2004-10-05
2013-04-25
  • fxnut
    fxnut
    2004-10-05

    Hi guys,

    I'm not sure if I'm doing something wrong here since I'm fairly new to the whole renderman thing, but when I attempt to use an image for bump mapping or displacement, I get lots of artifacts at the edges of the micropolygon grids.

    E.g. for bump mapping in a shader using noise I might do this (simplified):

      float amp = float noise(20*P);
      N = calculatenormal(P + 0.03*amp * normalize(N));
      ...
      ... then go on and render a simple plastic surface

    if I swap the first line for this one:

      float amp = float texture("mytex.tex"[0]);

    then I get lots of nasty artifacts at grid boundaries. The artifacts are localised around areas that have large derivatives in the image (try using a large scale checker image to see what I mean). At a guess, it looks like the filtering isn't working properly.

    Can anyone else confirm this as a bug?

    Regards

    Andy

     
    • Okan Arikan
      Okan Arikan
      2004-10-08

         Hi Andy,

         Sorry about the late response.

         This may also be the patch crack issue which I'm trying to fix. Can you send me an example which demonstrates the problem ?

         PrMan has an internal patch stitching mechanisms which fills the cracks up even if the filter sizes don't match along a grid boundary. I will implement a similar mechanism for Pixie.

         However, this may also be a bug in filter size computation which I have not encountered before.

         Thanks

         Okan

       
      • fxnut
        fxnut
        2004-10-11

        Thanks for your reply Okan. I've included the RIB file and the SL file below. You'll need an image called "test.tif" (the higher the contrast, the better - I used a checker pattern image).

        BTW, if you comment out the "UseImage" define in the shader file, it uses noise instead, and this seems to work fine without any tearing, so it would appear to be an image only problem.

        A big thanks by the way for making Pixie freely available, it's an awesome piece of work. Without your work (and those other people who've developed free Renderman compliant renderers) it'd be very hard to get into the Renderman realm!

        Regards

        Andy

        ////////////////////////////////////
        //Test.rib
        ////////////////////////////////////

        Display "sphere1.tif" "framebuffer" "rgb"

        Projection "perspective" "fov" [30]

        Translate 0 0 6

        WorldBegin
            LightSource "DistantLight" 1 "intensity" [1.2] "from" [10 -10 2] "to" [0 0 0]
            LightSource "DistantLight" 2 "intensity" [1.2] "from" [0 10 2] "to" [0 0 0]   
            Surface "ImageTexture"
            Sphere 1 -1 1 360   
        WorldEnd

        ////////////////////////////////////
        //ImageTexture.sl
        ////////////////////////////////////

        //Some of this was sourced from Advanced Renderman (Apodaca, Gritz)

        #define UseImage

        surface ImageTexture (float Ka = 1, Kd = 0.5, Ks = 0.5, roughness = 0.1;
                         color specularcolor = 1;) {
                           
        #ifdef UseImage                
            color tex = color texture ("test.tif",s,t);   
            float amp = float texture ("test.tif"[0],s,t,"blur",0.05);   
        #else       
            color tex = float noise(20*P);   
            float amp = float noise(20*P);
        #endif
           
            N = calculatenormal(P + 0.03*amp * normalize(N));
            normal Nf = faceforward (normalize(N),I);
            Oi = Os;           
            Ci = Os * (tex * (Ka*ambient() + comp(tex,0)*Kd*diffuse(Nf)) + comp(tex,0) * specularcolor * Ks*specular(Nf,-normalize(I),roughness));
        }

         
    • Okan Arikan
      Okan Arikan
      2004-10-13

         Hi Andy,

         The problem is the blur parameter to the texture call. If the texture is unmade, Pixie will blur the texture by sampling. The default number of samples is 1. This means, the texture lookup will generate a noisy image. Calculatenormal function essentially differentiates this noisy image and creates the normal map which is itself noisy. If you increase the number of samples ("samples" parameter) or if you prepare the texture (using "texmake") command, you should have a smoother result.

          Okan

       
    • fxnut
      fxnut
      2004-10-13

      Hi Okan, yep that makes perfect sense, thanks.

      Having said that though, I've just played around with increasing the number of samples, as well as prefiltering the image, and while I do get a smoother result, there are still discontinuities in the shading at the borders of the micropolygon grids. I reckon this must be the filter size issue you were talking about.

      Regards

      Andy