10layout(set = 0, binding = 0) uniform GLOBALS {
15layout(location = 1) out vec3 near_point;
16layout(location = 2) out vec3 far_point;
18vec3 grid_plane[6] = vec3[](
19 vec3(1, 1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0),
20 vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0)
23vec3 UnprojectPoint(float x, float y, float z, mat4 view, mat4 projection) {
24 mat4 view_inv = inverse(view);
25 mat4 proj_inv = inverse(projection);
27 vec4 unprojected_point = view_inv * proj_inv * vec4(x, y, z, 1.0);
29 return unprojected_point.xyz / unprojected_point.w;
33 vec3 p = grid_plane[gl_VertexIndex].xyz;
34 near_point = UnprojectPoint(p.x, p.y, 0.0, globals.view, globals.proj).xyz;
35 far_point = UnprojectPoint(p.x, p.y, 1.0, globals.view, globals.proj).xyz;
37 gl_Position = vec4(p, 1.0);
44layout(location = 0) out vec4 out_colour;
46layout(location = 1) in vec3 near_point;
47layout(location = 2) in vec3 far_point;
50 float t = -near_point.y / (far_point.y - near_point.y);
51 // out_colour = vec4(1.0, 0.0, 0.0, 1.0 * float(t > 0));
52 out_colour = vec4(1.0, 0.0, 0.0, t);
Definition editor_scene.hpp:5
const std::string_view kEditorFragShader
Definition editor_scene.hpp:41
const std::string_view kEditorVertShader
Definition editor_scene.hpp:7