- Home /
UnityPixelSnap in custom vertex shader behaves differently to implementation in default sprite shader.
I am trying to rewrite Unity's sprite shader to use normals, while still emulating the original light behavior of the built-in Sprites/Diffuse shader. Here is the relevant vertex program code:
vertexOutput vert (vertexInput input)
{
vertexOutput output;
output.pos = UnityObjectToClipPos(input.vertex);
#ifdef PIXELSNAP_ON
output.pos = UnityPixelSnap(output.pos);
#endif
return output;
}
This is concurrent with Unity's diffuse sprite shader implementation per the source code, but instead uses a surface shader. The issue is that my code doesn't behave identically to the diffuse shader, and still leaves some floating pixels that haven't been clamped to a grid. I have tried looking at the resulting shader code complied from the surface shader but can not find any difference between Pixel Snap and non Pixel Snap variants, which leads me to believe it is a preprocessor picking up the keyword and adding the relevant code. Any help would be appreciated, thanks.
Were you able to figure this out?? We have the same question!