纳金网

标题: 梦幻画面效果Shader [打印本页]

作者: 王者再临    时间: 2014-4-30 22:11
标题: 梦幻画面效果Shader
此shader效果未经实际测试,朋友们可以测试下!

Here is shader file (save as Dream.shader in your assets folder):
  1. Shader "Hidden/Dream" {
  2. Properties {
  3. _MainTex ("Base (RGB)", 2D) = "white" {}
  4. }
  5. SubShader {
  6. Pass {
  7. ZTest Always Cull Off ZWrite Off
  8. Fog { Mode off }

  9. CGPROGRAM
  10. #pragma vertex vert_img
  11. #pragma fragment frag
  12. #pragma fragmentoption ARB_precision_hint_fastest
  13. #include "UnityCG.cginc"

  14. uniform sampler2D _MainTex;

  15. float4 frag (v2f_img i) : COLOR {
  16. float4 c = tex2D(_MainTex, i.uv);
  17. c += tex2D(_MainTex, i.uv+0.001);
  18. c += tex2D(_MainTex, i.uv+0.003);
  19. c += tex2D(_MainTex, i.uv+0.005);
  20. c += tex2D(_MainTex, i.uv+0.007);
  21. c += tex2D(_MainTex, i.uv+0.009);
  22. //c += tex2D(_MainTex, i.uv+0.011);

  23. c += tex2D(_MainTex, i.uv-0.001);
  24. c += tex2D(_MainTex, i.uv-0.003);
  25. c += tex2D(_MainTex, i.uv-0.005);
  26. c += tex2D(_MainTex, i.uv-0.007);
  27. c += tex2D(_MainTex, i.uv-0.009);
  28. //c += tex2D(_MainTex, i.uv-0.011);
  29. c.rgb = float3((c.r+c.g+c.b)/3.0);
  30. c = c / 9.5;
  31. return c;
  32. }
  33. ENDCG
  34. }
  35. }
  36. Fallback off
  37. }
  38. here is code to be attached to camera (save as dream.cs):
  39. using UnityEngine;
  40. [ExecuteInEditMode]
  41. [AddComponentMenu("Image Effects/Dream")]
  42. public class Dream : ImageEffectBase {
  43. // Called by camera to apply image effect
  44. void OnRenderImage (RenderTexture source, RenderTexture destination) {
  45. Graphics.Blit (source, destination, material);
  46. }
  47. }
复制代码

作者: uitgh    时间: 2014-5-28 11:07
给摄像机
作者: Kadina    时间: 2014-7-2 08:13
Thank you for this share!
作者: 青缕    时间: 2014-7-17 12:58
等效果.
作者: 翾辰    时间: 2014-7-18 21:43
看看怎么样!
作者: frontmission999    时间: 2014-7-19 23:21
謝謝分享
作者: kiskil    时间: 2014-9-24 10:59
啥效果?类似HDR?




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