You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB

#version 450
// This file contains the raw math performed by the matrices in vert.vert
// Matrices are still used for rotation, though.
layout(std430, set = 0, binding = 0) buffer positions_buffer {
mat2x4 posnrm[];
} pos;
layout(push_constant, std430) uniform pc {
layout(offset=0) mat4 data;
layout(offset=64) vec4 offst;
};
layout (location = 0) out vec4 normal;
layout (location = 1) out vec4 pos_pre;
layout (location = 2) out vec4 pos_post;
const float PI = 3.14159;
const float TAU = PI*2.0;
void main() {
normal = pos.posnrm[gl_VertexIndex][1];
pos_pre = pos.posnrm[gl_VertexIndex][0];
float zFar = 100.0;
float zNear = 0.1;
vec3 cam_orig = offst.xyz;
vec2 cam_rot = vec2(data[3].w, offst.w);
gl_Position = pos.posnrm[gl_VertexIndex][0];
gl_Position.xyz += cam_orig;
pos_post = gl_Position;
mat2 xz_rot;
xz_rot[0] = vec2(cos(cam_rot.y), -sin(cam_rot.y));
xz_rot[1] = vec2(sin(cam_rot.y), cos(cam_rot.y));
gl_Position.xz *= inverse(xz_rot);
mat2 yz_rot;
yz_rot[0] = vec2(cos(cam_rot.x), -sin(cam_rot.x));
yz_rot[1] = vec2(sin(cam_rot.x), cos(cam_rot.x));
gl_Position.yz *= inverse(yz_rot);
gl_Position.x *= (1080.0/1920.0);
gl_Position.w = (gl_Position.z*sin(140.0/360.0*TAU));
gl_Position.z -= zNear;
gl_Position.z /= zFar;
}