Hello, I'm having some problems with a particles shader. I just would like to extend a quad relative to the uv mapping. So if the uv.v of the vertex is 0 no offset is added, if it's 1 then add an offset that I set externally. I actually achieved the result on a non particles mesh. But when I apply the shader to a particles seems like he coordinates space change. And actually I read that the vertex position in Particles is worldSpace. https://forum.unity.com/threads/particle-world-space-coords.82640/ So how can I achieve this on particle shader? This is done my vertex shader. Code (CSharp): float uvV = v.uv.y; //(x >= y) ? 1 : 0 //step(y,x) int isFarEdge = step(0.9, uvV); float zlerp = lerp(v.vertex.z _ZAdd, isFarEdge); v.vertex.z = zlerp ; o.vertex = UnityObjectToClipPos(v.vertex);
I actually missed a comma on that line. But the principle is the same, if isfaredge is 1 then z.lerp is zAdd otherwise zlerp is always v.vertex Am I wrong?
I just opened the scene with an old Unity version , and the result is correct. Something is changed in Unity 2017 but I can't understand what exactly.
Yeah something is still ocasionaly wrong with HLSL. Just last week it wouldn't let me use Code (CSharp): asuint( floatVar ) so I could check for NaN. Had to do some messy stuff like Code (CSharp): return floatVar == sqrt(-1); (Don't ask why NaN check was written the way it was. Error was thrown in a script that unity documentation pointed to)
So, because your particles are batched, you're lerping those verts from whatever position they are at to a fixed number... I assumed from you saying "offset" you wanted something like: Code (csharp): float zlerp = lerp(v.vertex.z, v.vertex.z + _ZAdd, isFarEdge);