Search Unity

Projecting grid pattern

Discussion in 'General Graphics' started by Mickwa, Nov 28, 2016.

  1. Mickwa

    Mickwa

    Joined:
    May 9, 2014
    Posts:
    15
    Hello,

    I need to project large (100x250) grid, tilled pattern on objects. Something like projector. I tried using Projector component, but it has artifacts on edges. I tried also light with cookie, but texture size of cookie is to small for such large pattern. What is the best way to do such thing?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Using a projector.

    The key is give your texture having a couple of extra pixels that are transparent around the edge, the texture set to clamped, and Border Mip Maps checked on (you need to set the texture type to advanced).
     
  3. Mickwa

    Mickwa

    Joined:
    May 9, 2014
    Posts:
    15
    Problem with projector is also that it doesn't stop on mesh.
    And should I have 100x250 grid of projectors? My grid tile is for example 256x256px black and white png, and I can not scale that down because I will loose quality of pattern. I was thinking maybe shaders are good way to solve this? Speed is not so important. It can be even 1 fps and it will be fine. Size of grid is important and that it won't loose quality of pattern.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    If you need it to not effect back side faces, that can be done with a custom projector shader, but if you want it to shadow you will need to use a light.

    Without understanding better what you're trying to do I suspect a light cookie from a single spotlight or directional light will do what you want. Don't set your texture to be of the type light cookie, just set it to use the Alpha8 format and check "alpha from greyscale". It shouldn't change the size of your texture any more than it does for the projector.
     
    theANMATOR2b likes this.