Eye space vertex manipulation in surface shader

Hi,

Short Form Question: Can the vertex:VertexFunction modifier specified for a surface shader only modify vertices in model space?

Longer Form Question: I currently have a vertex/fragment shader that does some vertex manipulation in eye/view space in the vertex program, something like this:

v2f vert (appdata_base v)
 {
     v2f output;

     // Transform model coords to viewspace coords
     float4 pos = mul(UNITY_MATRIX_MV, v.vertex);

     // Do some stuff with pos in viewspace
     ...

     // Project from viewspace to clip coords for the fragment shader
     o.pos = mul(UNITY_MATRIX_P, pos);
 
     return o;
 }

I’m now trying to convert this into a surface shader so that I get all the lovely goodness from automatic lighting calculations etc.

I initially thought I’d be able to do this by moving the code above into a vertex modifier. However, looking at the docs more carefully, “…it is possible to use a “vertex modifier” function that will modify incoming vertex data in the vertex shader…” so, if I understand the pipeline correctly, the vertex values in the Input structure of the vertex modifier are supplied (and must be returned) in model space, right? Because it’s a sort of vertex preprocessor whose output is then fed into the “real” vertex shader created based on the surf() function?

So, although I can access UNITY_MATRIX_MV in the modifier function in order to perform the calculations, it’s of no use because there’s no way to convert the output back to model space coordinates to pass onto to the vertex function. In which case, is there any other way I can do vertex modification in viewspace in a surface shader? (other than by letting Unity compile and create the various vertex/fragment shaders from the surface shader and then inserting it into each variant manually), or do I have to stick with my current vertex/fragment and just manually add all the PITA lighting stuff myself?

Hope that makes sense, and thankyou for any advice!

I guess if you were willing/able to calculate the inverse view matrix in code and upload it to the shader you could multiply by that and then _World2Object?