How do you make the material in the Terrain detail prototype properties update after runtime?

i made a script that alters the materials emission of my grass prefab, i have added it as a detail mesh to my terrain and i have tried everything to try and get the material on the painted grass to update.

now let me explain in more detail, my material is a HDRP lit, my script compares the distance between the player and the grass transforms, if it is less than the specified range then the materials emission changes, this all works, specifically it works when placing the prefab in the scene, but not when painting the prefab on the terrain, i have the nature renderer Asset pack to render the materials, and have no idea how to go about making the material in my prefab, in my terrain detailmesh update like the manually placed prefabs do, please help a guy out, ask any questions you need.

i did manage this but it turns out i was struggling because i was using the Nature renderer addon. this means i had to use their specific code.