Search Unity

Help coming up with a performance light visualization method

Discussion in 'Image Effects' started by _M_S_D_, Jul 16, 2018.

  1. _M_S_D_

    _M_S_D_

    Joined:
    Nov 12, 2013
    Posts:
    511
    Hello!

    In my game Atmocity, buildings have an efficiency variable that determines stuff like population capacity, resource output etc. I would like to somehow make a visualization mode so that players can easily find areas that are underperforming.

    Essentially what I would like to accomplish is to lerp from this:
    upload_2018-7-16_12-9-53.png

    To something like this:
    upload_2018-7-16_12-10-6.png
    (naturally with all buildings colored)

    Since my knowledge of shaders and image effects is pretty limited I'm open to ideas on how to do this in a performant way. I have to keep using the standard shader and don't want to switch materials, since we're talking about potentially hundreds or thousands of buildings.

    Any ideas?
     
  2. _M_S_D_

    _M_S_D_

    Joined:
    Nov 12, 2013
    Posts:
    511

    Attached Files:

  3. sergi_tortosa

    sergi_tortosa

    Joined:
    Feb 27, 2018
    Posts:
    1
    How did you solve this problem? Screen space and mapping world pos of the point to the correct building/parcel? Or any other approach? Thank you so much!
     
  4. _M_S_D_

    _M_S_D_

    Joined:
    Nov 12, 2013
    Posts:
    511
    A replacement shader replaces the standard shader. The replacement shader is pretty much just a gradient with shadows and lighting turned off.
    Buildings can inhabit the same space (building origin is in the center of a 1x1x1 space, so several buildings can have the same location). Because of this I pass the building's efficiency variable via a material property block to the shader instead of using world pos. This 0-1 variable is then interpreted as a red to green color that is added on top of the gradient.

    I will be doing a short tutorial on this fairly soon.
     
    sergi_tortosa likes this.