photon_switch VEX function

Takes three arguments which represent the probabilities for each of the reflective paths.

Context: photon

  1. int photon_switch(float diff, float spec, float transmit)

Takes three arguments which represent the probabilities for each of the reflective paths. The probabilities should add up to a number less than or equal to one. Based on the probabilities, one of the four paths will be returned.

The states are defined in shading.h:

#define PHOTON_STORE    0
#define PHOTON_DIFFUSE  1
#define PHOTON_REFLECT  2
#define PHOTON_TRANSMIT 3
For example:

result = photon_switch(.2, .1, .3);
…will return PHOTON_DIFFUSE (1) 20% of the time, PHOTON_REFLECT (2) 10% of the time, PHOTON_TRANSMIT (3) 30% of the time, and PHOTON_STORE (0) the rest of the time.