Skip to content

Instantly share code, notes, and snippets.

@aardvarrk
Created November 23, 2012 17:39
Show Gist options
  • Select an option

  • Save aardvarrk/4136603 to your computer and use it in GitHub Desktop.

Select an option

Save aardvarrk/4136603 to your computer and use it in GitHub Desktop.
#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