color getPhong( const normal& i_N, const vector& i_V, const float cosinePower, const eiBool i_keyLightsOnly, const eiBool unshadowed) { color C = 0; vector R = reflect( normalize(i_V), normalize(i_N) ); while( illuminance( P(), i_N, PI/2.0f ) ) { float isKeyLight = 1; //if( i_keyLightsOnly != 0 ) //{ // lightsource( "iskeylight", isKeyLight ); //} if( isKeyLight != 0 ) { const float nonspecular = 0.0f; //lightsource( "__nonspecular", nonspecular ); if( nonspecular < 1 ) { vector Ln = normalize(L()); SAMPLE_LIGHT_2(color, C, 0.0f, C += Cl()*pow(max<float>(0.0f,R%Ln),cosinePower)*(1.0f-nonspecular); ); } }
void main1_3(void *arg) { color Kd = color(diffuse(), diffuse(), diffuse()); normal Nf = faceforward(normalize(N()), I()); vector V = -normalize(I()); while (illuminance(P(), Nf, PI / 2.0f)) { color C = 0.0f; SAMPLE_LIGHT_2(color, C, 0.0f, C += Cl() * ( color_() * Kd * (normalize(L()) % Nf) + cosinePower() * specularColor() * specularbrdf(normalize(L()), Nf, V, 0.1f/*roughness()*/) ) ); Ci() += C; } if ( ! less_than( &transparency(), LIQ_SCALAR_ALMOST_ZERO ) ) {//transparent Ci() = Ci() * ( 1.0f - transparency() ) + trace_transparent() * transparency(); }//else{ opacity } setOutputForMaya(); }
color getDiffuse( const normal& i_N, const eiBool keyLightsOnly, const eiBool unshadowed ) { eiBool isKeyLight = eiTRUE; color C = 0; while ( illuminance( P(), i_N, PI/2.0f ) ) { //if( keyLightsOnly != eiFALSE ) //{ // lightsource( "iskeylight", isKeyLight ); //} if( isKeyLight != eiFALSE ) { float nondiffuse = 0.0f; //lightsource( "__nondiffuse", nondiffuse ); if( nondiffuse < 1.0f ) { SAMPLE_LIGHT_2(color, C, 0.0f, C += Cl() * (normalize(L()) % i_N) * (1.0f-nondiffuse) ); } } } return C; }
void main1(void *arg) { color Kd = color(diffuse(), diffuse(), diffuse()); normal Nf = faceforward(normalize(N()), I()); vector V = -normalize(I()); while (illuminance(P(), Nf, PI / 2.0f)) { color C = 0.0f; color last = 0.0f; int num_samples = 0; while (sample_light()) { C += Cl() * ( color_() * Kd * (normalize(L()) % Nf) + cosinePower() * specularColor() * specularbrdf(normalize(L()), Nf, V, 0.1f/*roughness()*/) ); ++ num_samples; if ((num_samples % 4) == 0) { color current = C * (1.0f / (scalar)num_samples); if (converged(current, last)){ break; } last = current; } } C *= (1.0f / (scalar)num_samples); Ci() += C; } if ( ! less_than( &transparency(), LIQ_SCALAR_ALMOST_ZERO ) ) {//transparent Ci() = Ci() * ( 1.0f - transparency() ) + trace_transparent() * transparency(); }//else{ opacity } setOutputForMaya(); }
float illuminance(const Camera& c) noexcept { const FCamera& camera = upcast(c); return illuminance(camera.getAperture(), camera.getShutterSpeed(), camera.getSensitivity()); }