Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Material Property Block

Discussion in 'General Graphics' started by popMark, Feb 21, 2022.

  1. popMark


    Apr 14, 2013
    Is there any benefit to me creating multiple MaterialPropertyBlock's for different purposes/values?
    Since GetPropertyBlock clears the block I could just have one static MaterialPropertyBlock and reuse it for all GetPropertyBlock/SetPropertyBlock calls.
    I had thought perhaps the Renderer kept a reference to the MaterialPropertyBlock since the 'set' of SetPropertyBlock couple imply that, but I realize now it gets copied per renderer.
    Curious as well why a MaterialPropertyBlock has to be created on the main thread
  2. Sluggy


    Nov 27, 2012
    I've personally never had any need for separate instances of MaterialPropertyBlocks. I usually just have a single cached instance. But perhaps it would be better in some cases to have a sort of table of 'pre-sets' for different common MPBs?

    As far as requiring creation on the main thread: that's just how Unity is set up for pretty much all engine constructs. Makes it easier for them to ensure it will always be used in a certain way and also makes it much easier for them to teach users how to use it without potentially blowing up their app and the end-user's computer along the way. This probably isn't as much of an issue these days but at least in the early days of Unity it seemed they were really aiming for simplicity and ease of onboarding new users to their engine.
    popMark likes this.