Created
November 23, 2012 17:39
-
-
Save aardvarrk/4136603 to your computer and use it in GitHub Desktop.
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
| #version 330 | |
| layout(location = 0) in vec4 position; | |
| uniform vec3 offset; | |
| uniform float near; | |
| uniform float far; | |
| uniform float frustum_scale; | |
| void main() { | |
| vec4 camera_pos = position + vec4(offset.x, offset.y, offset.z, 0.0); | |
| vec4 clip_pos; | |
| clip_pos.xy = camera_pos.xy * frustum_scale; | |
| clip_pos.z = camera_pos.z * (near + far) / (near - far); | |
| clip_pos.z += 2 * near * far / (near - far); | |
| clip_pos.w = -camera_pos.z; | |
| gl_Position = clip_pos; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment