Shader issue with Shuriken

Ok , so i wrote a shader that adds a “bendy” effect to a object … issue is that it does not work properly with shrunken , when using billboarded shrunken the mesh just disassapers while a mesh type shuriken particle works just fine , let me know if you have any thoughts why it’s not working or any walkarounds

here is the CG program

CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma fragmentoption ARB_precision_hint_fastest
            #pragma multi_compile_particles


            #include "UnityCG.cginc"


            sampler2D _MainTex;
            fixed4 _TintColor;
            
            float _XBend;
            float _YBend;
            
            struct appdata_t {
                float4 vertex : POSITION;
                fixed4 color : COLOR;
                float2 texcoord : TEXCOORD0;
            } ;


            struct v2f {
                float4 vertex : POSITION;
                fixed4 color : COLOR;
                float2 texcoord : TEXCOORD0;
                #ifdef SOFTPARTICLES_ON
                float4 projPos : TEXCOORD1;
                #endif
            } ;
            
            float4 _MainTex_ST;
            
            v2f vert (appdata_t v)
            {
                v2f o;
                
                
                
                float4 pos = mul(_Object2World, v.vertex);
                  
                  if(pos.x - _WorldSpaceCameraPos.x < 11.0f)
                  {
                      float zDiff = pos.x - _WorldSpaceCameraPos.x;
                      float zDiffSquared = zDiff * zDiff;
                      float bendAmountX = zDiffSquared * _XBend;
                    float bendAmountY = zDiffSquared * _YBend;
                    
                      pos.z += bendAmountX;
                      pos.y += bendAmountY;
                  }
                  
                  float4 lPos = mul(_World2Object , pos);
                  
                  v.vertex = lPos;
                
                o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                
                #ifdef SOFTPARTICLES_ON
                o.projPos = ComputeScreenPos (o.vertex);
                COMPUTE_EYEDEPTH(o.projPos.z);
                #endif
                o.color = v.color;
                o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
                return o;
            }


            sampler2D _CameraDepthTexture;
            float _InvFade;
            
            fixed4 frag (v2f i) : COLOR
            {
                #ifdef SOFTPARTICLES_ON
                float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
                float partZ = i.projPos.z;
                float fade = saturate (_InvFade * (sceneZ-partZ));
                i.color.a *= fade;
                #endif
                
                return 2.0f * i.color * _TintColor * (tex2D(_MainTex, i.texcoord).a * i.color.a * 2.0f);
            }
            ENDCG

This part actually does the bending

    float4 pos = mul(_Object2World, v.vertex);
                  
                  if(pos.x - _WorldSpaceCameraPos.x < 11.0f)
                  {
                      float zDiff = pos.x - _WorldSpaceCameraPos.x;
                      float zDiffSquared = zDiff * zDiff;
                      float bendAmountX = zDiffSquared * _XBend;
                    float bendAmountY = zDiffSquared * _YBend;
                    
                      pos.z += bendAmountX;
                      pos.y += bendAmountY;
                  }
                  
                  float4 lPos = mul(_World2Object , pos);
                  
                  v.vertex = lPos;

This is what the shader does in game

1189028--46558--$ingamescreem.png

_Object2World won’t work with a particle system. The position is in camera space rather than object space. To get the world position of a particle, see here;

http://forum.unity3d.com/threads/82640-Particle-World-Space-Coords

Worked , thank you

Sorry to revive an old thread, but I’m pretty much doing the same thing and using this solution does not work :frowning: Did you have to do anything else to get particles to render properly?

Is using _World2Object after the transformations still okay?