hello I want to change texture UV in Vert function of Surface shader here is Vertex\Fragment code: I want same thing on Surface shader how can i use this code on Surface shader code? My purpose is change UV tiling on vertex shader of surface shader
Use a custom vertex function. See the example for "Custom data computed per-vertex": https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html Replace float3 customColor; with float2 customUV; and o.customColor = ... with o.customUV = v.texcoord.xy * _MainTex_ST.xy * 7 + _MainTex_ST.zw; Alternatively you could just use tex2D(_DetailTex, IN.uv_MainTex * 7) in your surface shader and get basically the same result; exactly the same if you don't use any texture offset.
Thank you. I'll try it My purpose is create custom UV like Unreal mobile uv tiling solution. Its fast and solve Tiling blocky texture in Mali400 GPUs I test on simple fragment shader and it worked https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/CustomizedUVs/ Its unreal mobile test: download APK:Link
you help me a lot. I spend 7 hours yesterday without result and your help solve my hole problem. thanks again. my code: Code (CSharp): Shader "Custom/DetailSurface" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _DetailTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert vertex:vert #pragma target 3.0 sampler2D _MainTex; sampler2D _DetailTex; struct Input { float2 uv_MainTex; float2 uv_DetailTex; float2 customUV; }; void vert (inout appdata_full v, out Input o) { UNITY_INITIALIZE_OUTPUT(Input,o); o.customUV = v.texcoord.xy * 7; } void surf (Input IN, inout SurfaceOutput o) { half4 c = tex2D (_MainTex, IN.uv_MainTex)*tex2D (_DetailTex, IN.customUV); o.Albedo = c.rgb*7; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" } result on Mali400: