float4x4 xViewProjection; float4x4 xWorld; float4x4 xView; float4x4 xProjection; float4 xWirelineColor; float3 xDiffuseDirection; float3 xCameraPos; struct VertexShaderInput { float4 Position : POSITION0; float3 Normal : NORMAL0; float2 TexCoord : TEXCOORD0; }; struct VertexShaderOutput { float4 Position: POSITION0; float4 Color : COLOR0; }; VertexShaderOutput VertexShaderFunction(float4 inPos : POSITION, float3 inNormal : NORMAL0) { const float ONE_MINUS_TWO_K_TIMES_ONE_OVER_TWO_EARTH_RADIUS_M = 6.675044E-08; VertexShaderOutput output; float4 modelSpacePos = inPos; float4 worldSpacePos = mul(inPos, xWorld); float deltaX = xCameraPos.x - worldSpacePos.x; float deltaZ = xCameraPos.z - worldSpacePos.z; //see the version from the app to see where this constant comes from float distanceSquared = (deltaX * deltaX) + (deltaZ * deltaZ); //world space corrected world upsidedown float correction = (distanceSquared * ONE_MINUS_TWO_K_TIMES_ONE_OVER_TWO_EARTH_RADIUS_M); modelSpacePos.y = modelSpacePos.y + correction; float4x4 worldViewProjection = mul(xWorld, xViewProjection); output.Position = mul(modelSpacePos, worldViewProjection); return output; } float4 PixelShaderFunction(VertexShaderOutput input) :COLOR0 { return input.Color; } technique technique0 { pass Pass0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } }