# generating normals around a hemisphere *urgent pls*

This topic is 3684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

In order to do this Im using Malley's Method CVector Ret; float X, Y; float u1 = UniformRandomNr(), u2 = UniformRandomNr(); ConcentricSampleDiskEx(u1, u2, &Ret.X, &Ret.Y); Ret.Z = sqrt(max(0.f, 1.f - Ret.X * Ret.X - Ret.Y * Ret.Y) ); return Ret; This will give a cosine distribution with a normal vector along the Z axis. So it needs to transform according to the normal vector of the surface.can some one help to how to transform normal vactor w.r.t to a surface pls.Thank you in advance.

##### Share on other sites
By the way I used

void buildFrame(const CVector3& normal, CVector3& v1, CVector3& v2)
{
v1 = normal.cross(CVector3(1, 0, 0));
if (v1.squareLength() < 0.01)
v1 = normal.cross(CVector3(0, 1, 0));
v2 = normal.cross(v1);
}

output(Ret.x * v1 + Ret.y * v2 + Ret.z * normal);

Im using this.but every time Im getting no of intersects as 0 for ambient occlusion.

##### Share on other sites
maybe I'm missing something, but is there any reason not to just normalise each point's position relative to the centre of the sphere and use that?

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633700
• Total Posts
3013426
×