Skip to content

Instantly share code, notes, and snippets.

@yorung
Created August 21, 2015 11:47
Show Gist options
  • Save yorung/9c7f8184d886f9a76ad2 to your computer and use it in GitHub Desktop.
Save yorung/9c7f8184d886f9a76ad2 to your computer and use it in GitHub Desktop.
Stereographic projection(Little Planet)
float4 mainPS(VsToPs inp) : SV_Target
{
float2 scale = float2(4.0f / 3.0f, 1) * 3; // scale & aspect ratio
float2 plane = inp.screenPos.xy * scale;
float3 dir = float3(plane.x * 2, plane.y * 2, -1 + dot(plane, plane)) / (1 + dot(plane, plane));
return texCube.Sample(samplerState, dir.xzy); // y is upper
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment