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 are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here:
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  4. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    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.