Hello. I have created this shader to rotate the texture, but the axis of rotation is not that I want (see the picture). How can I fix it?
Shader "Decal Rotation" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Emission ("Emissive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.01, 1)) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" {}
_DecalTex ("Decal (RGBA)", 2D) = "black" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 150
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Pass {
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {matrix [_Rotation] combine texture * primary double, texture}
SetTexture [_DecalTex] {combine texture lerp (texture) previous}
}
}
Fallback "VertexLit", 1
}
The script attached is:
public bool RotateMainTexture = true;
void Update()
{
if(RotateMainTexture)
{
rot = Quaternion.Euler (0, 0, Time.time * rotateSpeed);
m = Matrix4x4.TRS (new Vector2(0,0), rot,new Vector3(1,1,1));
renderer.material.SetMatrix ("_Rotation", m);
}
}