Description This subroutine sets the type of directional sampling being used by an importance sample specification of a surface.
Syntax ImpSampSetDirectionSampleType( sNode, iSamp, sampType )
Parameters sNode As Long Node number of the surface whose importance sample is being modified.
iSamp As Long Index (0-based) of the importance sample on sNode whose direction sample type specification is being modified.
sampType As String Value indicating the type of directional sampling to be used. Options are: uniform – indicates that the subtended angular range of the importance sample is uniformly sampled by scattered rays with fluxes proportional to the BSDF function. This mode is most useful with BSDF functions that vary slowly over the subtended angular range. montecarlo – indicates that the subtended angular range of the importance sample is non-uniformly sampled, with ray densities proportional to the BSDF function, but the rays have equal flux weighting. This mode is most useful with BSDF functions that vary rapidly over the subtended angular range.
Example The example below removes all importance sample specifications from all surfaces, loops over the surfaces and identifies those that match some raytrace controls of interest, then assigns a new specular type importance sample to each surface and sets the ray count to 10 and the direction sample type to the Monte-Carlo option. Sub Main
'Delete all importance samples on all surfaces RemoveAllImpSampProp( 2 )
'Raytrace controls of interest Dim trans As Long, refl As Long, mech As Long trans = FindRaytraceCtrl( "Transmitting Optics" ) refl = FindRaytraceCtrl( "Reflective Optics" ) mech = FindRaytraceCtrl( "Mechanical Surfaces" )
Dim curEnt As Long, iSamp As Long, curCtrl As Long For curEnt = 0 To GetEntityCount()-1 If IsSurface(curEnt) Then
'Retrieve the surface's raytrace control and compare to those of interest curCtrl = GetSurfRaytraceCtrl( curEnt ) If (curCtrl = trans) Or (curCtrl = refl) Or (curCtrl = mech) Then
'Assign the specular type importance sample iSamp = ImpSampAddSpecular( curEnt, "Specular Direction", 2 ) ImpSampSetRayCount( curEnt, iSamp, 10 ) ImpSampSetDirectionSampleType( curEnt, iSamp, "montecarlo" )
End If
End If Next
'Update the model Update
End Sub
See Also Importance Samples Script Commands
|