#define NEAR_PLANE (0.01f) [[vk::binding(0, 1)]] cbuffer constants { float aspect_ratio; float fovy_degrees; float camera_x; float camera_y; float camera_distance; float camera_tilt; int2 drag_start; int2 mouse; uint map_width; }; float4x4 projection(float fovy, float aspect, float near) { float g = 1.0 / tan(fovy * 0.5); return { g / aspect, 0, 0, 0, 0, g, 0, 0, 0, 0, 0, near, 0, 0, 1, 0, }; } float4x4 view(float3 player_pos, float tilt, float camera_distance) { float s, c; sincos(-tilt, s, c); return float4x4( 1, 0, 0, -player_pos.x, 0, c, s, c * -player_pos.y, 0, -s, c, s * player_pos.y + camera_distance, 0, 0, 0, 1 ); }