Created
August 21, 2015 11:56
-
-
Save yorung/62f69d3e5260a3bffeb1 to your computer and use it in GitHub Desktop.
A Stereographic Projection example using a Photo Sphere as source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)); | |
| dir = dir.xzy; // y is upper | |
| float longitude = atan2(dir.x, dir.z) * (180 / 3.14159265f); | |
| float latitude = asin(dir.y) * (180 / 3.14159265f); | |
| return gTexture.Sample(samplerState, float2(longitude, latitude) / float2(360, -180) + 0.5); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment