在线等待,问一个关于shader的问题
unity3d吧
全部回复
仅看楼主
level 11
时灬尚c 楼主
我在网上找到的播放序列帧的shader代码:
Shader "HELLOHUAN/Hello_Sequence" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_SizeX ("列数", Float) = 4
_SizeY ("行数", Float) = 4
_Speed ("播放速度", Float) = 200
}
SubShader {
Tags { "RenderType"="Opaque"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
fixed4 _Color;
uniform fixed _SizeX;
uniform fixed _SizeY;
uniform fixed _Speed;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
int index = floor(_Time .x * _Speed);
int indexY = index/_SizeX;
int indexX = index - indexY*_SizeX;
float2 testUV = float2(IN.uv_MainTex.x /_SizeX, IN.uv_MainTex.y /_SizeY);
testUV.x += indexX/_SizeX;
testUV.y += indexY/_SizeY;
fixed4 c = tex2D(_MainTex, testUV) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
//o.Albedo = float3( floor(_Time .x * _Speed) , 1.0, 1.0);
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
2014年11月11日 03点11分 1
level 11
时灬尚c 楼主
然后想把unity中自带的Particles/Additive的代码进行融合,但是本人不会写shader,哪位大神会弄啊???
这么做的目的就是在于,想在一个Plane上用高亮叠加的方式播放序列帧,不知道哪位大侠能帮个忙??????
2014年11月11日 03点11分 2
在LOD 200下面加上两句 Blend One One 和ZWrite Off
2014年11月11日 04点11分
根本不需要和Additive的代码融合,高亮叠加的关键在于Blend One One 基础啊…
2014年11月11日 04点11分
这样就可以了?
2014年11月11日 04点11分
这样就可以像用自带的Particles/Additive的这个材质球那样,只要贴图的底儿是黑的,就能透明了???
2014年11月11日 04点11分
level 13
这个shader在手机上会出现time的精度问题吧
时间久了uv就会乱掉了
2014年11月11日 03点11分 3
额,主要是要用这个做刀光,想在unity中播放序列帧。unity自带的trial系统段数不圆滑
2014年11月11日 03点11分
您老做刀光的话,有没有好的方法介绍下,而且要效果好的
2014年11月11日 03点11分
回复 时灬尚c :https://tieba.baidu.com/p/3403686193 我刚刚发的 你试试看呗
2014年11月11日 04点11分
回复 魂淡星奈 :主要是在surf中或者在frag中计算time有点不准,就想着把time的计算放到vert中去
2014年11月11日 04点11分
1