Quantcast
Channel: Questions in topic: "hlsl"
Viewing all articles
Browse latest Browse all 206

Moving UV's with a shader (tiling error)

$
0
0
With the following code I tried to animate a texture on a surface by moving its uvs. However it moves, but it doesn't tile correct as the net tile is just grey (stretched from texture's border). Now how do I say that it should display the same texture over nd over again? I also tried TRANSFORM_TEX in the vertex function (same behaviour). Thanks. Shader "Custom/test" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Offset ("Offset", Range(-2.0, 2.0)) = 0.0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert alpha:blend vertex:vert #pragma target 3.0 sampler2D _MainTex; float _Offset; struct Input { float2 uv_MainTex; }; void vert (inout appdata_full v) { v.texcoord.xy += _Offset; } fixed4 _Color; void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }

Viewing all articles
Browse latest Browse all 206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>