I am trying to get this shader to work on particles but I think that since particles are screen space it does not work. I tried to replicate Particle World Space Coords? but without the C# part where I tried to manually compute Camera.cameraToWorldMatrix based on this page in the scripting docs, but I couldn’t get it to work. I am unable to use scripting since this is for a mod and not an actual game. Thanks.
Didn’t read the thread that I linked close enough. Figured out that particles do have the ability to use world space now, it is just that you must specify it in the Custom Vertex Streams area in the Render module. Here is a version of the unlit vertex shader that works w/ this method. Particle Custom Vertex Streams World Position Shader · GitHub
I’ll quote myself from the thread you linked to in your first post:
There’s nothing you need to do because they’re already in world space. The shader you posted doesn’t even use any data from Custom Vertex Streams, it’s just using the existing vertex positions, which are in world space, and snapping them to the closest grid position. If that works well enough for your use case, then great. Otherwise you are correct that you can get the world pivot position for each particle by using the vertex streams to store the pivot in the vertex texcoords. Alternatively you could use an instanced particle system shader which would allow the technique in the originally linked shader to work unmodified. Not that shader itself since it doesn’t have the code to handle particle instancing, but the use of the object to world matrix to get the pivot would actually work.