Hello,
I am working on a small project by myself. The goal is to draw graphs of math functions on mobile. I have three ways of doing it but couldn’t decide which one to go with. Here are those;
- This is the simplest solution that i have found but cannot guess if would it be so heavy for mobile. Since a line is a collection of dots, i’ve been thinking to draw lines using small quad meshes. Instantiating thousands of quad meshes along the path and create a line.
2)Using the line renderer which is almost the same with trail renderer.
3)Using the trail renderer which an empty gameobject will move along the path of the curve to create trail that will represent a line afterwards.
Also i have one problem that is caused by the particle additive shader. The problem is where the curve occurs there are some dirty looking straight lines because of the shader itself is transparent somehow. I set all the alpha values to 255 but it doesn’t solve the dirty look. Any ideas?
Thank you in advance!
maybe try this shader: (just ignore the commented zExtrusion )
Shader "TrailWithZWrite" {
Properties{
_Color("Main Color", Color) = (1,1,1,0.5)
_AlphaTex("Base (RGB) Trans (A)", 2D) = "white" {}
//_ExtrusionAmount("Z Extrusion Amount", Float) = 0
}
SubShader{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
LOD 100
ZWrite On
ZTest Less
Blend SrcAlpha One
//Offset 0, -5000
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
fixed4 _Color;
sampler2D _AlphaTex;
//float _ExtrusionAmount;
float4 _AlphaTex_ST;
struct v2f {
float4 pos : SV_POSITION;
half4 color : COLOR0;
float2 uv : TEXCOORD0;
};
v2f vert(appdata_full v)
{
v2f o;
//float3 camDirObjSpace = normalize(ObjSpaceViewDir(v.vertex));
//v.vertex.xyz += _ExtrusionAmount * camDirObjSpace;
o.color = v.color;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _AlphaTex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 texcol = tex2D(_AlphaTex, i.uv) * i.color;
return texcol * _Color;
}
ENDCG
}
}
FallBack "Unlit/Transparent Cutout"
}