Each material has absorption, scattering and transmission properties that affects how energy propagates throughout the environment. - `Absorption` affects how much energy a ray loses when reflecting off a surface - `Scattering` affects the angle of reflected rays(0.0 = perfect reflection, 1.0 = 90 degree offset) - `Transmission` affects how much energy is lost when rays pass through solid objects (permeation). - `PlaneTransmission` affects the percentage of energy lost when rays pass through flat planes/disks There are [[raytraced-audio/v110/Enums/MaterialType|18 presets]] for common materials like dirt, grass, concrete, metal, cloth. You can customise these and 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). 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, 0.8f, 40, 70, 0.1f, 0.25f); var alienColour = new(255, 0, 255); context.AddMaterial((vaudio.MaterialType)ALIEN, alienProperties, alienColour); // Tell the context that materials have been updated/created context.MaterialsDirty = true; ``` > 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 18 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 the change) ## Validation Materials will be validated when setting `MaterialsDirty` to true, and may throw an exception if: - All absorption/scattering values must be in the range `0-1` (inclusive) and not be `NaN` or `Infinity` - Transmission values must be in the range `0 - Float.Max` and not be `NaN` or `Infinity` ## Default Material Properties The absorption and scattering properties represent the percentage of energy lost on each bounce. The transmission properties represent how much energy is lost when a ray travels through an object, measured in dB/meter. `PlaneTransmissionLF` defaults to `0.1` and `PlaneTransmissionHF` defaults to `0.25` for all materials. |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)||