Skip to content

Commit e3a9607

Browse files
committed
Mobile diffuse shader improvements
1 parent 4dbe158 commit e3a9607

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Runtime/Shaders/Mobile-Diffuse-MeshAnimation.shader

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Shader "Mobile/Diffuse (Mesh Animation)" {
22
Properties {
33
_MainTex ("Base (RGB)", 2D) = "white" {}
4-
_AnimTex ("Animation (RGB)", 2D) = "white" {}
4+
5+
[Header(Mesh Animation)]
6+
_AnimTex ("Animation", 2D) = "white" {}
57
_AnimMul ("Animation Bounds Size", Vector) = (1, 1, 1, 0)
68
_AnimAdd ("Animation Bounds Offset", Vector) = (0, 0, 0, 0)
79
[PerRendererData] _AnimTime ("Animation Time", Vector) = (0, 1, 1, 0) /* (x: start, y: length, z: speed, w: startTime) */
@@ -51,15 +53,10 @@ Shader "Mobile/Diffuse (Mesh Animation)" {
5153

5254
float progress = (_Time.y - t.w) * t.z;
5355
float progress01 = lerp(saturate(progress), frac(progress), looping);
54-
float4 coords = float4(
55-
0.5 + v.vertexId,
56-
0.5 + t.x + progress01 * t.y,
57-
0,
58-
0
59-
);
60-
float4 position = tex2Dlod(_AnimTex, coords * _AnimTex_TexelSize) * _AnimMul + _AnimAdd;
56+
float2 coords = float2(0.5 + v.vertexId, 0.5 + t.x + progress01 * t.y) * _AnimTex_TexelSize.xy;
57+
float4 position = tex2Dlod(_AnimTex, float4(coords, 0, 0)) * _AnimMul + _AnimAdd;
6158

62-
v.vertex = position;
59+
v.vertex = float4(position.xyz, 1.0);
6360
}
6461

6562
void surf (Input IN, inout SurfaceOutput o) {

0 commit comments

Comments
 (0)