How can i convert uv coordinates to world space?

前端 未结 2 1697
我在风中等你
我在风中等你 2021-01-26 21:37

I am trying to implement a shader. It will use with Unity LineRenderer. Shader will have noise that scrolling overtime raltive to texture coordinates. For example in parallel to

2条回答
  •  礼貌的吻别
    2021-01-26 21:52

    Texture coordinates are already in texture space. If I understand correctly, you should be able to just do this:

        v2f vert(appdata_t IN)
        {
            v2f OUT;
    
            OUT.vertex = UnityObjectToClipPos(IN.vertex);
    
            OUT.texcoord = IN.uv;
            OUT.srcPos = IN.uv;
            OUT.srcPos *= _Freq;
    
            fixed2 scrollOffset = fixed2(1, 0);
            OUT.srcPos.xy -= fixed2(scrollOffset.x, scrollOffset.y) * _Time.y * _Speed;
    
            return OUT;
        }
    

提交回复
热议问题