法线平滑

基础

传统的法线外扩进行描边的

Cg shader

Gdshader

// https://godotshaders.com/shader/the-simplest-outline-shader-improved/
shader_type spatial;
render_mode cull_front, unshaded;

uniform float thickness : hint_range(0.0, 1.0, 0.01) = 0.1;
void vertex() {
	VERTEX += thickness * NORMAL;
}

void fragment() {
    ALBEDO = vec3(0.0, 0.0, 0.0);
}

从 Blender 中导出带有平滑法线的模型

Blender 输出“平滑法线”到自定义通道

将 Blender 中的带有平滑后的法线的 glb 导入到 godot 中,在使用上述描边就可以得到“接近完美”描边,但是会导致

Unity 中计算平滑法线

进阶