37 #ifndef RixIntegrator_h
38 #define RixIntegrator_h
49 #include "RiTypesHelper.h"
58 static const RixChannelId k_InvalidChannelId = 2147483647;
128 int nChans,
RixChannelId const* ids,
int iCtxIndex,
float const value) = 0;
131 int nChans,
RixChannelId const*
id,
int iCtxIndex, RtColorRGB
const value) = 0;
171 float const distance,
172 bool const isVolume =
true,
208 virtual int AddSample(
int iCtxIndex) = 0;
263 k_rtTransmission = 3,
290 uint32_t privateData[4];
292 mutable uint16_t hitId;
320 this->shadingCtxIndex = _shadingCtxIndex;
322 if (this->lobeSampled.GetTransmit())
324 bool const entering = Dot(Ngn[_shadingCtxIndex], this->direction) <= 0.f;
325 this->lobeSampled.SetEntering(entering);
340 this->shadingCtxIndex = _shadingCtxIndex;
342 this->lobeSampled.Set(
351 this->lobeSampled.SetEntering(
true);
380 float rayOriginRadius,
381 float rayOriginSpread,
384 bool lightPath =
false)
386 float pdfSpread = 0.0f;
395 pdfSpread = 0.125f / sqrtf(fPdf);
412 float curvatureSpread = rayOriginSpread + 2.0f * curvature * rayOriginRadius;
413 newSpread = std::max(curvatureSpread, pdfSpread);
429 newSpread = std::max(rayOriginSpread, pdfSpread);
441 newSpread = rayOriginSpread;
445 if (!(newSpread <= 1.0f)) newSpread = 1.0f;
446 if (newSpread < -1.0f) newSpread = -1.0f;
447 assert(-1.0f <= newSpread && newSpread <= 1.0f);
449 this->raySpread = newSpread;
461 return wavelength != 0.0f ?
462 (int((wavelength - 380.0f) * (65534.0f / (780.0f - 380.0f)) + 0.5f) + 1) :
475 return encodedWavelength != 0 ?
476 (float(encodedWavelength - 1) * ((780.0f - 380.0f) / 65534.0f) + 380.0f) :
636 namespace RixConstants
640 static const int k_MaxRaysPerBatch = 32768;
663 virtual RixRefCntPtr<RixLPE> GetRixLPE(
int version = 1)
const = 0;
670 k_IncludeMisses = 0x02,
671 k_ConstrainToVolume = 0x04,
672 k_ContinuationOpacity = 0x08,
673 k_SkipVolumes = 0x10,
715 virtual void GetNearestHits(
721 RtUString
const subset,
722 RtUString
const excludeSubset,
754 virtual void GetNearestHits(
759 RtUString
const subset,
760 RtUString
const excludeSubset,
815 RtUString
const subset = US_NULL,
816 RtUString
const excludeSubset = US_NULL,
817 bool isLightPath =
false,
819 bool isPrimary =
false,
820 bool isVolume =
false,
821 bool stochasticMode =
true)
823 int nearestHitFlags =
824 (isPrimary ? k_Primary : k_None) |
825 (wantsMisses ? k_IncludeMisses : k_None) |
826 (isVolume ? k_ConstrainToVolume : k_None) |
827 (stochasticMode ? k_None : k_ContinuationOpacity);
831 GetNearestHits(nRays, rays, lobesWanted,
832 raytype, nearestHitFlags, subset, excludeSubset, hitSides, numShadingCtxs, shadingCtxs);
846 RtUString
const subset = US_NULL,
847 RtUString
const excludeSubset = US_NULL,
849 bool isPrimary =
false,
850 bool isVolume =
false,
851 bool stochasticMode =
true)
853 int nearestHitFlags =
854 (isPrimary ? k_Primary : k_None) |
855 (isVolume ? k_ConstrainToVolume : k_None) |
856 (stochasticMode ? k_None : k_ContinuationOpacity);
858 GetNearestHits(nRays, rays, raytype,
859 nearestHitFlags, subset, excludeSubset, hitSides, hits);
893 virtual void GetTransmission(
896 RtColorRGB* transmissions,
897 RtColorRGB* volumeEmissions,
899 RtUString
const subset = US_NULL,
900 RtUString
const excludeSubset = US_NULL) = 0;
910 virtual void ReleaseShadingContexts(
922 virtual void* Allocate(
size_t nObjs,
size_t objSize, MemCategory) = 0;
927 T* mem =
static_cast<T*
>(Allocate(nObjs,
sizeof(T), k_IntegratorMem));
931 template <
class T> T*
New(
size_t nObjs)
933 T* mem =
static_cast<T*
>(Allocate(nObjs,
sizeof(T), k_IntegratorMem));
934 return new (mem) T[nObjs];
956 virtual void RenderBegin(
975 PIXAR_ARGUSED(rixSCSyncMsg);
976 PIXAR_ARGUSED(rixParameterList);
1017 for (
int i = 0; i < *numShadingCtxs; ++i)
1022 for (
int j = 0; j < sCtx->
numPts; ++j)
1028 Integrate(*numShadingCtxs, shadingCtxs, iCtx);
1046 virtual void Integrate(
1065 RtColorRGB* transmissions,
1066 RtColorRGB* volumeEmissions,
1067 RtUString
const subset,
1068 RtUString
const excludeSubset,
1072 PIXAR_ARGUSED(nRays);
1073 PIXAR_ARGUSED(rays);
1074 PIXAR_ARGUSED(transmissions);
1075 PIXAR_ARGUSED(volumeEmissions);
1076 PIXAR_ARGUSED(subset);
1077 PIXAR_ARGUSED(excludeSubset);
1078 PIXAR_ARGUSED(lights);
1079 PIXAR_ARGUSED(iCtx);
1106 void const* results)
1108 PIXAR_ARGUSED(iCtx);
1109 PIXAR_ARGUSED(rayIds);
1110 PIXAR_ARGUSED(nRays);
1111 PIXAR_ARGUSED(rayProperty);
1112 PIXAR_ARGUSED(results);
1147 PIXAR_ARGUSED(iCtx);
1148 PIXAR_ARGUSED(rayIds);
1149 PIXAR_ARGUSED(nRays);
1150 PIXAR_ARGUSED(rayProperty);
1151 PIXAR_ARGUSED(values);
1174 PIXAR_ARGUSED(rixCtx);
1175 PIXAR_ARGUSED(handle);
1176 PIXAR_ARGUSED(instanceParams);
1177 PIXAR_ARGUSED(instanceData);
1184 PIXAR_ARGUSED(rixCtx);
1185 PIXAR_ARGUSED(handle);
1186 PIXAR_ARGUSED(instanceParams);
1187 PIXAR_ARGUSED(editHints);
1188 PIXAR_ARGUSED(instanceData);
1194 virtual void DestroyIntegrator(
RixIntegrator const* integrator) = 0;
1203 #define RIX_INTEGRATORFACTORYCREATE \
1204 extern "C" PRMANEXPORT RixIntegratorFactory* CreateRixIntegratorFactory(const char* hint)
1206 #define RIX_INTEGRATORFACTORYDESTROY \
1207 extern "C" PRMANEXPORT void DestroyRixIntegratorFactory(RixIntegratorFactory* factory)