Brenta Engine 1.2
Loading...
Searching...
No Matches
particle_render_gs.c
1static const char* particle_render_gs = "#version 330 core\n"
2"\n"
3"layout (points) in;\n"
4"layout (triangle_strip, max_vertices = 4) out;\n"
5"\n"
6"in float drawOrDie[];\n"
7"\n"
8"uniform int atlas_width;\n"
9"uniform int atlas_height;\n"
10"uniform int atlas_index;\n"
11"uniform float scale = 1.0;\n"
12"uniform float aspect_ratio = 1.0;\n"
13"\n"
14"out vec2 TexCoordFrag;\n"
15"out float drawOrDieFrag;\n"
16"\n"
17"void main()\n"
18"{\n"
19" drawOrDieFrag = drawOrDie[0];\n"
20" float square_x = 1.0 / atlas_width;\n"
21" float square_y = 1.0 / atlas_height;\n"
22" int row_index = atlas_index / atlas_width;\n"
23" int col_index = atlas_index % atlas_width;\n"
24"\n"
25" float adjusted_scale_x = scale / (aspect_ratio < 1.0 ? aspect_ratio : 1.0);\n"
26" float adjusted_scale_y = scale / (aspect_ratio > 1.0 ? 1.0 / aspect_ratio : 1.0);\n"
27"\n"
28" gl_Position = gl_in[0].gl_Position + vec4(-1.0 * adjusted_scale_x,\n"
29" -1.0 * adjusted_scale_y, 0.0, 0.0);\n"
30" TexCoordFrag = vec2(square_x * col_index,\n"
31" square_y * (atlas_height - row_index - 1));\n"
32" EmitVertex();\n"
33" gl_Position = gl_in[0].gl_Position + vec4(1.0 * adjusted_scale_x,\n"
34" -1.0 * adjusted_scale_y, 0.0, 0.0);\n"
35" TexCoordFrag = vec2(square_x * (col_index + 1),\n"
36" square_y * (atlas_height - row_index - 1));\n"
37" EmitVertex();\n"
38" gl_Position = gl_in[0].gl_Position + vec4(-1.0 * adjusted_scale_x,\n"
39" 1.0 * adjusted_scale_y, 0.0, 0.0);\n"
40" TexCoordFrag = vec2(square_x * col_index,\n"
41" square_y * (atlas_height - row_index));\n"
42" EmitVertex();\n"
43" gl_Position = gl_in[0].gl_Position + vec4(1.0 * adjusted_scale_x,\n"
44" 1.0 * adjusted_scale_y, 0.0, 0.0);\n"
45" TexCoordFrag = vec2(square_x * (col_index + 1),\n"
46" square_y * (atlas_height - row_index));\n"
47" EmitVertex();\n"
48" EndPrimitive();\n"
49"}\n"
50;