标签:
http://m.blog.csdn.net/blog/stalendp/40859441
官方例子AngryBots的链接地址:http://u3d.as/content/unity-technologies/angry-bots/5CF
《Unity Shaders and Effects Cookbook》的章节:
Chapter 10 Screen Effects with Unity Render Textures
Chapter 11 Gameplay and Screen Effects
[GPU Gems] Real-Time Glow:http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html
using UnityEngine;
[ExecuteInEditMode]
public class _MultiTap_y: MonoBehaviour
{
public GUISkin skin;
public string[] labels;
public Rect[] rLabels;
public float[] vals;
public Rect[] rSliders;
public Material myMat;
void OnGUI()
{
GUI.skin = skin;
for (int i = 0; i < labels.Length; i++)
{
GUI.Label(rLabels[i], labels[i]);
}
vals[0] = GUI.HorizontalSlider(rSliders[0],vals[0],-8f,8f);
}
void OnRenderImage (RenderTexture src, RenderTexture dst)
{
Graphics.BlitMultiTap(src,dst,myMat,
new Vector2(vals[0],vals[0]),
new Vector2(vals[0],vals[0])
);
}
}
//====================
Shader "Tut/Effects/ConeTap_0y" {
Properties {
_MainTex ("", 2D) = "white" {}
}
Subshader {
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : POSITION;
half4 uv[2] : TEXCOORD0;
};
float4 _MainTex_TexelSize;
float4 _BlurOffsets;
v2f vert (appdata_img v)
{
v2f o;
float offX = _MainTex_TexelSize.x * _BlurOffsets.x;
float offY = _MainTex_TexelSize.y * _BlurOffsets.y;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
float2 uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord.xy-float2(offX, offY));
o.uv[0].xy = uv + float2( offX, offY);
o.uv[0].zw = uv + float2(-offX, offY);
o.uv[1].xy = uv + float2( offX,-offY);
o.uv[1].zw = uv + float2(-offX,-offY);
return o;
}
sampler2D _MainTex;
fixed4 frag( v2f i ) : COLOR
{
fixed4 c;
c = tex2D( _MainTex, i.uv[0].xy );
c += tex2D( _MainTex, i.uv[0].zw );
c += tex2D( _MainTex, i.uv[1].xy );
c += tex2D( _MainTex, i.uv[1].zw );
return c/4.0;
}
ENDCG
}
}
Fallback off
}
标签:
原文地址:http://www.cnblogs.com/j349900963/p/4543897.html