纳金网

标题: shader效果-梦幻 [打印本页]

作者: 会飞的鱼    时间: 2012-6-26 15:06
标题: 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);
}
}
You will need the imageeffectbase.cs file from the imageeffects package

原文:http://f***m.unity3d.com/threads ... f308ed98725b9194e92




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5