Unity Shader は「Nitrogen Acceleration Special Effects」を実装します

1: マテリアルとシェーダー

シェーダーは、GPU のレンダリング パイプラインである GPU に対して実行される一種のコードであり、開発者が効果をカスタマイズしやすくするために、プログラマーがコードを記述して制御するためのインターフェイスを開きます。この種のプログラムは、シェーダー、シェーダー開発言語、cocos と呼ばれます。 GLSL プログラミング言語を使用します。開発者は、次の図の頂点シェーダーとシェーダー シェーダーにコードを挿入できます。

マテリアルは構成ファイルです. シェーダー (アルゴリズム) を選択し、シェーダーに必要なパラメーターを提供します. ゲーム エンジンがオブジェクトを描画するときは、まずマテリアルを読み取り、シェーダーとシェーダーに必要なパラメーターを使用して GPU を構成しますこのようにして、パイプライン パイプラインはオブジェクトの描画を完了することができます。

2: 準備

弾頭モデルを用意(新幹線^_^)

高速化された炎と透明なグラデーションを使用してテクスチャを準備します。

3: 達成された効果:

4: 上記のコード:

Shader "Custom/additiveTex_2" {
	Properties {
		_TintColor ("Tint Color", Color) = (0.5, 0.5, 0.5, 0.5)
		_Intensity ("Intensity", Float) = 1.0
		_MainTexture ("Base (RGB) Alpha(A)", 2D) = "white" {}
		_Mask    ("Mask (ARGB or Grayscale)", 2D) = "white" {}
		_speed("speed",Float)=5
	}
	
	Category {
		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
			
	    Blend SrcAlpha One
	    AlphaTest Greater 0.01
	    ColorMask RGB
	    Cull Off
	    Lighting Off
	    ZWrite Off

	    // Fog { Color (0,0,0,0) }
		/*BindChannels {
	        Bind "Color", color
	        Bind "Vertex", vertex
	        Bind "TexCoord", texcoord
    	}*/

		SubShader {
			Pass {
				CGPROGRAM
				#pragma vertex vert
				#pragma fragment frag
				#pragma fragmentoption ARB_precision_hint_fastest

				#include "UnityCG.cginc"

				fixed4 _TintColor;
				float  _Intensity;
				sampler2D _MainTexture;
				sampler2D _Mask;

				float _speed;

				float4 _MainTexture_ST;
				float4 _Mask_ST;
				
				struct appdata_t {
					float4 vertex : POSITION;
					fixed4 color : COLOR;
					float2 texcoord : TEXCOORD0;
					float2 texcoord2 : TEXCOORD1;
				};

				struct v2f {
					float4 vertex : POSITION;
					fixed4 color : COLOR;
					float2 texcoord : TEXCOORD0;
					float2 texcoord2 : TEXCOORD1;
				};

				v2f vert (appdata_t v)
				{
					v2f o;
					o.vertex = UnityObjectToClipPos(v.vertex);
					o.color = v.color;
					o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTexture);
					o.texcoord2 = TRANSFORM_TEX(v.texcoord2,_Mask);
					return o;
				}
					
				fixed4 frag (v2f i) : COLOR
				{
					i.texcoord.x+=_Time*_speed;
					i.texcoord.y-=(_Time*_speed*16);
					
					half4 c = i.color * _TintColor * tex2D(_MainTexture, i.texcoord);
					half4 mask = tex2D(_Mask, i.texcoord2);
					c *= mask.a;
					return _Intensity * c;					
				}
				ENDCG 
			}
		}
	} 
	FallBack "Diffuse"
}

窒素加速効果とプロジェクトエンジニアリングの詳細なビデオ説明は、学習ディスカッショングループに追加できます. 今日の共有はここまでです.

おすすめ

転載: blog.csdn.net/voidinit/article/details/126478394