Conductor(const PropertyList &propList) { materialName = propList.getString("materialName", ""); if(materialName != "") { // load the specific material properties if(!getMaterialProperties(materialName, m_eta, m_k)){ std::cout << "Material " << materialName << " not found!" << std::endl; } } else { m_eta = propList.getColor("eta"); m_k = propList.getColor("k"); } }
RoughConductor(const PropertyList &propList) { materialName = propList.getString("materialName", ""); if(materialName != "") { // load the specific material properties if(!getMaterialProperties(materialName, m_eta, m_k)){ std::cout << "Material " << materialName << " not found!" << std::endl; } } else { m_eta = propList.getColor("eta"); m_k = propList.getColor("k"); } /* RMS surface roughness */ m_alpha = propList.getFloat("alpha", 0.1f); }
HeterogeneousMedium(const PropertyList &propList) { // Denotes the scattering albedo m_albedo = propList.getColor("albedo"); // An (optional) transformation that converts between medium and world coordinates m_worldToMedium = propList.getTransform("toWorld", Transform()).inverse(); // Optional multiplicative factor that will be applied to all density values in the file m_densityMultiplier = propList.getFloat("densityMultiplier", 1.0f); m_filename = propList.getString("filename"); QByteArray filename = m_filename.toLocal8Bit(); QFile file(m_filename); if (!file.exists()) throw NoriException(QString("The file \"%1\" does not exist!").arg(m_filename)); /* Parse the file header */ file.open(QIODevice::ReadOnly); QDataStream stream(&file); stream.setByteOrder(QDataStream::LittleEndian); qint8 header[3], version; qint32 type; stream >> header[0] >> header[1] >> header[2] >> version >> type; if (memcmp(header, "VOL", 3) != 0 || version != 3) throw NoriException("This is not a valid volume data file!"); stream >> m_resolution.x() >> m_resolution.y() >> m_resolution.z(); file.close(); cout << "Mapping \"" << filename.data() << "\" (" << m_resolution.x() << "x" << m_resolution.y() << "x" << m_resolution.z() << ") into memory .." << endl; m_fileSize = (size_t) file.size(); #if defined(PLATFORM_LINUX) || defined(PLATFORM_MACOS) int fd = open(filename.data(), O_RDONLY); if (fd == -1) throw NoriException(QString("Could not open \"%1\"!").arg(m_filename)); m_data = (float *) mmap(NULL, m_fileSize, PROT_READ, MAP_SHARED, fd, 0); if (m_data == NULL) throw NoriException("mmap(): failed."); if (close(fd) != 0) throw NoriException("close(): unable to close file descriptor!"); #elif defined(PLATFORM_WINDOWS) m_file = CreateFileA(filename.data(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (m_file == INVALID_HANDLE_VALUE) throw NoriException(QString("Could not open \"%1\"!").arg(m_filename)); m_fileMapping = CreateFileMapping(m_file, NULL, PAGE_READONLY, 0, 0, NULL); if (m_fileMapping == NULL) throw NoriException("CreateFileMapping(): failed."); m_data = (float *) MapViewOfFile(m_fileMapping, FILE_MAP_READ, 0, 0, 0); if (m_data == NULL) throw NoriException("MapViewOfFile(): failed."); #endif m_data += 12; // Shift past the header }
NORI_NAMESPACE_BEGIN areaLight::areaLight (const PropertyList &props) : Emitter() { //set the arguments m_radiance = props.getColor("radiance", Color3f(10.0f, 10.0f, 10.0f)); m_shootInNormalDirc = props.getBoolean("shootInNormal", false); }
Phong(const PropertyList &propList) { m_Kd = propList.getColor("kd", Color3f(0.5f)); m_Ks = propList.getColor("ks", Color3f(0.5f)); m_exp = propList.getFloat("n", 20.0f); // computation of the sampling weights float wd = m_Kd.getLuminance(); float ws = m_Ks.getLuminance(); m_specSamplingWeight = ws / (ws + wd); m_diffSamplingWeight = 1.0f - m_specSamplingWeight; }
SpotLight(const PropertyList &props) : Emitter() { //set the arguments m_position = props.getPoint("position"); m_intensity = props.getColor("Intensity"); bool useLookAt = props.getBoolean("useLookAt", true); if(useLookAt){ Vector3f lookPT = props.getPoint("lookAt", Point3f(0.0f, 0.0f, 0.0f)); m_direction = (lookPT - m_position).normalized(); } else { m_direction = props.getVector("direction"); } m_theta = props.getFloat("theta"); m_cosFalloffStart = props.getFloat("falloff"); }
MicrofacetBRDF(const PropertyList &propList) { /* RMS surface roughness */ m_alpha = propList.getFloat("alpha", 0.1f); /* Interior IOR (default: BK7 borosilicate optical glass) */ m_intIOR = propList.getFloat("intIOR", 1.5046f); /* Exterior IOR (default: air) */ m_extIOR = propList.getFloat("extIOR", 1.000277f); /* Albedo of the diffuse base material (a.k.a "kd") */ m_kd = propList.getColor("kd", Color3f(0.5f)); /* To ensure energy conservation, we must scale the specular component by 1-kd. While that is not a particularly realistic model of what happens in reality, this will greatly simplify the implementation. Please see the course staff if you're interested in implementing a more realistic version of this BRDF. */ m_ks = 1.0f - m_kd.maxCoeff(); }
Phong(const PropertyList &propList) { m_Kd = propList.getColor("kd", Color3f(0.5f)); m_Ks = propList.getColor("ks", Color3f(0.5f)); m_exp = propList.getFloat("n", 20.0f); srand(time(NULL)); }
Diffuse(const PropertyList &propList) { m_albedo = propList.getColor("albedo", Color3f(0.5f)); }