bool MaterialBasicRefractive::OutputRay( const Ray& incident, DifferentialGeometry* dg, RandomDeviate& rand, Ray* outputRay ) const { double randomNumber = rand.RandomDouble(); if( dg->shapeFrontSide ) { if ( randomNumber < reflectivityFront.getValue() ) { *outputRay = *ReflectedRay( incident, dg, rand ); return true; } else if ( randomNumber < ( reflectivityFront.getValue() + transmissivityFront.getValue() ) ) { *outputRay = *RefractedtRay( incident, dg, rand ); return true; } else return false; } else { if ( randomNumber < reflectivityBack.getValue() ) { *outputRay = *ReflectedRay( incident, dg, rand ); return true; } else if ( randomNumber < ( reflectivityBack.getValue() + transmissivityBack.getValue() ) ) { *outputRay = *RefractedtRay( incident, dg, rand ); return true; } else return false; } }
bool MaterialAngleDependentRefractive::OutputRay( const Ray& incident, DifferentialGeometry* dg, RandomDeviate& rand, Ray* outputRay ) const { NormalVector dgNormal; if( dg->shapeFrontSide ) dgNormal = dg->normal; else dgNormal = - dg->normal; double incidenceAngle = acos( DotProduct( -incident.direction(), dgNormal ) ); std::vector< double> reflectivityTransmissivity = OutputPropertyValue( m_frontReflectivityIncidenceAngle, m_frontReflectivityValue, m_frontTransmissivityValue, incidenceAngle ); double reflectivity = reflectivityTransmissivity[0]; double transmissivity = reflectivityTransmissivity[1]; double randomNumber = rand.RandomDouble(); if( dg->shapeFrontSide ) { if ( randomNumber < reflectivity ) { *outputRay = *ReflectedRay( incident, dg, rand ); return true; } else if ( randomNumber < ( reflectivity + transmissivity ) ) { *outputRay = *RefractedtRay( incident, dg, rand ); return true; } else return false; } else { if ( randomNumber < reflectivity ) { *outputRay = *ReflectedRay( incident, dg, rand ); return true; } else if ( randomNumber < ( reflectivity + transmissivity ) ) { *outputRay = *RefractedtRay( incident, dg, rand ); return true; } else return false; } }