bool spotLight::Illuminance(const intersection &inter, lightOutput &output) { // We calculate the output light vector, and attenuation just // like with a point light. double D, atten; output.L = pos - inter.p; // point to the light D = output.L.Length(); atten = 1.0 / (attenC + attenL * D + attenQ * D * D); output.a = aC; output.d = atten * dC; output.s = atten * sC; output.L /= D; // Normalize the light vector // To Do // // Then calculate the angle from the spot direction to the // light direction to the intersection point. Then use // the inner and outer theta angles to smooth-step down from // a fully bright light to a brightness of zero between these // two angles. Simply multiply the poing light's colors by this // "spot attenuation" value. CalculateShadow(inter, output); return true; }
void RayTracer::ExpandRayTracingTree(){ std::cout<<"Starting Expanding Ray Tracing Tree"<<std::endl; int inte = 0; for(;m_RayBuffer.size()!=0;){ Ray* tempray = m_RayBuffer.front(); m_RayBuffer.pop(); //std::cout<<"check ray"<<std::endl; Attr_Intersection* intsec = CalculateIntersection(tempray->m_RayLine); if(intsec!=NULL){ inte++; tempray->m_pIntersectionProperties = intsec; tempray->m_color += intsec->m_IntersectionColor; std::vector<Ray*> reflectray = tempray->reflect(intsec->m_PlanarNormal); Ray* refractray = tempray->refract(intsec->m_PlanarNormal,NULL); if(tempray->m_bShadowEnabled){ CalculateShadow(tempray); } if(reflectray.size()!=0){ for(unsigned int i =0; i < reflectray.size();i++){ m_RayBuffer.push(reflectray[i]); } } if(refractray!=NULL) m_RayBuffer.push(refractray); } tempray->m_isDone = true; m_ShadingBuffer.push(tempray); std::cout<<"\rCurrent Ray Remain: "<<m_RayBuffer.size(); } std::cout<<"Expanding Complete, Number Of Ray Intersects: "<<inte<<std::endl; }
bool distantLight::Illuminance(const intersection &inter, lightOutput &output) { output.L = dir; output.a = aC; output.d = dC; output.s = sC; CalculateShadow(inter, output); return true; }
bool pointLight::Illuminance(const intersection &inter, lightOutput &output) { double D, atten; output.L = pos - inter.p; // point to the light D = output.L.Length(); atten = 1.0 / (attenC + attenL * D + attenQ * D * D); output.a = aC; output.d = atten * dC; output.s = atten * sC; output.L /= D; // Normalize the light vector CalculateShadow(inter, output); return true; }