Hi,

I need to generate a 'uniform sample' over an hemisphere and once done project it in a specific vector direction.

I have try the following, but it produce some errors... maybe you have an idea ? I have another solution, but I don't understand why this one does not work !

**1. Create a random direction**

x = random() * 2 - 1

y = random() * 2 - 1

z = random() * 2 - 1

d = normalize(x,y,z) // Scale it to have vector lenght = 1

**2. Project the sample into the direction**

dp = dot_product(d, direction)

if dp <= 0 then result = -d

else result = d

Thanks