Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

LightFilter "PxrGobo" "gobo1"  "string coordSys" ["Gobo1"] "string map" ["ratGrid.tx"]
AreaLightSource "PxrArealight" "light1"

...

Like pattern plugins, light filters are supplied a context. The RixLightFilterContext is The RixLightFilterContext is a subset of the RixShadingContext and the RixShadingContext and does not support full pattern generation (there is no EvalParam() is not supported). That capability is under consideration for future releases.

Light filtering happens after lighting services has picked which lights will be sampled for each point in a shading context. The RixLightFilterContext member variable numPts is The RixLightFilterContext member variable numPts is the number of points in the underlying shading context. Light filters are called on a light-by-light basis, and not all of the points in a shading context will be getting a sample from a given light. Some may get zero samples, others may get multiple samples. For this reason, the Filter call is sample-centric: it operates over the samples generated for a given light.

The shadingCtxIndex maps The shadingCtxIndex maps a particular sample back to the point on the shading context for which it was generated.

The three lighting arrays toLightarrays toLight,  dist dist, and lightPdfIllumand lightPdfIllum, are numSamples in  in length. These are the vector to the light, the distance from the point on the shading context to the sample point on the light, and the pdf of the sample on the light.

The input/output array contribution contains the lighting contribution distributed into some number of diffuse and specular lobes. For each lobe there are numSamples entries entries. For instance, to modulate the lighting by a filter that passes only the red channel:

...

Like bxdfs, light filters can be parameters to other light filters. The last filter given before an AreaLightSource call (the root filter in a tree of filters) is responsible for delegating to the filters in its parameter list. Furthermore, light filters can be disabled on a gprim basis. To respect this, it is the responsibility of the filter to call RixLightFilterContextcall RixLightFilterContext::IsEnabled(). If the upstream filter is not enabled, don't run it. IsEnabled also  IsEnabled() also returns a pointer to the upstream filter's instanceData, which should be passed to its Filter methodits Filter() method.

void combiner::Filter(RixLightFilterContext const *lfCtx,
                  RtConstPointer instanceData,
                  RtInt const numSamples,
                  RtInt const * shadingCtxIndex,
                  RtVector3 const * toLight,
                  RtFloat const * dist,
                  RtFloat const * lightPdfIllum,
                  RixBXLobeWeights *contribution
                 )
{
  myData const * mydata = (myData const *) instanceData;

  for (int i=0; i<mydata->arrayLen; ++i) {
      RtConstPointer nextInstanceData;
      if (lfCtx->IsEnabled(mydata->instances[i], &nextInstanceData))
      {
          mydata->filters[i]->Filter(
              lfCtx, nextInstanceData,
              numSamples, shadingCtxIndex,
              toLight, dist, lightPdfIllum, contribution);
      }
  }
}