galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
R2DShader.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_RESOURCE_EMBEDDED_R2DSHADER_HPP_
9#define GALAXY_RESOURCE_EMBEDDED_R2DSHADER_HPP_
10
11namespace galaxy
12{
13 namespace resource
14 {
18 constexpr const auto r2d_vert_shader = R"(
19 #version 460 core
20
21 precision highp int;
22 precision highp float;
23
24 layout(location = 0) in vec2 l_pos;
25 layout(location = 1) in vec2 l_texels;
26
27 layout(std430, binding = 0) readonly buffer camera_data
28 {
29 mat4 u_camera_model_view;
30 mat4 u_camera_proj;
31 };
32
33 layout(std430, binding = 1) readonly buffer render_data
34 {
35 mat4 u_transform;
36 vec4 u_colour;
37 int u_entity;
38 bool u_point;
39 bool u_textured;
40 };
41
42 out vec2 io_texels;
43
44 void main()
45 {
46 gl_Position = u_camera_proj * u_camera_model_view * u_transform * vec4(l_pos, 0.0, 1.0);
47
48 io_texels = l_texels;
49 io_texels.y = 1.0 - io_texels.y;
50
51 if (u_point)
52 {
53 gl_PointSize = 4;
54 }
55 }
56 )";
57
61 constexpr const auto r2d_frag_shader = R"(
62 #version 460 core
63
64 precision highp int;
65 precision highp float;
66
67 layout(std430, binding = 0) readonly buffer camera_data
68 {
69 mat4 u_camera_model_view;
70 mat4 u_camera_proj;
71 };
72
73 layout(std430, binding = 1) readonly buffer render_data
74 {
75 mat4 u_transform;
76 vec4 u_colour;
77 int u_entity;
78 bool u_point;
79 bool u_textured;
80 };
81
82 in vec2 io_texels;
83
84 layout (location = 0) out vec4 io_frag_colour;
85 layout (location = 1) out int io_entity;
86
87 uniform sampler2D u_texture;
88
89 void main()
90 {
91 if (u_textured)
92 {
93 io_frag_colour = texture(u_texture, io_texels) * u_colour;
94 }
95 else
96 {
97 io_frag_colour = u_colour;
98 }
99
100 io_entity = u_entity;
101 }
102 )";
103 } // namespace resource
104} // namespace galaxy
105
106#endif
constexpr const auto r2d_frag_shader
Fragment shader for the 2d renderer.
Definition R2DShader.hpp:60
constexpr const auto r2d_vert_shader
Vertex shader for the 2d renderer.
Definition R2DShader.hpp:18
Timer.hpp galaxy.
Definition Async.hpp:17