forge
Explore
Log in

Don't you dare go Hollow

Change custom-shader to a prelude-epilogue system

Browse files at this commit

1681ed16d91757d98dc3eb653b970e706ff84b78Ivan MolodetskikhParent: d4bed70
src/render_helpers/primary_gpu_pixel_shader_with_textures.rsmodified+2 -2
@@ -63,8 +63,8 @@ unsafe fn compile_program(
63 let vert_position = CStr::from_bytes_with_nul(b"vert_position\0").expect("NULL terminated");63 let vert_position = CStr::from_bytes_with_nul(b"vert_position\0").expect("NULL terminated");
64 let matrix = CStr::from_bytes_with_nul(b"matrix\0").expect("NULL terminated");64 let matrix = CStr::from_bytes_with_nul(b"matrix\0").expect("NULL terminated");
65 let tex_matrix = CStr::from_bytes_with_nul(b"tex_matrix\0").expect("NULL terminated");65 let tex_matrix = CStr::from_bytes_with_nul(b"tex_matrix\0").expect("NULL terminated");
66- let size = CStr::from_bytes_with_nul(b"size\0").expect("NULL terminated");66+ let size = CStr::from_bytes_with_nul(b"niri_size\0").expect("NULL terminated");
67- let alpha = CStr::from_bytes_with_nul(b"alpha\0").expect("NULL terminated");67+ let alpha = CStr::from_bytes_with_nul(b"niri_alpha\0").expect("NULL terminated");
68 68
69 Ok(PixelWithTexturesProgram(Rc::new(69 Ok(PixelWithTexturesProgram(Rc::new(
70 PixelWithTexturesProgramInner {70 PixelWithTexturesProgramInner {
src/render_helpers/resize.rsmodified+12 -13
@@ -74,10 +74,9 @@ impl ResizeRenderElement {
74 // Compute the transformation matrices.74 // Compute the transformation matrices.
75 let input_to_curr_geo = Mat3::from_scale(area_size / curr_geo_size)75 let input_to_curr_geo = Mat3::from_scale(area_size / curr_geo_size)
76 * Mat3::from_translation((area_loc - curr_geo_loc) / area_size);76 * Mat3::from_translation((area_loc - curr_geo_loc) / area_size);
77- let input_to_prev_geo = Mat3::from_scale(area_size / size_prev)77+
78- * Mat3::from_translation((area_loc - curr_geo_loc) / area_size);78+ let curr_geo_to_prev_geo = Mat3::from_scale(curr_geo_size / size_prev);
79- let input_to_next_geo = Mat3::from_scale(area_size / size_next)79+ let curr_geo_to_next_geo = Mat3::from_scale(curr_geo_size / size_next);
80- * Mat3::from_translation((area_loc - curr_geo_loc) / area_size);
81 80
82 let geo_to_tex_prev = Mat3::from_translation(-tex_prev_geo_loc / tex_prev_geo_size)81 let geo_to_tex_prev = Mat3::from_translation(-tex_prev_geo_loc / tex_prev_geo_size)
83 * Mat3::from_scale(size_prev / tex_prev_geo_size * scale);82 * Mat3::from_scale(size_prev / tex_prev_geo_size * scale);
@@ -99,21 +98,21 @@ impl ResizeRenderElement {
99 Self(PrimaryGpuPixelShaderWithTexturesRenderElement::new(98 Self(PrimaryGpuPixelShaderWithTexturesRenderElement::new(
100 shader,99 shader,
101 HashMap::from([100 HashMap::from([
102- (String::from("tex_prev"), texture_prev),101+ (String::from("niri_tex_prev"), texture_prev),
103- (String::from("tex_next"), texture_next),102+ (String::from("niri_tex_next"), texture_next),
104 ]),103 ]),
105 area,104 area,
106 size,105 size,
107 None,106 None,
108 result_alpha,107 result_alpha,
109 vec![108 vec![
110- make_uniform("input_to_curr_geo", input_to_curr_geo),109+ make_uniform("niri_input_to_curr_geo", input_to_curr_geo),
111- make_uniform("input_to_prev_geo", input_to_prev_geo),110+ make_uniform("niri_curr_geo_to_prev_geo", curr_geo_to_prev_geo),
112- make_uniform("input_to_next_geo", input_to_next_geo),111+ make_uniform("niri_curr_geo_to_next_geo", curr_geo_to_next_geo),
113- make_uniform("geo_to_tex_prev", geo_to_tex_prev),112+ make_uniform("niri_geo_to_tex_prev", geo_to_tex_prev),
114- make_uniform("geo_to_tex_next", geo_to_tex_next),113+ make_uniform("niri_geo_to_tex_next", geo_to_tex_next),
115- Uniform::new("progress", progress),114+ Uniform::new("niri_progress", progress),
116- Uniform::new("clamped_progress", clamped_progress),115+ Uniform::new("niri_clamped_progress", clamped_progress),
117 ],116 ],
118 Kind::Unspecified,117 Kind::Unspecified,
119 ))118 ))
src/render_helpers/shaders/mod.rsmodified+33 -33
@@ -1,6 +1,8 @@
1 use std::cell::RefCell;1 use std::cell::RefCell;
2 2
3-use smithay::backend::renderer::gles::{GlesPixelProgram, GlesRenderer, UniformName, UniformType};3+use smithay::backend::renderer::gles::{
4+ GlesError, GlesPixelProgram, GlesRenderer, UniformName, UniformType,
5+};
4 6
5 use super::primary_gpu_pixel_shader_with_textures::PixelWithTexturesProgram;7 use super::primary_gpu_pixel_shader_with_textures::PixelWithTexturesProgram;
6 use super::renderer::NiriRenderer;8 use super::renderer::NiriRenderer;
@@ -31,24 +33,11 @@ impl Shaders {
31 })33 })
32 .ok();34 .ok();
33 35
34- let resize = PixelWithTexturesProgram::compile(36+ let resize = compile_resize_program(renderer, include_str!("resize.frag"))
35- renderer,37+ .map_err(|err| {
36- include_str!("resize.frag"),38+ warn!("error compiling resize shader: {err:?}");
37- &[39+ })
38- UniformName::new("input_to_curr_geo", UniformType::Matrix3x3),40+ .ok();
39- UniformName::new("input_to_prev_geo", UniformType::Matrix3x3),
40- UniformName::new("input_to_next_geo", UniformType::Matrix3x3),
41- UniformName::new("geo_to_tex_prev", UniformType::Matrix3x3),
42- UniformName::new("geo_to_tex_next", UniformType::Matrix3x3),
43- UniformName::new("progress", UniformType::_1f),
44- UniformName::new("clamped_progress", UniformType::_1f),
45- ],
46- &["tex_prev", "tex_next"],
47- )
48- .map_err(|err| {
49- warn!("error compiling resize shader: {err:?}");
50- })
51- .ok();
52 41
53 Self {42 Self {
54 gradient_border,43 gradient_border,
@@ -87,22 +76,33 @@ pub fn init(renderer: &mut GlesRenderer) {
87 }76 }
88 }77 }
89 78
79+fn compile_resize_program(
80+ renderer: &mut GlesRenderer,
81+ src: &str,
82+) -> Result<PixelWithTexturesProgram, GlesError> {
83+ let mut program = include_str!("resize-prelude.frag").to_string();
84+ program.push_str(src);
85+ program.push_str(include_str!("resize-epilogue.frag"));
86+
87+ PixelWithTexturesProgram::compile(
88+ renderer,
89+ &program,
90+ &[
91+ UniformName::new("niri_input_to_curr_geo", UniformType::Matrix3x3),
92+ UniformName::new("niri_curr_geo_to_prev_geo", UniformType::Matrix3x3),
93+ UniformName::new("niri_curr_geo_to_next_geo", UniformType::Matrix3x3),
94+ UniformName::new("niri_geo_to_tex_prev", UniformType::Matrix3x3),
95+ UniformName::new("niri_geo_to_tex_next", UniformType::Matrix3x3),
96+ UniformName::new("niri_progress", UniformType::_1f),
97+ UniformName::new("niri_clamped_progress", UniformType::_1f),
98+ ],
99+ &["niri_tex_prev", "niri_tex_next"],
100+ )
101+}
102+
90 pub fn set_custom_resize_program(renderer: &mut GlesRenderer, src: Option<&str>) {103 pub fn set_custom_resize_program(renderer: &mut GlesRenderer, src: Option<&str>) {
91 let program = if let Some(src) = src {104 let program = if let Some(src) = src {
92- match PixelWithTexturesProgram::compile(105+ match compile_resize_program(renderer, src) {
93- renderer,
94- src,
95- &[
96- UniformName::new("input_to_curr_geo", UniformType::Matrix3x3),
97- UniformName::new("input_to_prev_geo", UniformType::Matrix3x3),
98- UniformName::new("input_to_next_geo", UniformType::Matrix3x3),
99- UniformName::new("geo_to_tex_prev", UniformType::Matrix3x3),
100- UniformName::new("geo_to_tex_next", UniformType::Matrix3x3),
101- UniformName::new("progress", UniformType::_1f),
102- UniformName::new("clamped_progress", UniformType::_1f),
103- ],
104- &["tex_prev", "tex_next"],
105- ) {
106 Ok(program) => Some(program),106 Ok(program) => Some(program),
107 Err(err) => {107 Err(err) => {
108 warn!("error compiling custom resize shader: {err:?}");108 warn!("error compiling custom resize shader: {err:?}");
src/render_helpers/shaders/resize-epilogue.fragadded+8 -0
@@ -0,0 +1,8 @@
1+void main() {
2+ vec3 coords_curr_geo = niri_input_to_curr_geo * vec3(niri_v_coords, 1.0);
3+ vec3 size_curr_geo = niri_input_to_curr_geo * vec3(niri_size, 1.0);
4+
5+ vec4 color = resize_color(coords_curr_geo, size_curr_geo);
6+
7+ gl_FragColor = color * niri_alpha;
8+}
src/render_helpers/shaders/resize-prelude.fragadded+21 -0
@@ -0,0 +1,21 @@
1+#version 100
2+
3+precision mediump float;
4+
5+varying vec2 niri_v_coords;
6+uniform vec2 niri_size;
7+
8+uniform mat3 niri_input_to_curr_geo;
9+uniform mat3 niri_curr_geo_to_prev_geo;
10+uniform mat3 niri_curr_geo_to_next_geo;
11+
12+uniform sampler2D niri_tex_prev;
13+uniform mat3 niri_geo_to_tex_prev;
14+
15+uniform sampler2D niri_tex_next;
16+uniform mat3 niri_geo_to_tex_next;
17+
18+uniform float niri_progress;
19+uniform float niri_clamped_progress;
20+
21+uniform float niri_alpha;
src/render_helpers/shaders/resize.fragmodified+6 -37
@@ -1,41 +1,10 @@
1-#version 1001+vec4 resize_color(vec3 coords_curr_geo, vec3 size_curr_geo) {
2+ vec3 coords_tex_prev = niri_geo_to_tex_prev * coords_curr_geo;
3+ vec4 color_prev = texture2D(niri_tex_prev, coords_tex_prev.st);
2 4
3-precision mediump float;5+ vec3 coords_tex_next = niri_geo_to_tex_next * coords_curr_geo;
6+ vec4 color_next = texture2D(niri_tex_next, coords_tex_next.st);
4 7
5-varying vec2 v_coords;8+ vec4 color = mix(color_prev, color_next, niri_clamped_progress);
6-uniform vec2 size;
7-
8-uniform mat3 input_to_curr_geo;
9-uniform mat3 input_to_prev_geo;
10-uniform mat3 input_to_next_geo;
11-
12-uniform sampler2D tex_prev;
13-uniform mat3 geo_to_tex_prev;
14-
15-uniform sampler2D tex_next;
16-uniform mat3 geo_to_tex_next;
17-
18-uniform float progress;
19-uniform float clamped_progress;
20-
21-uniform float alpha;
22-
23-vec4 crossfade() {
24- vec3 coords_curr_geo = input_to_curr_geo * vec3(v_coords, 1.0);
25-
26- vec3 coords_tex_prev = geo_to_tex_prev * coords_curr_geo;
27- vec4 color_prev = texture2D(tex_prev, vec2(coords_tex_prev));
28-
29- vec3 coords_tex_next = geo_to_tex_next * coords_curr_geo;
30- vec4 color_next = texture2D(tex_next, vec2(coords_tex_next));
31-
32- vec4 color = mix(color_prev, color_next, clamped_progress);
33 return color;9 return color;
34 }10 }
35-
36-void main() {
37- vec4 color = crossfade();
38-
39- gl_FragColor = color * alpha;
40-}
41-
src/render_helpers/shaders/texture.vertmodified+2 -2
@@ -6,7 +6,7 @@ uniform mat3 tex_matrix;
6 attribute vec2 vert;6 attribute vec2 vert;
7 attribute vec4 vert_position;7 attribute vec4 vert_position;
8 8
9-varying vec2 v_coords;9+varying vec2 niri_v_coords;
10 10
11 mat2 scale(vec2 scale_vec){11 mat2 scale(vec2 scale_vec){
12 return mat2(12 return mat2(
@@ -19,7 +19,7 @@ void main() {
19 vec2 vert_transform_translation = vert_position.xy;19 vec2 vert_transform_translation = vert_position.xy;
20 vec2 vert_transform_scale = vert_position.zw;20 vec2 vert_transform_scale = vert_position.zw;
21 vec3 position = vec3(vert * scale(vert_transform_scale) + vert_transform_translation, 1.0);21 vec3 position = vec3(vert * scale(vert_transform_scale) + vert_transform_translation, 1.0);
22- v_coords = (tex_matrix * position).xy;22+ niri_v_coords = (tex_matrix * position).xy;
23 gl_Position = vec4(matrix * position, 1.0);23 gl_Position = vec4(matrix * position, 1.0);
24 }24 }
25 25
wiki/Configuration:-Animations.mdmodified+7 -15
@@ -234,31 +234,23 @@ See [this example shader](./examples/resize-custom-shader.frag) for a full docum
234 234
235 If a custom shader fails to compile, niri will print a warning and fall back to the default, or previous successfully compiled shader.235 If a custom shader fails to compile, niri will print a warning and fall back to the default, or previous successfully compiled shader.
236 236
237-> [!NOTE]237+> [!WARNING]
238 > 238 >
239 > Custom shaders do not have a backwards compatibility guarantee.239 > Custom shaders do not have a backwards compatibility guarantee.
240 > I may need to change their interface as I'm developing new features.240 > I may need to change their interface as I'm developing new features.
241 241
242+Example: resize will show the next (after resize) window texture right away, stretched to the current geometry.
243+
242 ```244 ```
243 animations {245 animations {
244 window-resize {246 window-resize {
245 spring damping-ratio=1.0 stiffness=800 epsilon=0.0001247 spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
246 248
247 custom-shader r"249 custom-shader r"
248- #version 100250+ vec4 resize_color(vec3 coords_curr_geo, vec3 size_curr_geo) {
249- precision mediump float;251+ vec3 coords_tex_next = niri_geo_to_tex_next * coords_curr_geo;
250-252+ vec4 color = texture2D(niri_tex_next, coords_tex_next.st);
251- varying vec2 v_coords;253+ return color;
252- uniform mat3 input_to_curr_geo;
253- uniform sampler2D tex_next;
254- uniform mat3 geo_to_tex_next;
255- uniform float alpha;
256-
257- void main() {
258- vec3 coords_curr_geo = input_to_curr_geo * vec3(v_coords, 1.0);
259- vec3 coords_tex_next = geo_to_tex_next * coords_curr_geo;
260- vec4 color = texture2D(tex_next, vec2(coords_tex_next));
261- gl_FragColor = color * alpha;
262 }254 }
263 "255 "
264 }256 }
wiki/examples/resize-custom-shader.fragmodified+70 -59
@@ -1,72 +1,87 @@
1-#version 1001+// Your shader must contain one function (see the bottom of this file).
2-
3-precision mediump float;
4-
5-// Coordinates of the current pixel.
6 //2 //
7-// These range from 0 to 1 over the whole area of the shader. The location and3+// It should not contain any uniform definitions or anything else, as niri
8-// the size of the area are unspecified, but niri will make it large enough to4+// provides them for you.
9-// accomodate a crossfade.
10 //5 //
11-// You very likely want to convert these coordinates to geometry coordinates6+// All symbols defined by niri will have a niri_ prefix, so don't use it for
12-// before using them (see below).7+// your own variables and functions.
13-varying vec2 v_coords;
14 8
15-// Pixel size of the whole area of the shader.9+// The function that you must define looks like this:
16-uniform vec2 size;10+vec4 resize_color(vec3 coords_curr_geo, vec3 size_curr_geo) {
11+ vec4 color = /* ...compute the color... */;
12+ return color;
13+}
17 14
18-// Matrix that converts the input v_coords into coordinates inside the current15+// It takes as input:
16+//
17+// * coords_curr_geo: coordinates of the current pixel relative to the current
19 // window geometry.18 // window geometry.
20 //19 //
20+// These are homogeneous (the Z component is equal to 1) and scaled in such a
21+// way that the 0 to 1 coordinates lie within the current window geometry (in
22+// the middle of a resize). Pixels outside the window geometry will have
23+// coordinates below 0 or above 1.
24+//
21 // The window geometry is its "visible bounds" from the user's perspective.25 // The window geometry is its "visible bounds" from the user's perspective.
22-// After applying this matrix, the 0 to 1 coordinate range will correspond to26+//
23-// the current geometry (in the middle of a resize), and pixels outside the27+// The shader runs over an area of unspecified size and location, so you must
24-// geometry will have coordinates below 0 or above 1.28+// expect and handle coordinates outside the [0, 1] range. The area will be
25-uniform mat3 input_to_curr_geo;29+// large enough to accomodate a crossfade effect.
26-30+//
27-// Matrix that converts the input v_coords into coordinates inside the previous31+// * size_curr_geo: size of the current window geometry in physical pixels.
28-// (before resize) window geometry.32+//
29-uniform mat3 input_to_prev_geo;33+// It is homogeneous (the Z component is equal to 1).
34+//
35+// The function must return the color of the pixel (with premultiplied alpha).
36+// The pixel color will be further processed by niri (for example, to apply the
37+// final opacity from window rules).
30 38
31-// Matrix that converts the input v_coords into coordinates inside the next39+// Now let's go over the uniforms that niri defines.
32-// (after resize) window geometry.
33-uniform mat3 input_to_next_geo;
34 40
35 // Previous (before resize) window texture.41 // Previous (before resize) window texture.
36-uniform sampler2D tex_prev;42+uniform sampler2D niri_tex_prev;
37 43
38 // Matrix that converts geometry coordinates into the previous window texture44 // Matrix that converts geometry coordinates into the previous window texture
39 // coordinates.45 // coordinates.
40 //46 //
41 // The window texture can and will go outside the geometry (for client-side47 // The window texture can and will go outside the geometry (for client-side
42 // decoration shadows for example), which is why this matrix is necessary.48 // decoration shadows for example), which is why this matrix is necessary.
43-uniform mat3 geo_to_tex_prev;49+uniform mat3 niri_geo_to_tex_prev;
44 50
45 // Next (after resize) window texture.51 // Next (after resize) window texture.
46-uniform sampler2D tex_next;52+uniform sampler2D niri_tex_next;
47 53
48 // Matrix that converts geometry coordinates into the next window texture54 // Matrix that converts geometry coordinates into the next window texture
49 // coordinates.55 // coordinates.
50-uniform mat3 geo_to_tex_next;56+uniform mat3 niri_geo_to_tex_next;
57+
58+
59+// Matrix that converts coords_curr_geo into coordinates inside the previous
60+// (before resize) window geometry.
61+uniform mat3 niri_curr_geo_to_prev_geo;
62+
63+// Matrix that converts coords_curr_geo into coordinates inside the next
64+// (after resize) window geometry.
65+uniform mat3 niri_curr_geo_to_next_geo;
66+
51 67
52 // Unclamped progress of the resize.68 // Unclamped progress of the resize.
53 //69 //
54 // Goes from 0 to 1 but may overshoot and oscillate.70 // Goes from 0 to 1 but may overshoot and oscillate.
55-uniform float progress;71+uniform float niri_progress;
56 72
57 // Clamped progress of the resize.73 // Clamped progress of the resize.
58 //74 //
59 // Goes from 0 to 1, but will stop at 1 as soon as it first reaches 1. Will not75 // Goes from 0 to 1, but will stop at 1 as soon as it first reaches 1. Will not
60 // overshoot or oscillate.76 // overshoot or oscillate.
61-uniform float clamped_progress;77+uniform float niri_clamped_progress;
62 78
63-// Additional opacity to apply to the final color.79+// Now let's look at some examples. You can copy everything below this line
64-uniform float alpha;80+// into your custom-shader to experiment.
65 81
66 // Example: fill the current geometry with a solid vertical gradient.82 // Example: fill the current geometry with a solid vertical gradient.
67-vec4 solid_gradient() {83+vec4 solid_gradient(vec3 coords_curr_geo, vec3 size_curr_geo) {
68- vec3 coords = input_to_curr_geo * vec3(v_coords, 1.0);84+ vec3 coords = coords_curr_geo;
69-
70 vec4 color = vec4(0.0);85 vec4 color = vec4(0.0);
71 86
72 // Paint only the area inside the current geometry.87 // Paint only the area inside the current geometry.
@@ -83,35 +98,33 @@ vec4 solid_gradient() {
83 98
84 // Example: crossfade between previous and next texture, stretched to the99 // Example: crossfade between previous and next texture, stretched to the
85 // current geometry.100 // current geometry.
86-vec4 crossfade() {101+vec4 crossfade(vec3 coords_curr_geo, vec3 size_curr_geo) {
87- vec3 coords_curr_geo = input_to_curr_geo * vec3(v_coords, 1.0);102+ // Convert coordinates into the texture space for sampling.
103+ vec3 coords_tex_prev = niri_geo_to_tex_prev * coords_curr_geo;
104+ vec4 color_prev = texture2D(niri_tex_prev, coords_tex_prev.st);
88 105
89- vec3 coords_tex_prev = geo_to_tex_prev * coords_curr_geo;106+ // Convert coordinates into the texture space for sampling.
90- vec4 color_prev = texture2D(tex_prev, vec2(coords_tex_prev));107+ vec3 coords_tex_next = niri_geo_to_tex_next * coords_curr_geo;
108+ vec4 color_next = texture2D(niri_tex_next, coords_tex_next.st);
91 109
92- vec3 coords_tex_next = geo_to_tex_next * coords_curr_geo;110+ vec4 color = mix(color_prev, color_next, niri_clamped_progress);
93- vec4 color_next = texture2D(tex_next, vec2(coords_tex_next));
94-
95- vec4 color = mix(color_prev, color_next, clamped_progress);
96 return color;111 return color;
97 }112 }
98 113
99 // Example: next texture, stretched to the current geometry.114 // Example: next texture, stretched to the current geometry.
100-vec4 stretch_next() {115+vec4 stretch_next(vec3 coords_curr_geo, vec3 size_curr_geo) {
101- vec3 coords_curr_geo = input_to_curr_geo * vec3(v_coords, 1.0);116+ vec3 coords_tex_next = niri_geo_to_tex_next * coords_curr_geo;
102- vec3 coords_tex_next = geo_to_tex_next * coords_curr_geo;117+ vec4 color = texture2D(niri_tex_next, coords_tex_next.st);
103- vec4 color = texture2D(tex_next, vec2(coords_tex_next));
104 return color;118 return color;
105 }119 }
106 120
107 // Example: next texture, stretched to the current geometry if smaller, and121 // Example: next texture, stretched to the current geometry if smaller, and
108 // cropped if bigger.122 // cropped if bigger.
109-vec4 stretch_or_crop_next() {123+vec4 stretch_or_crop_next(vec3 coords_curr_geo, vec3 size_curr_geo) {
110- vec3 coords_curr_geo = input_to_curr_geo * vec3(v_coords, 1.0);124+ vec3 coords_next_geo = niri_curr_geo_to_next_geo * coords_curr_geo;
111- vec3 coords_next_geo = input_to_next_geo * vec3(v_coords, 1.0);
112 125
113- vec3 coords_stretch = geo_to_tex_next * coords_curr_geo;126+ vec3 coords_stretch = niri_geo_to_tex_next * coords_curr_geo;
114- vec3 coords_crop = geo_to_tex_next * coords_next_geo;127+ vec3 coords_crop = niri_geo_to_tex_next * coords_next_geo;
115 128
116 // If the crop coord is smaller than the stretch coord, then the next129 // If the crop coord is smaller than the stretch coord, then the next
117 // texture size is bigger than the current geometry, which means that we130 // texture size is bigger than the current geometry, which means that we
@@ -122,7 +135,7 @@ vec4 stretch_or_crop_next() {
122 if (coords_crop.y < coords_stretch.y)135 if (coords_crop.y < coords_stretch.y)
123 coords.y = coords_crop.y;136 coords.y = coords_crop.y;
124 137
125- vec4 color = texture2D(tex_next, vec2(coords));138+ vec4 color = texture2D(niri_tex_next, coords.st);
126 139
127 // However, when we crop, we also want to crop out anything outside the140 // However, when we crop, we also want to crop out anything outside the
128 // current geometry. This is because the area of the shader is unspecified141 // current geometry. This is because the area of the shader is unspecified
@@ -142,11 +155,9 @@ vec4 stretch_or_crop_next() {
142 return color;155 return color;
143 }156 }
144 157
145-// The main entry point of the shader.158+// This is the function that you must define.
146-void main() {159+vec4 resize_color(vec3 coords_curr_geo, vec3 size_curr_geo) {
147 // You can pick one of the example functions or write your own.160 // You can pick one of the example functions or write your own.
148- vec4 color = stretch_or_crop_next();161+ return stretch_or_crop_next(coords_curr_geo, size_curr_geo);
149-
150- gl_FragColor = color * alpha;
151 }162 }
152 163