| 235 | } |
| 236 | |
| 237 | static void DefineMaterial(const string &name, const Properties &matProps, const Properties &lightProps) { |
| 238 | const string prefix = "scene.materials." + name; |
| 239 | |
| 240 | //-------------------------------------------------------------------------- |
| 241 | // Material definition |
| 242 | //-------------------------------------------------------------------------- |
| 243 | |
| 244 | const string type = matProps.Get(Property("type")("matte")).Get<string>(); |
| 245 | if (type == "matte") { |
| 246 | if (matProps.IsDefined("sigma")) { |
| 247 | *sceneProps << |
| 248 | Property(prefix + ".type")("roughmatte") << |
| 249 | GetTexture(prefix + ".kd", Property("Kd")(Spectrum(.9f)), matProps) << |
| 250 | GetTexture(prefix + ".sigma", Property("sigma")(0.f), matProps); |
| 251 | } else { |
| 252 | *sceneProps << |
| 253 | Property(prefix + ".type")("matte") << |
| 254 | GetTexture(prefix + ".kd", Property("Kd")(Spectrum(.9f)), matProps); |
| 255 | } |
| 256 | } else if (type == "mirror") { |
| 257 | *sceneProps << |
| 258 | Property(prefix + ".type")("mirror") << |
| 259 | GetTexture(prefix + ".kr", Property("Kr")(Spectrum(1.f)), matProps); |
| 260 | } else if (type == "glass") { |
| 261 | const bool isArchitectural = matProps.Get(Property("architectural")(false)).Get<bool>(); |
| 262 | |
| 263 | *sceneProps << |
| 264 | Property(prefix + ".type")(isArchitectural ? "archglass" : "glass") << |
| 265 | GetTexture(prefix + ".kr", Property("Kr")(Spectrum(1.f)), matProps) << |
| 266 | GetTexture(prefix + ".kt", Property("Kt")(Spectrum(1.f)), matProps) << |
| 267 | Property(prefix +".ioroutside")(1.f) << |
| 268 | GetTexture(prefix + ".iorinside", Property("index")(1.5f), matProps); |
| 269 | } else if (type == "metal") { |
| 270 | string presetName = matProps.Get("name").Get<string>(); |
| 271 | Spectrum n, k; |
| 272 | FresnelPreset(presetName, &n, &k); |
| 273 | |
| 274 | *sceneProps << |
| 275 | Property(prefix + ".type")("metal2") << |
| 276 | Property(prefix + ".n")(n) << |
| 277 | Property(prefix + ".k")(k) << |
| 278 | GetTexture(prefix + ".uroughness", Property("uroughness")(.1f), matProps) << |
| 279 | GetTexture(prefix + ".vroughness", Property("vroughness")(.1f), matProps); |
| 280 | } else if (type == "mattetranslucent") { |
| 281 | if (matProps.Get(Property("energyconserving")(false)).Get<bool>() == false) |
| 282 | LC_LOG("Mattetranslucent with energyconserving=false is not supported, using energyconservin."); |
| 283 | if (matProps.IsDefined("sigma")) { |
| 284 | *sceneProps << |
| 285 | Property(prefix + ".type")("roughmattetranslucent") << |
| 286 | GetTexture(prefix + ".kr", Property("Kr")(Spectrum(.9f)), matProps) << |
| 287 | GetTexture(prefix + ".kt", Property("Kt")(Spectrum(1.f)), matProps) << |
| 288 | GetTexture(prefix + ".sigma", Property("sigma")(0.f), matProps); |
| 289 | } else { |
| 290 | *sceneProps << |
| 291 | Property(prefix + ".type")("mattetranslucent") << |
| 292 | GetTexture(prefix + ".kr", Property("Kr")(Spectrum(1.f)), matProps) << |
| 293 | GetTexture(prefix + ".kt", Property("Kt")(Spectrum(1.f)), matProps); |
| 294 | } |
no test coverage detected