Search Unity

Same texture, multiple objects, different scales.

Discussion in 'General Graphics' started by GfK, Feb 3, 2015.

  1. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Sorry if the thread title is a bit confusing, I have no idea if there's a proper term for this.

    Imagine I have a bunch of planes (or meshes, or anything) of arbitrary size. I also have a single checkerboard texture (with four coloured squares - two black, two white). I want the texture to be applied to all objects, but have the black/white squares look the same size in the game.

    I can think of two ways to solve it right now:

    1. Have a different material per game object, each with "tiling" set differently (this is really no option at all)!
    2. Manually scale up the UV coordinates so that they extend beyond the 0-1 range.

    Thoughts?
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    On the one hand you would need to change the uv coords of each vertex adjusted so that the position of the vertex within the texture produces the uv coord, rather than stretching the texture. Sort of like screen-space coordiniates. Another option is a custom shader which uses screen-space coordinates of the fragment and converts that into a uv coordinate on the fly.