I’m rendering a point cloud using MeshTopology.Points. I wrote a simple vertex shader that can change the point size during play and that worked fine until Direct3D 11. I have to use D3D11 because I’m using the Rift DK2. Does anyone know the right shader code to make this work in Unity 4.5.5 and D3D11?
Point sprites aren’t supported on DX11 (or any other modern API for that matter). You have to create quads from points manually. There are several way how to do this on DX11. It was recently discussed here. This is the relevant part:
- Emit a quad for every vertex in geometry shader (textbook solution, not necessarily best/fastest)
- Create quads from points in tesselator
- HW Instancing
- The old fashion way. Works on every hw. Create 4 identical vertices with different uvs for every particle. You also have to store “offset vector” in second uv set for every vertex. That offset will tell you where to move that vertex in vertex shader so that all 4 vertices will form a quad. First vertex will move to lower left corner, second one to upper left corner of the quad etc. You will simply use something like this in vertex shader:
position += cameraRightVector * offset.x * particleSize; position += cameraUpVector * offset.y * particleSize;