Menu

Need help with writing shader

Help
PhilB
2010-12-24
2013-04-25
  • PhilB

    PhilB - 2010-12-24

    Hello all,
    I am trying to use raymarching, thus I've written an interior volume shader which basically should return a value equal to the length of the ray going through object (I understand Pixie implements interior volume shader, right ?).
    Unfortunately, I only get a completely black image. Could anyone point my mistake ?
    Below, the shader script and the RIB file. BTW, I use Pixie 2.2.5.
    Thanks
    PhilB

    **** My shader ****
    volume thickness ()
      {
      point  frontP = P - I;
      point  currP = frontP;
      float  totalDist = length(I);
      float  accumulatedValue = 0;
      float stepSize=0.1;
      float currDist=0;

      while(currDist <= totalDist)
        {
        // Notice that I/totalDist is the normalized vector I
        // multiplying by a float (currDist) is a vector aligned with I
        currP = frontP + (currDist/totalDist) * I;

        accumulatedValue += stepSize;

        // Prepare for the next iteration of the loop
        currDist += stepSize;
        }
      // Modify the output colors.
      Ci = accumulatedValue;
      }

    **** My RIB file calling the above shader ****
    Display "sphere3.tif" "framebuffer" "rgb"
    Projection "perspective" "fov"
    Translate 0 0 30
    WorldBegin
      Atmosphere "thickness"
      Opacity 0.1 0.1 0.5
      Sphere 10 -10 10 360
    WorldEnd

     
  • PhilB

    PhilB - 2010-12-24

    Sorry, the RIB file should read:
    Display "sphere3.tif" "framebuffer" "rgb"
    Projection "perspective" "fov"
    Translate 0 0 30
    WorldBegin
      Interior "thickness"
      Sphere 10 -10 10 360
    WorldEnd

     
  • PhilB

    PhilB - 2011-01-03

    OK, maybe this is not the right place for this request…
    Would someone be kind enough to point me towards the right forum to post questions regarding interior volume shaders ?
    TIA
    Phil

     

Log in to post a comment.