Search Unity

Is using texture offset with displacement shader possible?

Discussion in 'Shaders' started by Raul_T, Nov 28, 2015.

  1. Raul_T

    Raul_T

    Joined:
    Jan 10, 2015
    Posts:
    363
    Hello, I am working on a surface shader, and I am wondering if it is possible to use the texture offset on the displacement texture, because as it is now, it changes nothing. This is the displacement function of the shader.

    Code (CSharp):
    1.    void disp(inout appdata v)
    2.      {
    3.          float horizontal = tex2Dlod(_Displacement, float4(v.texcoord.xy,0,0)).r * _DisplacementPow * 5;
    4.          float vertical = tex2Dlod(_Displacement, float4(v.texcoord.xy, 0, 0)).r * _DisplacementPow * 5;
    5.          v.vertex.x += v.normal * horizontal;
    6.          v.vertex.y += (v.normal * vertical);
    7.        
    8.          v.vertex.y -= 0.5;
    9.      }
    I would like to know if it is possible to use texture offset with the height map, and if yes, what needs to be changed.
     
  2. StevenGerrard

    StevenGerrard

    Joined:
    Jun 1, 2015
    Posts:
    97
    Do you use TRANSFORM_TEX to manipulate your vertex input texcoord ?
    If yes I think you could offset your uv.