无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Unity shader 實現(xiàn)氮氣加速特效

2019-12-05 14:25 作者:博毅創(chuàng)為  | 我要投稿

1:材質(zhì)和shader

Shader 是一種給GPU執(zhí)行的代碼,GPU的渲染流水線,為了方便開發(fā)人員定制效果,開放出接口給程序員編寫代碼來控制,這種程序叫作shader, shader開發(fā)語言,cocos采用的是GLSL編程語言。開發(fā)人員可以在下圖頂點Shader和著色Shader來插入代碼。

材質(zhì)是一種配置文件,選擇好一個Shader(算法), 并給這個Shader提供必要的參數(shù),當(dāng)游戲引擎繪制物體的時候,先讀取材質(zhì),根據(jù)材質(zhì), 給GPU配置shader和shader要的參數(shù), 這樣管道流水線就可以完成的繪制出來這個物體。

2: 準(zhǔn)備工作

準(zhǔn)備一個子彈頭模型(子彈列車^_^)

準(zhǔn)備一個加速特效的火焰與透明漸變的貼圖:

3: 實現(xiàn)的效果:

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"

}

氮氣加速特效詳細(xì)的視頻詳細(xì)講解,和項目工程,可以加學(xué)習(xí)討論群,今天的分享都到這里結(jié)束了,謝謝大家。


Unity shader 實現(xiàn)氮氣加速特效的評論 (共 條)

分享到微博請遵守國家法律
右玉县| 铁岭县| 石家庄市| 咸阳市| 兰坪| 延寿县| 永丰县| 长垣县| 余江县| 庐江县| 依安县| 汤原县| 娄烦县| 银川市| 金堂县| 登封市| 五大连池市| 沁源县| 乳山市| 锡林浩特市| 尉氏县| 洛南县| 洛阳市| 高碑店市| 虞城县| 双城市| 沙湾县| 武汉市| 开平市| 阿尔山市| 文山县| 齐齐哈尔市| 兴安县| 沙河市| 柳州市| 积石山| 海阳市| 工布江达县| 同江市| 鄂托克前旗| 景洪市|