Drawing generated mesh with vertex offset doesnt look the same on android
Alright, so im generating a custom mesh from code like this:
mesh = new Mesh();
width = 64;
height = 64;
Vector3[] verticies = new Vector3[width * height];
for (int x = 0; x < (int)Mathf.Sqrt(width * height); x++)
{
for (int y = 0; y < (int)Mathf.Sqrt(width * height); y++)
{
verticies[x * width + y] = new Vector3((float)x / (float)width, (float)y / (float)height, 0);
}
}
var incicies = new int[verticies.Length];
for (int i = 0; i < verticies.Length; i++)
incicies[i] = i;
mesh.SetVertices(verticies.ToList());
mesh.SetIndices(incicies, MeshTopology.Points, 0, true);
Using this shader to offset the vertex of the mesh:
Shader "Custom/VertexTest"
{
Properties
{
}
SubShader
{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
Blend One One
Cull Off Lighting Off ZWrite Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// #pragma target 3.0
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : SV_POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.vertex.x += v.vertex.x;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return float4(0.2f, 0.2, 0.8f, 1.0f);
}
ENDCG
}
}
}
And i draw it in OnPostRender like this:
void OnPostRender()
{
RenderTexture.active = null;
var material = new Material(Shader.Find("Custom/VertexTest"));
material.SetPass(0);
Graphics.DrawMeshNow(mesh, new Vector3(0, 0, 0), Quaternion.identity);
}
It looks fine and as expected in editor and on windows. But on android it only renders two points in total, it seems to be the two end points, like first and last points. Im not sure if im missing something simple but i dont understand why it looks diffrent on android to the editor. Also adding "float size : PSIZE;" to v2f struct and changing size seems only to affect editor/pc aswell when setting o.size = 10.0f;
Here is how it looks on PC: http://puu.sh/qv3Ri/d57d66ba18.png
Your answer
Follow this Question
Related Questions
How to fix the "torn" model bug in Skinned Mesh Render? 0 Answers
I have a problem with skinned render mesh on Android. 0 Answers
Dynamic meshes not visible on android (samsung galaxy s6) 2 Answers
how to create move brush to deform mesh 0 Answers
Graphics.DrawMeshInstanced Doesn't work with transparent materials 1 Answer