Sign in to follow this  
brett01

generating normals around a hemisphere *urgent pls*

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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this