You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.8 KiB
81 lines
1.8 KiB
3 years ago
|
Shader "Unlit/TestWarp1Shader"
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
_MainTex ("Texture", 2D) = "white" {}
|
||
|
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||
|
_GlassColor ("Glass Color" ,COLOR) = (1,1,1,1)
|
||
|
_ScaleTest("Scale Vertex" ,float) = 1
|
||
|
_TexTint("Tex Tint",float) = 0.2
|
||
|
}
|
||
|
SubShader
|
||
|
{
|
||
|
Tags { "RenderType"="Opaque" "Queue"="Transparent" }
|
||
|
LOD 100
|
||
|
GrabPass { "_RefractionTex2" }
|
||
|
Pass
|
||
|
{
|
||
|
CGPROGRAM
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
// make fog work
|
||
|
//#pragma multi_compile_fog
|
||
|
|
||
|
#include "UnityCG.cginc"
|
||
|
sampler2D _RefractionTex2;
|
||
|
float4 _RefractionTex2_ST;
|
||
|
sampler2D _BumpMap;
|
||
|
float4 _BumpMap_ST;
|
||
|
sampler2D _MainTex;
|
||
|
float4 _MainTex_ST;
|
||
|
float4 _GlassColor;
|
||
|
float _TexTint;
|
||
|
float _ScaleTest;
|
||
|
|
||
|
|
||
|
struct a2v
|
||
|
{
|
||
|
float4 vertex : POSITION;
|
||
|
float3 normal : NORMAL;
|
||
|
float2 uv : TEXCOORD0;
|
||
|
};
|
||
|
|
||
|
struct v2f
|
||
|
{
|
||
|
float4 vertex : SV_POSITION;
|
||
|
float4 scrPos : TEXCOORD0;
|
||
|
float2 uv : TEXCOORD1;
|
||
|
UNITY_FOG_COORDS(1)
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
v2f vert (a2v v)
|
||
|
{
|
||
|
v2f o;
|
||
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||
|
//o.vertex = float4(o.vertex.x+(1+sin(o.vertex.x+_ScaleTest)),o.vertex.y,o.vertex.z,o.vertex.w);
|
||
|
o.scrPos = ComputeGrabScreenPos(o.vertex);
|
||
|
return o;
|
||
|
}
|
||
|
|
||
|
fixed4 frag (v2f i) : SV_Target
|
||
|
{
|
||
|
fixed4 tex = tex2D(_MainTex, i.uv);
|
||
|
fixed4 texTint = _TexTint*fixed4(i.vertex.z,i.vertex.z,i.vertex.z,1);
|
||
|
// sample the texture
|
||
|
float2 offset = float2(1,1);
|
||
|
i.scrPos.xy = i.scrPos.xy+sin(float2(0,i.scrPos.y));
|
||
|
//i.scrPos.xy = tex.xy * i.scrPos.z + i.scrPos.xy;
|
||
|
fixed4 refrCol = tex2D(_RefractionTex2, i.scrPos.xy/i.scrPos.w);
|
||
|
fixed4 col = tex2D(_RefractionTex2, i.uv);
|
||
|
|
||
|
return refrCol+_GlassColor+tex*texTint;
|
||
|
//return tex*_TexTint;
|
||
|
}
|
||
|
ENDCG
|
||
|
}
|
||
|
}
|
||
|
}
|