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. Dismiss Notice

Making attack markings on walls?

Discussion in 'General Graphics' started by metamorphist, Apr 17, 2016.

  1. metamorphist

    metamorphist

    Joined:
    Mar 15, 2014
    Posts:
    77
    On raycasthit or attack trigger hit, if the object is in a particular layer, apply texture decals? And have it decay and only placed relative to the attack position?

    Help?
     
  2. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    If at most a few on a single object, and not overlapping between objects, and UV's are made for it, then you can use a shader that supports "decals". In summary, unlikely this is gonna work.
    Otherwise I suggest either "real" decals, or deferred decals. Both have their up and downsides.
     
  3. metamorphist

    metamorphist

    Joined:
    Mar 15, 2014
    Posts:
    77
    Can you elaborate more?

    I seem to want it practical, decals that is inside the UV so i can remove it the next few frames.
     
  4. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    "inside the UV", so you want it limited to a single object?
    "remove it the next few frames" has nothing to do with HOW the problem is solved. However if your going to add and remove them often deferred decals will likely be cheaper, (assuming your using deferred or unlit shading).
    In short the solution is "decals", the long answer is that you will either need to write your own system, or buy/get a existing one.
     
  5. metamorphist

    metamorphist

    Joined:
    Mar 15, 2014
    Posts:
    77
    Wow, i checked out the deferred decals...some existing ones like alloy sure looks good... and it even decals the normal map...
    it practically casts light into the mesh eh?
    But what i need is only on basic unlit mesh shader...
    Should it be simpler?
     
  6. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Actually no, deferred decals don't cause any additional lighting. (I'm not sure how alloy's are done, but that's how they are normally used). What they do is modify the normals and albedo (color) before light is applied.
    Yep, that will make things a lot easier! You could still use the concept of deferred decals. It's more or less the same as Unity's Projectors only that they have some limitations and a lot less performance problems.
    If the mesh is simple enough it might be simpler to use a mesh based decal. (Create a mesh fitting the underlying area you want it on, and then render it after the "original" mesh has been rendered.)
     
  7. Deleted User

    Deleted User

    Guest

    @Zicandar
    Perhaps @metamorphist is referring to the difference in ambient lighting between the surface and the decal. You see, deferred decals are a separate mesh and can't receive lightmapped GI from the surface beneath them. So they have to use light probes instead, which may look close enough but will never look 100% correct. Even in the case of decals on an object using a light probe the decal will have a different centroid than the object, and thus receives a slightly different interpolated light probe.
     
  8. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    The part about lightmapped GI I agree with completly, however for light probes I disagree, as I think that Unity now applies light probes per pixel instead of per object? And thereby it should be possible to do after applying the decal?
    (If ANY light is applied before the decal it limits its functionality anyways for deferred decals, such as only changing the normalmap...)
     
  9. Deleted User

    Deleted User

    Guest

    @Zicandar
    You're referring to the optional new Light Probe Proxy Volumes in 5.4, which partially solve the problem while introducing new issues. For example, those volumes are far more expensive to sample and they take up more memory than regular light probes. Plus, the decals will still look out of place if you are using Directional Specular lightmaps.