Surface Shader和Deferred渲染路径

作者:追风剑情 发布于:2014-7-26 11:48 分类:Shader

实验目的:在Deferred渲染路径下ForwardBass是否会被执行?

  1. Shader "Custom/noDeferredSurf_1" {
  2. Properties {
  3. _MainTex ("Base (RGB)", 2D) = "white" {}
  4. }
  5. SubShader {
  6. Tags { "RenderType"="Opaque" }
  7. LOD 200
  8. //.1
  9. Pass {
  10. Tags {"LightMode"="ForwardBase"}
  11. CGPROGRAM
  12. #pragma vertex vert
  13. #pragma fragment frag
  14. #include "UnityCG.cginc"
  15. #include "Lighting.cginc"
  16. struct vertOut {
  17. float4 pos:SV_POSITION;
  18. float4 color:COLOR;
  19. };
  20. vertOut vert(appdata_base v)
  21. {
  22. vertOut o;
  23. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  24. o.color = float4(0, 1, 0, 1);//输出绿色
  25. return o;
  26. }
  27. float4 frag(vertOut i):COLOR
  28. {
  29. return i.color;
  30. }
  31. ENDCG
  32. }
  33. //.2
  34. Blend One One
  35. CGPROGRAM
  36. //exclude_path:prepass参数告诉Unity不要为Deferred渲染路径产生Shader
  37. #pragma surface surf Lambert exclude_path:prepass
  38. #pragma debug
  39. sampler2D _MainTex;
  40.  
  41. struct Input {
  42. float2 uv_MainTex;
  43. };
  44.  
  45. void surf (Input IN, inout SurfaceOutput o) {
  46. half4 c = tex2D (_MainTex, IN.uv_MainTex);
  47. o.Albedo = c.rgb;
  48. o.Alpha = c.a;
  49. }
  50. ENDCG
  51. }
  52. FallBack Off
  53. }

效果

deferred.png


结论:

在Deferred渲染路径下,没有适合于Deferred模式的Pass,Unity会执行适合于Forward模式的Pass

标签: Shader

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号