Each material has properties that affect: - Reverb - rays lose energy on each bounce - Ray Directions - rays change directions when bouncing - Permeation - rays lose energy when passing through materials There are [[raytraced-audio/v110/Enums/MaterialType|23 default materials]] for common materials like dirt, grass, concrete, metal, cloth, etc. You can customise these, as well as define your own materials. ## Data Structure The [[raytraced-audio/v110/Classes/MaterialProperties|MaterialProperties]] class contains all data for one material. ```cs public class MaterialProperties { // How much energy is lost on each bounce (0.0 to 1.0) public float AbsorptionLF; public float AbsorptionHF; // Scattering strength. 0.0 has no scattering and 1.0 scatters // up to 90 degrees from the reflected direction public float Scattering; // How much energy is lost in dB/m (0.0 or greater) when a // ray passes through a primitive public float TransmissionLF; public float TransmissionHF; // Percentage of energy lost when a ray passes through a // flat primitive (0.0 to 1.0) public float PlaneTransmissionLF; public float PlaneTransmissionHF; } ``` Materials can be updated via the `GetMaterial` and `AddMaterial` functions on a [[raytraced-audio/v110/Classes/RaytracingContext|RaytracingContext]] object. ```cs var dirt = context.GetMaterial(MaterialType.Dirt); dirt.Scattering = 0.6f; const int ALIEN = 1000; var alienProperties = new MaterialProperties(0.5f, 0.6f, 0.7f, 4, 7, 0.1f, 0.2f); var alienColour = new Color(255, 0, 255); context.AddMaterial((MaterialType)ALIEN, alienProperties, alienColour); // Tell the context that materials have been updated/created context.MaterialsDirty = true; ``` > `context.MaterialsDirty` **must be set to true after updating materials, and will cause all rays to be re-cast.** Notes: - The first 1000 values (0 to 999) in `MaterialType` are reserved, so set your custom material IDs from 1000 onwards - Contexts are automatically initialised with all default materials - You can update materials at any time, but your changes will only apply the next time raytracing occurs (i.e. the current background threads won't receive this change) ## Validation Materials will be validated when setting `MaterialsDirty` to true, and may throw an exception if: - Any field is `NaN` or `Infinity` - All `Absorption`, `Scattering` and `PlaneTransmission` values must be in the range `0.0f - 1.0f` (inclusive) - `Transmission` values must be in the range `0 - Float.Max` (inclusive) ## Default Material Properties For every material: - `PlaneTransmissionLF` defaults to `0.1` - `PlaneTransmissionHF` defaults to `0.25` |Material|Absorption LF|Absorption HF|Scattering|Transmission LF|Transmission HF|Source| |---|---|---|---|---|---|---|---| |Brick|0.31|0.52|0.40|80|120|[hard_surface](https://pyroomacoustics.readthedocs.io/en/pypi-release/pyroomacoustics.materials.database.html)| |Cloth|0.72|0.91|0.70|15|30|[carpet_cotton](https://pyroomacoustics.readthedocs.io/en/pypi-release/pyroomacoustics.materials.database.html)| |Concrete|0.31|0.55|0.40|100|150|[Concrete unpainted, rough finish](https://www.acoustic-supplies.com/absorption-coefficient-chart/)| |Concrete Polished|0.06|0.12|0.10|110|160|[Concrete sealed or painted](https://www.acoustic-supplies.com/absorption-coefficient-chart/)| |Dirt|0.48|0.88|0.50|40|80|[50mm soil depth](https://www.researchgate.net/profile/Hong-Seok-Yang/publication/258455034_Random-Incidence_Absorption_and_Scattering_Coefficients_of_Vegetation/links/5c43281992851c22a3812440/Random-Incidence-Absorption-and-Scattering-Coefficients-of-Vegetation.pdf)| |Glass|0.08|0.12|0.05|60|100|Estimated| |Grass|0.71|0.93|0.80|20|40|[100% density, 200mm depth](https://www.researchgate.net/profile/Hong-Seok-Yang/publication/258455034_Random-Incidence_Absorption_and_Scattering_Coefficients_of_Vegetation/links/5c43281992851c22a3812440/Random-Incidence-Absorption-and-Scattering-Coefficients-of-Vegetation.pdf)| |Gravel|0.06|0.12|0.70|120|170|Estimated| |Gyprock|0.04|0.08|0.05|30|60|Estimated| |Ice|0.01|0.03|0.01|60|100|Estimated| |Leaf|0.71|0.91|0.80|10|25|[60% vegetation coverage](https://www.researchgate.net/profile/Hong-Seok-Yang/publication/258455034_Random-Incidence_Absorption_and_Scattering_Coefficients_of_Vegetation/links/5c43281992851c22a3812440/Random-Incidence-Absorption-and-Scattering-Coefficients-of-Vegetation.pdf)| |Marble|0.06|0.12|0.03|120|170|[marble_floor](https://pyroomacoustics.readthedocs.io/en/pypi-release/pyroomacoustics.materials.database.html)| |Metal|0.05|0.02|0.01|150|250|[Steel door](https://www.researchgate.net/figure/Material-list-and-sound-absorption-coefficients-Christensen-2002_tbl1_228850689)| |Mud|0.56|0.82|0.50|50|90|[150mm soil depth](https://www.researchgate.net/profile/Hong-Seok-Yang/publication/258455034_Random-Incidence_Absorption_and_Scattering_Coefficients_of_Vegetation/links/5c43281992851c22a3812440/Random-Incidence-Absorption-and-Scattering-Coefficients-of-Vegetation.pdf)| |Rock|0.31|0.51|0.40|90|130|[limestone_wall](https://pyroomacoustics.readthedocs.io/en/pypi-release/pyroomacoustics.materials.database.html)| |Sand|0.65|0.92|0.70|35|70|[Sand (5cm thickness)](https://www.researchgate.net/figure/Reflection-and-absorption-coefficient-of-sand-Sample-thickness-is-equal-to-5-cm_fig1_236663318)| |Snow|0.65|0.92|0.70|25|50|Estimated from sand| |Tile|0.06|0.12|0.03|120|170|Estimated| |Tree|0.22|0.46|0.30|35|65|[Vegetation attenuation study](https://www.researchgate.net/publication/271394333_Sound_attenuation_through_absorption_by_vegetation)| |Water|0.06|0.12|0.10|60|100||Estimated| |Wood Indoor|0.12|0.30|0.10|30|60|[plywood_thin](https://pyroomacoustics.readthedocs.io/en/pypi-release/pyroomacoustics.materials.database.html)| |Wood Outdoor|0.16|0.37|0.20|40|70|[wood_16mm](https://pyroomacoustics.readthedocs.io/en/pypi-release/pyroomacoustics.materials.database.html)||