Синтаксис:
Используется glsl
Shader "Cg/ReflectorSight"{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_ReticleSize("ReticleSize", float) = 2.0
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha One
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
float _ReticleSize;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = v.vertex.xy*_ReticleSize-mul((float3x3)_World2Object, _WorldSpaceCameraPos-mul(_Object2World, float4(0,0,0,1))).xy*_ReticleSize+float2(0.5, 0.5);
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord);
return col;
}
ENDCG
}
}
}
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_ReticleSize("ReticleSize", float) = 2.0
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha One
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
float _ReticleSize;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = v.vertex.xy*_ReticleSize-mul((float3x3)_World2Object, _WorldSpaceCameraPos-mul(_Object2World, float4(0,0,0,1))).xy*_ReticleSize+float2(0.5, 0.5);
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord);
return col;
}
ENDCG
}
}
}