- 最后登录
- 2018-6-29
- 注册时间
- 2011-7-1
- 阅读权限
- 20
- 积分
- 359

- 纳金币
- 335582
- 精华
- 0
|
此shader效果未经实际测试,朋友们可以测试下!
Here is shader file (save as Dream.shader in your assets folder):
Shader "Hidden/Dream" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
float4 frag (v2f_img i) : COLOR {
float4 c = tex2D(_MainTex, i.uv);
c += tex2D(_MainTex, i.uv+0.001);
c += tex2D(_MainTex, i.uv+0.003);
c += tex2D(_MainTex, i.uv+0.005);
c += tex2D(_MainTex, i.uv+0.007);
c += tex2D(_MainTex, i.uv+0.009);
//c += tex2D(_MainTex, i.uv+0.011);
c += tex2D(_MainTex, i.uv-0.001);
c += tex2D(_MainTex, i.uv-0.003);
c += tex2D(_MainTex, i.uv-0.005);
c += tex2D(_MainTex, i.uv-0.007);
c += tex2D(_MainTex, i.uv-0.009);
//c += tex2D(_MainTex, i.uv-0.011);
c.rgb = float3((c.r+c.g+c.b)/3.0);
c = c / 9.5;
return c;
}
ENDCG
}
}
Fallback off
}
here is code to be attached to camera (save as dream.cs):
using UnityEngine;
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/Dream")]
public class Dream : ImageEffectBase {
// Called by camera to apply image effect
void OnRenderImage (RenderTexture source, RenderTexture destination) {
Graphics.Blit (source, destination, material);
}
} |
|