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

Generating "Splat Mesh"?

Discussion in 'Scripting' started by ZeroG677, Oct 21, 2016.

  1. ZeroG677

    ZeroG677

    Joined:
    Sep 30, 2016
    Posts:
    27
    Hey
    I want to make an script that would generate a mesh flattened over geometry. Something like this(Ignore the text):

    With correct UV's(Top left of the mesh being the top left of the texture and the bottom right of the mesh being the bottom right of the texture).
    I'm going to use this for roads, bullet holes, blood, etc. How can i make a script that can generate something like this?
     
  2. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    ZeroG677 likes this.
  3. ZeroG677

    ZeroG677

    Joined:
    Sep 30, 2016
    Posts:
    27
  4. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    For each affected model, transform each vertex to world space, then transform them to local space of projector. If they have transform components you have both methods and matrices with this functionality.
     
  5. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
  6. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    I'm not sure if "Unity Projectors" are still a thing to avoid, since I haven't seen them or messed with them in quite awhile, but it used to be that they were a horrible option for common texture overlays (decals) because of the performance concerns associated with them. Bullet holes and other dynamic instances were completely out of the question. I noticed now though, looking through the manual, that "bullet marks" are listed as a possible use. Has anyone used a projector in more recent (post 5.0) versions, namely after the switch to the current standard shader, and can give any sort of update on performance concerns?

    Btw, if you need really simple decals like bullet holes, and the surfaces that they can occur on are guaranteed to be flat, I recommend the Quick Decals 2 asset on the UAS. It won't work like a projector, but it's a simple resource-friendly alternative for flat texture overlays on flat surfaces.