ãUnityããããªã¢ã«ã®æç»ãã·ã§ã¼ãã¼ã®Queueé ã«å¦çãããªãåå ã¨å¯¾ç
èªä½ã·ã§ã¼ãã¼ãªã©ã使ç¨ãã¦ã¬ã³ããªã³ã°ãè¡ãå ´åãã¬ã³ããªã³ã°é åºãTagsã®Queueã§æå®ãã¾ãããç¹å®ã®æ¡ä»¶ã§ãã®ã¬ã³ããªã³ã°é åºãç¡è¦ãããç¾è±¡ãçºçããã®ã§å ±æã
ç°¡æ½ã«ã¾ã¨ãã ã
ã¾ã¨ããã¨
ç¾è±¡ããï¼ã·ã§ã¼ãã¼ã§æå®ããã¬ã³ããªã³ã°ãã¥ã¼ãç¡è¦ããããã¨ããã
åå ããï¼Materialã®Custom Render Queueã«ä¸æ£å¤ãå
¥ã£ã¦ãããã
çºçæ¡ä»¶ï¼èªä½ã·ã§ã¼ãã¼ã使ç¨ãï¼ãèªä½ã·ã§ã¼ãã¼è¨å®åã«ãä»ã®ã·ã§ã¼ãã¼ãå²ãå½ã¦ã¦ããå ´å
対çããï¼Custom Render Queueã«-1ãè¨å®ããã°OK
ãããããã¬ã³ããªã³ã°é åºã«ã¤ãã¦
ã¬ã³ããªã³ã°é åºã¯ãã·ã§ã¼ãã¼ã®Tags Queueã«è¨å®ããã以ä¸ã®é ã«ãªãã¾ãï¼ãªã«ãæå®ããªãå ´åã¯"Geometry"ï¼ã
Tags{ "Queue"="Geometry" }
ã»Background
ã»Geometryï¼ããã©ã«ãï¼
ã»AlphaTest
ã»Transparent
ã»Overlay
ç¾è±¡
ããããç¹å®ã®ç¶æ³ã§ãã®Queueãç¡è¦ãããç¶æ³ãçºçãã¾ãã
ä¾ãã°ä»¥ä¸ã®ç»åã§ã¯ã奥ã®ãã§ãã¯æã«ã¯Unlit-Colorã·ã§ã¼ãã¼(Queue=Geometry)ããæåã®ãã¥ã¼ãã«ã¯èªä½ã®åéæã·ã§ã¼ãã¼(Queue=Transparent)ãè¨å®ãã¦ãã¾ããããã¥ã¼ããå端ã«æç»ããã¦ãã¾ããã«ã¡ã©è§åº¦ã«ãã£ã¦ã¯å®å
¨ã«æ¶ãã¦ãã¾ãã¾ãã
ã¡ãªã¿ã«èªä½ã·ã§ã¼ãã¼ã®ä¸èº«ã¯ãããªæãã§ããQueueã«Transparentãè¨å®ããZTestã«Always(深度ãã§ãã¯ã¯å¸¸ã«OK)ãæå®ãã¦ãã¾ããã·ã§ã¼ãã¼çã«ã¯ãå®å ¨ã«æç»ãããã¯ãã§ãã
Shader "Custom/Alpha Blended" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _Alpha ("Alpha", Range(0, 1)) = 1 } SubShader { Tags { "Queue"="Transparent" "RenderType"="Transparent" } Blend SrcAlpha OneMinusSrcAlpha Lighting Off ZWrite Off ZTest Always Fog { Color (0,0,0,0) } CGPROGRAM #pragma surface surf Lambert fixed _Alpha; float4 _Color; struct Input { float4 color : COLOR; }; void surf (Input IN, inout SurfaceOutput o) { o.Albedo = _Color.rgb; o.Alpha = _Alpha; } ENDCG } }
åå
çµè«ããæ¸ãã¨ãMaterialã®Custom Render Queueãåå ã§ãã
Materialãé¸æããç¶æ
ã§ãInspectorããããã°ã¢ã¼ãã§éãã¾ãããããã°ã¢ã¼ãã¯ã以ä¸ã®å ´æããéãã¾ãã
表示ãããé
ç®ã®ãCustom Render Queueã«æ³¨ç®ãã¦ãã ãããä¸å³ã ã¨ã2000ã¨å
¥åããã¦ãã¾ãã
å®ã¯ãã®Custom Render Queueãã·ã§ã¼ãã¼ã§æå®ããQueueã«å¯¾å¿ãã¦ãã¦ãunityã¯ãã®æ°åã«å¾ã£ã¦ã¬ã³ããªã³ã°ãè¡ã£ã¦ããæ§åã§ãã
Background 1000
Geometry 2000
AlphaTest 2450
Transparent 3000
Overlay 4000
ä½æ
èªä½ã·ã§ã¼ãã¼ã¯Queue=Transparentãªã®ã«Custom Render Queueã2000ã«ãªã£ã¦ãããã¨ããã¨ããã®èªä½ã·ã§ã¼ãã¼ãè¨å®ããåã«ãMaterialã«Unlit-Colorãè¨å®ãã¦ããããã§ããèªä½ã·ã§ã¼ãã¼ãè¨å®ããå ´åãèªåã§Custom Render Queueãæ´æ°ãã¦ãããªãæ§åããã
対ç
対çã¯ç°¡åã§ãCustom Render Queueã«-1ãè¨å®ããã°ãã·ã§ã¼ãã¼ã«æ¸ããQueueéãã«åä½ãã¾ãã
ãããã¯ã¾ã£ãã¯ã¾ã£ããUnityã¯ãããããããæãã