How do I use PSIZE in a Unity 4.5.4 shader?

I’m told that Unity overhauled the shader compile system in version 4.5. I am unable to get any examples of a shader that sets the size of vertices to work in Unity 4.5.

I am trying to build a point cloud editor that will allow me to scale the visible point size as the user scales a model. I have seen several posts claiming this approach works but they are all a couple years old…

Here is the shader I have been trying:

Shader "Custom/VertexColor" {
    SubShader {
    Pass {
    	Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
        LOD 200
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"
        struct VertexInput {
            float4 v : POSITION;
            float4 color: COLOR;
        struct VertexOutput {
            float4 pos : SV_POSITION;
            float4 col : COLOR;
            float4 size : PSIZE;
        VertexOutput vert(VertexInput v) {
            VertexOutput o;
            o.pos = mul(UNITY_MATRIX_MVP, v.v);
            o.col = v.color;
            o.size = 10.0;
            return o;
        float4 frag(VertexOutput o) : COLOR {
            return o.col;

The only way I’ve been able to get PSIZE to work is by forcing OpenGL. There may be a workaround for Direct3D but this might get you started.

First, run Unity with OpenGL like so:

"C:\Program Files (x86)\Unity\Editor\Unity.exe" -force-opengl

Attach the following script to your main camera. This enables point size in OpenGL. ([Source][1])

using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class EnablePointSize : MonoBehaviour 
    const UInt32 GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642;
    const UInt32 GL_POINT_SMOOTH = 0x0B10;
    const string LibGLPath =
    "libGL";  // Untested on Linux, this may not be correct
    null;   // OpenGL ES platforms don't require this feature
    public static extern void glEnable(UInt32 cap);
    private bool mIsOpenGL;
    void Start()
        mIsOpenGL = SystemInfo.graphicsDeviceVersion.Contains("OpenGL");
    void OnPreRender()
        if (mIsOpenGL)

Attach the following script to a GameObject to create a point mesh. ([Source][2])

using UnityEngine;
using System.Collections;
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class PointCloud : MonoBehaviour {
    private Mesh mesh;
    int numPoints = 60000;
    // Use this for initialization
    void Start () {
        mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;
    void CreateMesh() {
        Vector3[] points = new Vector3[numPoints];
        int[] indecies = new int[numPoints];
        Color[] colors = new Color[numPoints];
        for(int i=0;i<points.Length;++i) {
            points *= new Vector3(Random.Range(-10,10), Random.Range (-10,10), Random.Range (-10,10));*

indecies = i;
colors = new Color(Random.Range(0.0f,1.0f),Random.Range (0.0f,1.0f),Random.Range(0.0f,1.0f),1.0f);

mesh.vertices = points;
mesh.colors = colors;
mesh.SetIndices(indecies, MeshTopology.Points,0);

Attach your shader using PSIZE to that game object as a Material.
Now you should have a point cloud.
*[2]: is for sale | HugeDomains