/ chmod777_includes / shaders / html.vs.glsl
html.vs.glsl
 1  #version 420
 2  
 3  // file: html.vs.glsl
 4  
 5  /*
 6  Copyright (C) 2024 chmod777
 7  
 8  This program is free software: you can redistribute it and/or modify it under
 9  the terms of the GNU Affero General Public License version 3 as published by the
10  Free Software Foundation.
11  
12  This program is distributed in the hope that it will be useful, but WITHOUT ANY
13  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14  PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
15  
16  You should have received a copy of the GNU Affero General Public License along
17  with this program. If not, see <https://www.gnu.org/licenses/>. 
18  */
19  
20  // vertex data
21  layout (location = 0) in vec2 coords;
22  layout (location = 1) in vec2 uv;
23  
24  // instance data
25  layout (location = 2) in ivec4 flags;
26  layout (location = 3) in vec4 position_size;
27  
28  layout (location = 4) in vec4 background_color;
29  layout (location = 5) in ivec4 background_images;
30  
31  layout (location = 6) in vec4 border_widths;
32  layout (location = 7) in vec4 border_color;
33  
34  layout (location = 8) in vec4 image0_size_offset;
35  layout (location = 9) in vec4 image1_size_offset;
36  layout (location = 10) in vec4 image2_size_offset;
37  layout (location = 11) in vec4 image3_size_offset;
38  layout (location = 12) in ivec4 image0_origin_repeat_image1_origin_repeat;
39  layout (location = 13) in ivec4 image2_origin_repeat_image3_origin_repeat;
40  layout (location = 14) in ivec4 image_blend_modes;
41  
42  
43  
44  uniform vec2 viewGeometry;
45  uniform float uiScale;
46  
47  out DataVS {
48  	vec2 uv;
49  	vec4 flags;
50  	vec2 position;
51  	vec2 size;
52  	vec4 background_color;
53  	vec4 background_images;
54  	vec4 border_widths;
55  	vec4 border_color;
56  	vec4 image0_size_offset;
57  	vec2 image0_uv;
58  } vs_out;
59  
60  void main() {
61  	vec2 position = position_size.xy;
62  	vec2 size = position_size.zw;
63  
64  	vec2 image0_size = image0_size_offset.xy;
65  	vec2 image0_offset = image0_size_offset.zw;
66  	vec2 image0_uv = uv * size / image0_size;
67  
68  	int image0_repeat_mode = image0_origin_repeat_image1_origin_repeat.y;
69  	int image0_x_repeat_mode = image0_repeat_mode & 0xff;
70  	int image0_y_repeat_mode = (image0_repeat_mode >> 4) & 0xff;
71  
72  	vec2 coord = fma(coords, size, position) / viewGeometry;
73  	coord = fma(coord, vec2(2.0), vec2(-1.0));
74  
75  	gl_Position = vec4(coord, 0, 1);
76  
77  
78  	vs_out.uv = uv;
79  
80  	vs_out.flags = flags;
81  
82  	vs_out.position = position_size.xy;
83  	vs_out.size = position_size.zw;
84  
85  	vs_out.background_color = background_color;
86  	vs_out.background_images = background_images;
87  
88  	vs_out.border_widths = border_widths;
89  	vs_out.border_color = border_color;
90  
91  	vs_out.image0_size_offset = image0_size_offset;
92  	vs_out.image0_uv = image0_uv;
93  }