圆角矩形抗锯齿
This commit is contained in:
parent
ffcdc3b9f5
commit
8d1bb03372
@ -89,7 +89,7 @@ void dx_window::begin_frame() {
|
||||
context.draw_rectangle({ 400, 0 }, { 100, 100 }, { 0, 1, 0, 1 });
|
||||
auto radius = abs(sin(get_total_time().count())) * 50;
|
||||
auto angle = sin(get_total_time().count()) * 45;
|
||||
context.draw_rounded_rectangle({ 500, 500 }, { 100, 400 }, { 1, 0, 0, 1 }, 10, {10, 20, 30, 40});
|
||||
context.draw_rounded_rectangle({ 500, 500 }, { 100, 400 }, { 1, 0, 0, 1 }, angle, {10, 20, 30, 40});
|
||||
|
||||
double mouse_x, mouse_y;
|
||||
glfwGetCursorPos(get_glfw_window(), &mouse_x, &mouse_y);
|
||||
|
@ -45,7 +45,10 @@ float4 pixel_main(PSInput input) : SV_Target
|
||||
int idx = (quadrant.x > 0 ? 1 : 0) + (quadrant.y > 0 ? 0 : 2);
|
||||
float r = radius[idx];
|
||||
float d = distance_from_rect_uv(p, r);
|
||||
// TODO 抗锯齿
|
||||
|
||||
return input.color * -d;
|
||||
float edge_width = fwidth(d);
|
||||
// 根据dd计算抗锯齿
|
||||
input.color.a *= smoothstep(0.0, edge_width, -d);
|
||||
|
||||
return input.color;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user