unity 全屏乱影 BlitMultiTap
http://m.blog.csdn.net/blog/stalendp/40859441
官方例子AngryBots的链接地址:http://u3d.as/content/unity-technologies/angry-bots/5CF
《Unity Shaders and Effects Cookbook》的章节:
[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
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。