I'm re-visiting my moon lander game on Android, as I came up with an idea for the terrain which performs really nicely on my basic tablet. But, I do have a weird problem with my terrain shader.
The terrain itself is a square quadtree, centred on (0, 0, 0), stretching into the XZ plane with a side length of 5000. In game, I prefer to see a circle of terrain rather than a square slab, so I do a simple radial clip in my shader:
float distanceFromCentre = length(float2(input.PositionWorld.x, input.PositionWorld.z));
clip(distanceFromCentre > 2500 ? -1 : 1);
...in Windows, this produces the intended effect (I've also added a fade to black around the rim):
...however when I compile and run the same shader for Android, far too much of the terrain is clipped:
I know it's not a problem with the clip function because when I choose a simpler condition, it works. For example, when I do this:
clip(input.PositionWorld.x > 0 && input.PositionWorld.z > 0 ? -1 : 1);
...I get a quadrant missing in the correct place, while the rest shows up:
So it must be something to do with the line where
distanceFromCentre is calculated. I tried just doing a
sqrt(x*x + z*z) instead of using
length() but I get the same incorrect result! Can anyone throw me a bone here?
..oh and while I'm here, how do I get anti-aliasing working in Android? I have set
PreferMultiSampling = true which works for Windows, but not on my tablet.