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

Per-instance material color for entities?

Discussion in 'Entity Component System' started by meanfox, May 15, 2020.

  1. meanfox

    meanfox

    Joined:
    Apr 9, 2020
    Posts:
    25
  2. schaefsky

    schaefsky

    Joined:
    Aug 11, 2013
    Posts:
    89
    meanfox likes this.
  3. meanfox

    meanfox

    Joined:
    Apr 9, 2020
    Posts:
    25
    Thanks. What would be the downsides of using HDRP for this?
     
  4. schaefsky

    schaefsky

    Joined:
    Aug 11, 2013
    Posts:
    89
    Really do not know, but from my POV mostly that a lot of shaders and I think particle systems will not work and you have to have new ones.
    I have seen some assets being updated though, so it may or may not matter to you.
    Also of course if your doing that stuff by yourself I guess you can just make it so that it works, but me i do not have a clue how to write shaders or make particle effects that look good.
     
    meanfox likes this.
  5. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Main downside is a lot of assets on the asset store are not calibrated to HDRP. However, assets designed for the standard shader are also calibrated for URP, so it is only custom shaders for the built-in pipeline that don't work.

    upload_2020-5-18_10-41-30.png
    Code (CSharp):
    1. [MaterialProperty("_Fade", MaterialPropertyFormat.Float)]
    2.     public struct FadeProperty : IComponentData
    3.     {
    4.         public float fade;
    5.     }
    Code (CSharp):
    1. Entities.ForEach((ref FadeProperty fade, in TimeToLive timeToLive, in TimeToLiveFadeStart timeToLiveFadeStart) =>
    2.             {
    3.                 fade.fade  = math.saturate(timeToLive.timeToLive / timeToLiveFadeStart.fadeTimeWindow);
    4.                 fade.fade *= fade.fade; //Gamma-tize the fade
    5.             }).ScheduleParallel();
     
    meanfox and florianhanke like this.