电子商务网站建设课程心得,免费建站建站,深圳最新新闻事件,wordpress发布失败粒子特效使用的材质球#xff0c;如果通过动画控制shader的某个参数#xff0c;例如溶解阈值#xff0c;所有的粒子都会按照相同的数值变化#xff0c;如果需要每个粒子在自己的生命周期内按照曲线变化#xff0c;则可以通过customData实现。
1.ParticleSystem中勾选Cust…粒子特效使用的材质球如果通过动画控制shader的某个参数例如溶解阈值所有的粒子都会按照相同的数值变化如果需要每个粒子在自己的生命周期内按照曲线变化则可以通过customData实现。
1.ParticleSystem中勾选CustomData,支持8个通道可以选择固定参数或者曲线 2.ParticleSystem中勾选Render中的Custom Vertex Streams 添加custom1和custom2两个通道各支持四个通道 注意不可以调整上图内UV和Custom的顺序上图就是默认添加后的顺序
uv TEXCOORD0.xy
Custom1.xy TEXCOORD0.zw Custom1.zw TEXCOORD1.xy
Custom2.xy TEXCOORD1.zw Custom2.zw TEXCOORD2.xy
由于uv占用了TEXCOORD0寄存器因此Custom2.zw存在了TEXCOORD2寄存器
Shader Unlit/TestCustomData
{Properties{_MainTex (Texture, 2D) white {}_TestValue(TestValue1,Range(0,0.5)) 0.2}SubShader{Tags { RenderTypeOpaque }LOD 100Pass{CGPROGRAM#pragma vertex vert#pragma fragment frag#include UnityCG.cgincfloat _TestValue;struct appdata{float4 vertex : POSITION; float4 customData1 : TEXCOORD0; float4 customData2 : TEXCOORD1; float4 customData3 : TEXCOORD2; };struct v2f{float2 uv : TEXCOORD0; float4 vertex : SV_POSITION;float4 testData1 : TEXCOORD1;float4 testData2 : TEXCOORD2; };sampler2D _MainTex;float4 _MainTex_ST;v2f vert (appdata v){v2f o;o.vertex UnityObjectToClipPos(v.vertex);o.uv TRANSFORM_TEX(v.customData1.xy, _MainTex);o.testData1.xy v.customData1.zw;o.testData1.zw v.customData2.xy;o.testData2.xy v.customData2.zw;o.testData2.zw v.customData3.xy;return o;}fixed4 frag (v2f i) : SV_Target{ fixed4 col tex2D(_MainTex, i.uv);//col * i.testData1;col i.testData2;return col;}ENDCG}}
}