Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

heightmap shader

Discussion in 'Shaders' started by metervara, May 26, 2008.

  1. metervara

    metervara

    Joined:
    Jun 15, 2006
    Posts:
    203
    Hi.

    How can I get color from a texture inside a vertex program? I'd like to offset the vertices based on the color from a texture to create a heightmap shader. Is that possible?

    Is there something that matches tex2D for vertex programs or should i approach the problem differently?

    thanks,
    Patrik
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    It won't work with Cg programs - possibly you can do a bit with GLSL (but that will run on VERY few cards) and be very slow.

    I'd recommend taking another route. What are you trying to do?
     
  3. metervara

    metervara

    Joined:
    Jun 15, 2006
    Posts:
    203
    Hi,

    I wanted to use a projector to deform a mesh based on what color each vertex gets form the projection. It would eliminate uv recalculation on my mesh which is getting a bit too complicated.

    Guess I'll deform with the mesh interface and just use the projector for texture.

    thanks
    /P
     
  4. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    If you do the projection in the vertex shader and you can represent the texture though a simple function, you could do it that way.
     
  5. metervara

    metervara

    Joined:
    Jun 15, 2006
    Posts:
    203
    In some cases it's going to be simple patterns and 'noise' like deformation and for those I'll look at doing a vertex shader.

    /P