shader
Shader "Paint3D/AddTexture"
{
Properties
{
_MainTex ("Main Texture", 2D) = "white" {}
_MainColor("Main Color", Color)=(1,1,1,1)
_AddTex0 ("Texture0", 2D) = "white" {}
_AddTex1 ("Texture1", 2D) = "white" {}
_offsetX("offsetX",Range(-5,5)) = 0
_offsetY("offsetY",Range(-5,5)) = 0
_oftX("oftX",Range(-5,5)) = -0.67
_deg("scaleZ",Range(-360,360)) = 0
_Color("AddColor",Color)= (1,1,1,1)
_imageSize("ImageSize整体",float)=10
_expendSize("Expend拖拽拉伸",float)=1
_size("Size粗细",float)=1
_isShow("isShow",float)=0
_height("Screeheight暂时无用",float)=1536
_Imgwidth("Imgwidth暂时无用",float)=200
_Imgheight("Imgheight暂时无用",float)=200
}
SubShader
{
Tags { "Queue"="AlphaTest" "RenderType"="Transparent" }
LOD 200
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_fog
// #pragma surface Surf Standard alphatest:_Cutoff addshadow
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
UNITY_FOG_COORDS(1)
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
sampler2D _AddTex0;
sampler2D _AddTex1;
float4 _MainTex_ST;
fixed4 _Color;
fixed4 _MainColor;
float _offsetX;
float _offsetY;
float _oftX;
float _deg;
float _isShow;
float _height;
float _Imgwidth;
float _Imgheight;
float _imageSize;
float _expendSize;
float _size;
v2f vert (appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 texCol ;
if(_isShow==0){
texCol = tex2D(_MainTex, i.texcoord);
return texCol*_MainColor;
}
float3 uvw0= float3(i.texcoord.x,i.texcoord.y,1);
float3 uvw1= float3(i.texcoord.x,i.texcoord.y,1);
float3x3 transla0=float3x3(float3(1,0,-_offsetX),float3(0,1,-_offsetY),float3(0,0,1));
float3x3 transla1=float3x3(float3(1,0,-_offsetX),float3(0,1,-_offsetY),float3(0,0,1));
uvw0 =mul(transla0, uvw0);
uvw1 =mul(transla1, uvw1);
float rad=radians(_deg);
float3x3 rotate=float3x3(float3(cos(rad),-sin(rad),0),float3(sin(rad),cos(rad),0),float3(0,0,1));
uvw0 =mul(rotate, uvw0);
uvw1 =mul(rotate, uvw1);
float3x3 scale0=float3x3(float3(_imageSize/_expendSize,0,-0.5),float3(0,_imageSize*_size,0),float3(0,0,1));
float3x3 scale1=float3x3(float3(_imageSize,0,-_expendSize),float3(0,_imageSize*_size,0),float3(0,0,1));
//float3x3 scale=float3x3(float3(_width/_imageSize/_expendSize,0,0),float3(0,_height/_imageSize,0),float3(0,0,1));
uvw0 =mul(scale0 ,uvw0);
uvw1 =mul(scale1 ,uvw1);
float2 uv0=float2(uvw0.x,uvw0.y);
float2 uv1=float2(uvw1.x,uvw1.y);
uv0+=0.5;
uv1+=0.5;
texCo