Hi,
I modified a shader i found on the forums in order to render a mesh that only consists of vertices (MeshTopology.Points).
I want to be able to define the size each vertex is rendered with on screen using the shader.
Now I think it should work and changing the PointSize value of the shader changes the appearance of the vertices on screen. The problem I’m facing now is that it does work on Windows when Unity is running in DirectX mode, but not on any other platform that uses OpenGL. I tried the same Windows machine with -force-opengl, a mac, and an Android tablet. On each of these platforms the vertices are rendered as single pixel vertices, but the PointSize value does not have any influence!
Does anyone have any clues, why this is happening or an idea how to resolve this issue? I’m quite new to shaders in Unity, so I’ll appreciate any suggestions.
Best,
Stefan
Shader "Custom/PC2" {
//based on http://forum.unity3d.com/threads/176317-Point-Sprite-automatic-texture-coords
Properties {
_PointSize("PointSize", Float) = 1
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
Pass {
Cull Off ZWrite On Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma exclude_renderers flash
#pragma vertex vert
#pragma fragment frag
struct appdata {
float4 pos : POSITION;
fixed4 color : COLOR;
};
struct v2f {
float4 pos : SV_POSITION;
float size : PSIZE;
fixed4 color : COLOR;
};
float _PointSize;
v2f vert(appdata v){
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.pos);
o.size = _PointSize;
o.color = v.color;
return o;
}
half4 frag(v2f i) : COLOR0
{
return i.color;
}
ENDCG
}
}
}