Home>
shader "unlit/render_reflect"
{
properties
{
_maintex ("texture", 2d)="white" {}
}
subshader
{
tags {"queue"="transparent" "rendertype"="opaque"}
lod 100
grabpass {"_ screentex"}
pass
{
cgprogram
#pragma vertex vert
#pragma fragment frag
//make fog work
#pragma multi_compile_fog
#include "unitycg.cginc"
#include "lighting.cginc"
#include "autolight.cginc"
struct appdata
{
float4 vertex:position;
float2 uv:texcoord0;
};
struct v2f
{
float4 uv:texcoord0;
float2 uv2:texcoord1;
float4 vertex:sv_position;
};
sampler2d _maintex;
float4 _maintex_st;
sampler2d _screentex;
v2f vert (appdata v)
{
v2f o;
o.vertex=unityobjecttoclippos (v.vertex);
o.uv2=transform_tex (v.uv, _maintex);
o.uv=computegrabscreenpos (o.vertex);
//o.uv.x=1-o.uv.x;
return o;
}
fixed4 frag (v2f i):sv_target
{
//sample the texture
i.uv.xy +=float2 (0.1,0.1);
fixed4 fra=tex2d (_screentex, i.uv.xy/i.uv.w);
fixed4 fle=tex2d (_maintex, i.uv2);
//apply fog
return lerp (fra, fle, 0.2);
}
endcg
}
}
}
Related articles
Related questions
- Unity Shader achieves cutting effect
- Unity Shader realizes the fog of 2D games
- Unity Shader realizes the sketch effect
- Unity Shader implements sketch-style rendering
- Unity Shader achieves graphics drawing (blue sky, white clouds and sea)
- Unity shader realizes the effect of vertex animation wave
- Unity Shader achieves dynamic fog effect
- Unity Shader achieves glass material effect
- Unity Shader intersection algorithm realizes simple anti-energy shield