Skip to content

Commit 5747a3a

Browse files
committed
Fix: カメラが近づいた時負荷が上がる問題に対処
1 parent 797ad27 commit 5747a3a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Assets/HipParticle/Scenes/HipParticleMobile.unity

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ PrefabInstance:
123123
propertyPath: m_Name
124124
value: ConstellationLine
125125
objectReference: {fileID: 0}
126+
- target: {fileID: 1734431167554066, guid: 4971b1241fd564745a3a33cbc9fdac5a, type: 3}
127+
propertyPath: m_IsActive
128+
value: 1
129+
objectReference: {fileID: 0}
126130
- target: {fileID: 4094628960794872, guid: 4971b1241fd564745a3a33cbc9fdac5a, type: 3}
127131
propertyPath: m_LocalPosition.x
128132
value: 0

Assets/HipParticle/Shaders/HipParticleMobile.shader

+11-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
struct v2f
3434
{
3535
float2 uv : TEXCOORD0;
36-
float2 triuv : TEXCOORD1;
36+
float3 color : TEXCOORD1;
3737
float4 vertex : SV_POSITION;
3838
};
3939

@@ -72,32 +72,34 @@
7272
float aspectRatio = - UNITY_MATRIX_P[0][0] / UNITY_MATRIX_P[1][1];
7373

7474
float2 uv = float2((floor(v.vertex.z / texWidth) + 0.5) / texWidth, (fmod(v.vertex.z, texWidth) + 0.5) / texWidth);
75-
o.uv = uv;
7675

7776
float3 p = unpack(uv).xzy;
7877
float4 vp1 = UnityObjectToClipPos(float4(p, 1));
7978

79+
float3 c = tex2Dlod(_Col, float4(uv,0,0)).xyz;
80+
o.color = c;
81+
8082
float sz = unpack_int(uv) * _Mag_param + _Mag_min;
8183
float3x2 triVert = float3x2(
8284
float2(0, 1),
8385
float2(0.9, -0.5),
8486
float2(-0.9, -0.5));
85-
o.triuv = triVert[round(v.vertex.y)];
87+
o.uv = triVert[round(v.vertex.y)];
88+
89+
if(length(c) < 0.1 && length(p) < 0.1) sz = 0;
8690
if (abs(UNITY_MATRIX_P[0][2]) < 0.0001) sz *= 2;
8791
sz *= pow(determinant((float3x3)UNITY_MATRIX_M),1/3.0);
88-
o.vertex = vp1+float4(o.triuv*sz*float2(aspectRatio,1),0,0);
92+
o.vertex = vp1+float4(o.uv*sz*float2(aspectRatio,1),0,0);
8993
return o;
9094
}
9195

9296
fixed4 frag (v2f i) : SV_Target
9397
{
94-
float l = length(i.triuv);
95-
float3 c = tex2D(_Col, i.uv).xyz;
96-
if(length(c) < 0.001 && length(tex2D(_Pos, i.uv).xyz) < 0.1) clip(-1);
98+
float l = length(i.uv);
9799
clip(0.5-l);
98-
return float4(c, 1.0 - pow(max(0.0, abs(l) * 2.2 - 0.1), 0.2));
100+
return float4(i.color, 1.0 - pow(max(0.0, abs(l) * 2.2 - 0.1), 0.2));
99101
}
100102
ENDCG
101103
}
102104
}
103-
}
105+
}

0 commit comments

Comments
 (0)