Is there any way to modify matrix of texture in CG?

using passes did not work…

        Shader "TextureRotateShader" {
        Properties {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        }
        SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200
         
         
        Pass{
        SetTexture[_MainTex]
        {
        Matrix[_Matrix]
        }
        }
         
        CGPROGRAM
        #pragma surface surf Lambert
         
        sampler2D _MainTex;
        fixed4 _Color;
         
        struct Input {
        float2 uv_MainTex;
        };
         
        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 "VertexLit"
        }

http://forum.unity3d.com/threads/68245-How-to-set-Matrix-as-a-Property

Decide if you really need to send a whole matrix though. You can probably do everything you need with a Vector4.

Here’s what I mean by that:
(Does [HideInInspector] work for you? It doesn’t for me.)

Shader "Rotate Main Texture" {

Properties {
    _MainTex ("Texture", 2D) = ""
	[HideInInspector] _2DRotationMatrix ("2D Rotation Matrix", Vector) = (1, 0, 0, 0)
}

Subshader {
	Pass {
		CGPROGRAM
		#pragma vertex vert
		#pragma fragment frag
		struct v2f {
			float4 position : SV_POSITION;
			float2 uv_mainTex : TEXCOORD;
		};
		
		uniform float4 _MainTex_ST, _2DRotationMatrix;
		v2f vert(float4 position : POSITION, float2 uv : TEXCOORD0) {
			v2f o;
			o.position = mul(UNITY_MATRIX_MVP, position);
			
			float2x2 rotation = float2x2(
				_2DRotationMatrix.x, -_2DRotationMatrix.y,
				_2DRotationMatrix.y, _2DRotationMatrix.x
			);
			float2 center = _2DRotationMatrix.zw * _MainTex_ST.xy;
			o.uv_mainTex = mul(rotation, uv * _MainTex_ST.xy - center)
				+ center + _MainTex_ST.zw;
			
			return o;
		}
		
		uniform sampler2D _MainTex;
		fixed4 frag(float2 uv_mainTex : TEXCOORD) : COLOR {
			return tex2D(_MainTex, uv_mainTex);
		}
		ENDCG
	}
}

}
using UnityEngine;

public static class MaterialExtensions {
	public static void SetVector(this Material material, 
		string propertyName, float angle, Vector2 center = default(Vector2)) 
	{			
		material.SetVector( propertyName, new Vector4(
			Mathf.Cos(angle), Mathf.Sin(angle), center.x, center.y) 
		);
	}
}

Thanks Jessy,

Although I do understand that I don’t need to pass in the entire matrix to achieve what I need, but the problem is that the effect I wanted is combining the rotation with the diffuse shader.

I tried using your shader and added the diffuse part, but it just gave errors

Shader "TextureRotateShader" {
Properties {

	_Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB)", 2D) = "white" {}

    _2DRotationMatrix ("2D Rotation Matrix", Vector) = (1, 0, 0, 0)
}

 

Subshader {
	Tags { "RenderType"="Opaque" }
	LOD 200
    CGPROGRAM
	// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
	#pragma exclude_renderers gles
	#pragma vertex vert
	#pragma fragment frag

        struct v2f {

            float4 position : SV_POSITION;

            float2 uv_mainTex : TEXCOORD;

        };

        uniform float4 _MainTex_ST, _2DRotationMatrix;


        v2f vert(float4 position : POSITION, float2 uv : TEXCOORD0) {

            v2f o;

            o.position = mul(UNITY_MATRIX_MVP, position);

           

            float2x2 rotation = float2x2(

                _2DRotationMatrix.x, -_2DRotationMatrix.y,

                _2DRotationMatrix.y, _2DRotationMatrix.x

            );

            o.uv_mainTex = mul(rotation, uv * _MainTex_ST.xy) + _2DRotationMatrix.zw + _MainTex_ST.zw;
           

            return o;

        }

        uniform sampler2D _MainTex;

        fixed4 frag(float2 uv_mainTex : TEXCOORD) : COLOR {

            return tex2D(_MainTex, uv_mainTex);

        }
        ENDCG
	        pass
	        {
	        	combine texture + previous
	        	CGPROGRAM
	        	#pragma surface surf Lambert
				fixed4 _Color;
				uniform sampler2D _MainTex;
				struct Input {
					float2 uv_MainTex;
				};
				
				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 "VertexLit"
}