在Unity中,你使用 HLSL
编程语言编写 shader program
。
本节只包含 HLSL
的Unity特有用法。更通用的 HLSL
用法请查阅 Microsoft’s HLSL documentation
注意:Unity最初使用 CG 语言,因此一些Unity关键字(如:
CGPROGRAM
)和文件扩展名(如:.cginc
)包含cg/CG
。当前Unity已不再使用CG
,但这些命名依然保留。
HLSL
有两种语法:
在Unity中,你使用 HLSL
编程语言编写 shader program
。
本节只包含 HLSL
的Unity特有用法。更通用的 HLSL
用法请查阅 Microsoft’s HLSL documentation
注意:Unity最初使用 CG 语言,因此一些Unity关键字(如:
CGPROGRAM
)和文件扩展名(如:.cginc
)包含cg/CG
。当前Unity已不再使用CG
,但这些命名依然保留。
HLSL
有两种语法:
using DCFApixels.DragonECS; | |
#if ENABLE_IL2CPP | |
using Unity.IL2CPP.CompilerServices; | |
[Il2CppSetOption(Option.NullChecks, false)] | |
[Il2CppSetOption(Option.ArrayBoundsChecks, false)] | |
#endif | |
[System.Serializable] | |
public struct #SCRIPTNAME#:IEcsComponent | |
{ | |
} |
class $COMPONENT$Template:ComponentTemplate<$COMPONENT$>{} |
import taichi as ti | |
ti.init(arch=ti.gpu) | |
n = 320 | |
pixels = ti.field(dtype=float, shape=(n * 2, n)) | |
@ti.func | |
def complex_sqr(z): | |
return ti.Vector([z[0]**2 - z[1]**2, z[1] * z[0] * 2]) |