MCPcopy Create free account
hub / github.com/LuxCoreRender/LuxCore / DefineMaterial

Function DefineMaterial

src/luxcore/luxparser/luxparse.cpp:237–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237static 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 }

Callers 1

yyparseFunction · 0.85

Calls 9

GetTextureFunction · 0.85
FresnelPresetFunction · 0.85
GetLuxCoreValidNameFunction · 0.85
Get<string>Method · 0.80
GetMethod · 0.80
IsDefinedMethod · 0.80
Get<bool>Method · 0.80
Get<float>Method · 0.80
GetSizeMethod · 0.45

Tested by

no test coverage detected