Unity3d 从函数返回结构
cg中的结构可以用于声明管道语义以外的任何东西吗 我使用的是Unity3D,这段代码抛出了“隐式/Rose中的着色器错误:在第48行(d3d11上)“PetalData”的重新定义” 我怎样才能让它工作?我是否遗漏了什么,或者这只是一个不受Unity支持的用法Unity3d 从函数返回结构,unity3d,cg,Unity3d,Cg,cg中的结构可以用于声明管道语义以外的任何东西吗 我使用的是Unity3D,这段代码抛出了“隐式/Rose中的着色器错误:在第48行(d3d11上)“PetalData”的重新定义” 我怎样才能让它工作?我是否遗漏了什么,或者这只是一个不受Unity支持的用法 struct PetalData { half radius; half2 center; } PetalData GetPetalData (half petalIndex, half totalPetals) {
struct PetalData {
half radius;
half2 center;
}
PetalData GetPetalData (half petalIndex, half totalPetals) {
half p = petalIndex/totalPetals;
PetalData petal;
petal.radius = 0.03 * SShape(p) + 0.01;
petal.center = sqrt(p) * AngleToDir(petalIndex);
return petal;
}
half PetalField (half2 topology, PetalData petal) {
half d = distance(topology, petal.center);
d /= petal.radius;
d = 1 - d;
d *= _Ramp;
return d;
}
如果我读对了,我相信您的结构定义需要一个终止分号
struct PetalData {
half radius;
half2 center;
};
是的,就是这样。把一个放在那里感觉很尴尬。谢谢