Anyone know of a shader which takes in 2 textures, one that can use alpha and the other that can be rotated? So you end up with a texture spinning behind a masked texture. Thanks for any help
I dont have time to write it now, it's a pretty enlightening thing to program to rotate X and Y of the shader, you have to change the TEXCOORD U , V, values that are used to read the texture using this will rotate a texture: http://forum.unity3d.com/threads/rotation-of-texture-uvs-directly-from-a-shader.150482/ then take the second texture, read its rgba values as well just straight half4 d = tex2D (_MainTex, IN.uv_MainTex); and at the end of the shader do o.albedo = c.r*d.a , c.g*d.a , c.b*d.a; its a float3 rgb value... multing it means that when alpha pixel is zero, rotating tex underneat it is zero. you dont have to use an alpha on second texture you can use black and white grey ones, and use r,g,or b value. can be easier sometimes. i dont have a 2 texture blend shader at hand that averages the pixel values of rgb of 2 textures at hand in surf function, right now. you can find some.
ok sry here it is, there maybe a tiny syntax error where i added the alphatex, i didnt run it, and teh UV_alphatex. it's you have the 2 shaders so you can scramble it from this probably Code (csharp): [LIST=1] [*] [*]Shader "Custom/RotateUVs" { [*] Properties { [*] _MainTex ("Base (RGB)", 2D) = "white" {} [*] _alphaTex ("Base (RGB)", 2D) = "white" {} [*] _RotationSpeed ("Rotation Speed", Float) = 2.0 [*] } [*] SubShader { [*] Tags { "RenderType"="Opaque" } [*] LOD 200 [*] [*] CGPROGRAM [*] #pragma surface surf Lambert vertex:vert [*] [*] sampler2D _MainTex,_alphaTex ; [*] [*] struct Input { [*] float2 uv_MainTex; [*] float2 uv_alphaTex ; [*] }; [*] [*] float _RotationSpeed; [*] void vert (inout appdata_full v) { [*] float sinX = sin ( _RotationSpeed * _Time ); [*] float cosX = cos ( _RotationSpeed * _Time ); [*] float sinY = sin ( _RotationSpeed * _Time ); [*] float2x2 rotationMatrix = float2x2( cosX, -sinX, sinY, cosX); [*] v.texcoord.xy = mul ( v.texcoord.xy, rotationMatrix ); [*] } [*] [*] void surf (Input IN, inout SurfaceOutput o) { [*] half4 c = tex2D (_MainTex, IN.uv_MainTex); [*] half4 at = tex2D (_alphaTex , IN.uv_alphaTex ); [*] o.Albedo = c.rgb * at.a; [*] o.Alpha = c.a; [*] } [*] ENDCG [*] } [*] FallBack "Diffuse" [*]} [*] [/LIST]