- Home /
How do you change Point Size in Direct3d 11 shader?
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?
Is this something that's changed with Unity or the way Direct3D / HLSL works?
Answer by Michal_ · Jan 31, 2016 at 02:37 PM
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;
Your answer
Follow this Question
Related Questions
How can I get correct lighting on a low poly water shader? 1 Answer
Shader - Object Depth 0 Answers
Why color not rendering in my shader? 0 Answers