最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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)氮氣加速特效的評論 (共 條)

分享到微博請遵守國家法律
老河口市| 加查县| 镇康县| 淮安市| 宜黄县| 苗栗县| 新平| 莱西市| 剑河县| 墨竹工卡县| 石狮市| 南京市| 化州市| 五峰| 郑州市| 日喀则市| 恩平市| 兴化市| 玉门市| 达孜县| 长沙市| 黄浦区| 天全县| 从化市| 开阳县| 大冶市| 镇安县| 五常市| 台前县| 舞阳县| 顺平县| 霍林郭勒市| 开封市| 高台县| 任丘市| 沧州市| 沐川县| 富蕴县| 屏东县| 衢州市| 略阳县|