Reputation: 1072
Can structs in cg be used for anything outher than declaring pipeline semantics?
I'm using Unity3D and this code throws "Shader error in 'Implicit/Rose': redefinition of 'PetalData' at line 48 (on d3d11)".
How can I make it work? Am I missing something, or it's just a usage not supported by Unity?
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;
}
Upvotes: 3
Views: 1768
Reputation: 201
If I'm reading this correctly, I believe your struct definition needs a terminating semicolon.
struct PetalData {
half radius;
half2 center;
};
Upvotes: 3