quakeforge/libs/video/renderer/vulkan/shader/fisheye.frag
Bill Currie 4cb120e878 [vulkan] Implement most of the changes for cube rendering
There are some missing parts from this commit as these are the fairly
clean changes. Missing is building a separate set of pipelines for the
new render pass (might be able to get away from that), OIT heads texture
is flat rather than an array, view matrices aren't set up, and the
fisheye renderer isn't hooked up to the output pass (code exists but is
messy). However, with the missing parts included, testing shows things
mostly working: the cube map is rendered correctly even though it's not
displayed correctly (incorrect view). This has definitely proven to be a
good test for Vulkan's multiview feature (very nice).
2023-02-14 13:24:47 +09:00

30 lines
729 B
GLSL

#version 450
#extension GL_GOOGLE_include_directive : enable
layout (set = 0, binding = 0) uniform
#include "matrices.h"
;
layout (set = 1, binding = 0) uniform samplerCube Input;
layout (push_constant) uniform PushConstants {
float fov;
float aspect;
};
layout (location = 0) in vec2 uv;
layout (location = 0) out vec4 frag_color;
void
main ()
{
// slight offset on y is to avoid the singularity straight ahead
vec2 xy = (2.0 * uv - vec2 (1, 1.00002)) * (vec2(1, -aspect));
float r = sqrt (dot (xy, xy));
vec2 cs = vec2 (cos (r * fov), sin (r * fov));
vec3 dir = vec3 (cs.y * xy / r, cs.x);
vec4 c = texture (Input, dir);
frag_color = c;// * 0.001 + vec4(dir, 1);
}