Search Unity

WorldPos texture blend

Discussion in 'Shaders' started by shmo, Mar 20, 2011.

  1. shmo

    shmo

    Joined:
    Oct 27, 2010
    Posts:
    21
    What I am trying to achieve is a blend between a "map" texture and the main texture based on "explored" areas the player has been (updating as they move around).

    I can think of a way to do this by updating an alpha texture (with SetPixel) but I have read that this approach is not very good.

    I wondered if there is a way to do this directly in a shader?

    I have a simple shader (based on the "progress bar" shader mentioned in the Unite presentation).

    It takes two textures, a radius and an origin in world space. It then does a circular blend from the origin. This is great for one point, but is there a way that I can pass multiple points in?

    Or is there another approach?

    Any pointers would be greatly appreciated.
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Vertex colors sound like a much better match, to me. But it depends on how you reveal. If you can model the blend, then it's a good method. The map in Toe Jam and Earl, the best map of all time, of course, would work great with a method like that, but I think that it would be even better just to delete vertices from a mesh, and use no blending.
     
  3. shmo

    shmo

    Joined:
    Oct 27, 2010
    Posts:
    21
    Thanks Jessy,

    I'll look into how to use vertex colors. I think I saw a post about them earlier, I'll search it out.
     
  4. shmo

    shmo

    Joined:
    Oct 27, 2010
    Posts:
    21
    Ok,

    Just testing this out with a simple plane, (100x100 vertex).

    That works, however, it looks quite "pixelated". Would that be purely from the number of vertices I used or could I modify the shader to make a smoother result? The one I am using at the moment just does a lerp between two textures based on vertex color.

    Also the approach I took for setting the vertex colors (iterating through all the vertices and seeing if they are within a given distance from a point) is pretty slow. Does anyone have advice for "fast" ways to find vertices in an area?