Skip to content

Commit 2f6d866

Browse files
authored
rounded border: remove dead code in shader (#12602)
# Objective - #12500 added dead code to the ui shader ## Solution - Remove it
1 parent 93c17d1 commit 2f6d866

File tree

1 file changed

+0
-141
lines changed

1 file changed

+0
-141
lines changed

crates/bevy_ui/src/render/ui.wgsl

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ fn vertex(
6262
@group(1) @binding(0) var sprite_texture: texture_2d<f32>;
6363
@group(1) @binding(1) var sprite_sampler: sampler;
6464

65-
fn sigmoid(t: f32) -> f32 {
66-
return 1.0 / (1.0 + exp(-t));
67-
}
68-
6965
// The returned value is the shortest distance from the given point to the boundary of the rounded
7066
// box.
7167
//
@@ -124,143 +120,6 @@ fn sd_inset_rounded_box(point: vec2<f32>, size: vec2<f32>, radius: vec4<f32>, in
124120
return sd_rounded_box(inner_point, inner_size, r);
125121
}
126122

127-
#ifdef CLAMP_INNER_CURVES
128-
fn sd_inset_rounded_box(point: vec2<f32>, size: vec2<f32>, radius: vec4<f32>, inset: vec4<f32>) -> f32 {
129-
let inner_size = size - inset.xy - inset.zw;
130-
let inner_center = inset.xy + 0.5 * inner_size - 0.5 * size;
131-
let inner_point = point - inner_center;
132-
133-
var r = radius;
134-
135-
if 0. < min(inset.x, inset.y) || inset.x + inset.y <= 0. {
136-
// Top left corner.
137-
r.x = r.x - max(inset.x, inset.y);
138-
} else {
139-
r.x = 0.;
140-
}
141-
142-
if 0. < min(inset.z, inset.y) || inset.z + inset.y <= 0. {
143-
// Top right corner.
144-
r.y = r.y - max(inset.z, inset.y);
145-
} else {
146-
r.y = 0.;
147-
}
148-
149-
if 0. < min(inset.z, inset.w) || inset.z + inset.w <= 0. {
150-
// Bottom right corner.
151-
r.z = r.z - max(inset.z, inset.w);
152-
} else {
153-
r.z = 0.;
154-
}
155-
156-
if 0. < min(inset.x, inset.w) || inset.x + inset.w <= 0. {
157-
// Bottom left corner.
158-
r.w = r.w - max(inset.x, inset.w);
159-
} else {
160-
r.w = 0.;
161-
}
162-
163-
let half_size = inner_size * 0.5;
164-
let min = min(half_size.x, half_size.y);
165-
166-
r = min(max(r, vec4<f32>(0.0)), vec4<f32>(min));
167-
168-
return sd_rounded_box(inner_point, inner_size, r);
169-
}
170-
#endif
171-
172-
const RED: vec4<f32> = vec4<f32>(1., 0., 0., 1.);
173-
const GREEN: vec4<f32> = vec4<f32>(0., 1., 0., 1.);
174-
const BLUE: vec4<f32> = vec4<f32>(0., 0., 1., 1.);
175-
const WHITE = vec4<f32>(1., 1., 1., 1.);
176-
const BLACK = vec4<f32>(0., 0., 0., 1.);
177-
178-
// Draw the border in white, rest of the rect black.
179-
fn draw_border(in: VertexOutput) -> vec4<f32> {
180-
// Distance from external border. Positive values outside.
181-
let external_distance = sd_rounded_box(in.point, in.size, in.radius);
182-
183-
// Distance from internal border. Positive values inside.
184-
let internal_distance = sd_inset_rounded_box(in.point, in.size, in.radius, in.border);
185-
186-
// Distance from border, positive values inside border.
187-
let border = max(-internal_distance, external_distance);
188-
189-
if border < 0.0 {
190-
return WHITE;
191-
} else {
192-
return BLACK;
193-
}
194-
}
195-
196-
// Draw just the interior in white, rest of the rect black.
197-
fn draw_interior(in: VertexOutput) -> vec4<f32> {
198-
// Distance from external border. Positive values outside.
199-
let external_distance = sd_rounded_box(in.point, in.size, in.radius);
200-
201-
if external_distance < 0.0 {
202-
return WHITE;
203-
} else {
204-
return BLACK;
205-
}
206-
}
207-
208-
// Draw all the geometry.
209-
fn draw_test(in: VertexOutput) -> vec4<f32> {
210-
// Distance from external border. Negative inside
211-
let external_distance = sd_rounded_box(in.point, in.size, in.radius);
212-
213-
// Distance from internal border.
214-
let internal_distance = sd_inset_rounded_box(in.point, in.size, in.radius, in.border);
215-
216-
// Distance from border.
217-
let border = max(-internal_distance, external_distance);
218-
219-
// Draw the area outside the border in green.
220-
if 0.0 < external_distance {
221-
return GREEN;
222-
}
223-
224-
// Draw the area inside the border in white.
225-
if border < 0.0 {
226-
return WHITE;
227-
}
228-
229-
// Draw the interior in blue.
230-
if internal_distance < 0.0 {
231-
return BLUE;
232-
}
233-
234-
// Fill anything else with red (the presence of any red is a bug).
235-
return RED;
236-
}
237-
238-
fn draw_no_aa(in: VertexOutput) -> vec4<f32> {
239-
let texture_color = textureSample(sprite_texture, sprite_sampler, in.uv);
240-
let color = select(in.color, in.color * texture_color, enabled(in.flags, TEXTURED));
241-
242-
// Negative value => point inside external border.
243-
let external_distance = sd_rounded_box(in.point, in.size, in.radius);
244-
// Negative value => point inside internal border.
245-
let internal_distance = sd_inset_rounded_box(in.point, in.size, in.radius, in.border);
246-
// Negative value => point inside border.
247-
let border = max(external_distance, -internal_distance);
248-
249-
if enabled(in.flags, BORDER) {
250-
if border < 0.0 {
251-
return color;
252-
} else {
253-
return vec4(0.0);
254-
}
255-
}
256-
257-
if external_distance < 0.0 {
258-
return color;
259-
}
260-
261-
return vec4(0.0);
262-
}
263-
264123
fn draw(in: VertexOutput) -> vec4<f32> {
265124
let texture_color = textureSample(sprite_texture, sprite_sampler, in.uv);
266125

0 commit comments

Comments
 (0)