[!warning|aside-r] 仅限片段着色器

clip 裁剪

在片元着色器阶段对像素进行裁剪(丢弃),如果传入的参数任何分量小于0,则丢弃当前像素

HLSL
clip(0); // 大于等于0,保留
clip(-1); // 小于0,裁剪
点击展开查看更多

案例:画圆⚪,即丢弃圆外的像素

HLSL
// 画圆⚪,即丢弃圆外的像素
float dist = distance(uv, float2(0.5)); // 圆中心(0.5, 0.5)
clip(0.5 - dist); // 半径0.5
点击展开查看更多

版权声明

作者: Chaim

链接: https://chaim.eu.org/posts/%E5%86%85%E7%BD%AE%E5%87%BD%E6%95%B0%E6%B8%B2%E6%9F%93/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键