   How to generate "Random Texutre" & "Sphere Vectors" in SSAO?
  Please help me... Thank you for any advice... -----------------------------------------------I read some source code about SSAO. I found that "Random Texture" and "Sphere Vectors" are necessary as below:-----------------------------------------------1 "Sphere Vectors"float3 pSphere[SAMPLES] = {float3(-0.010735935, 0.01647018, 0.0062425877),float3(-0.06533369, 0.3647007, -0.13746321),float3(-0.6539235, -0.016726388, -0.53000957),float3(0.40958285, 0.0052428036, -0.5591124),float3(-0.1465366, 0.09899267, 0.15571679),float3(-0.44122112, -0.5458797, 0.04912532),float3(0.03755566, -0.10961345, -0.33040273),float3(0.019100213, 0.29652783, 0.066237666),float3(0.8765323, 0.011236004, 0.28265962),float3(0.29264435, -0.40794238, 0.15964167)};How to generate those vectors usually?(in application)------------------------------------------------2 "Random Texture"// grab a normal for reflecting the sample rays later onfloat3 fres = normalize((tex2D(g_samplerNoiseMap,uv*offset).xyz*2.0) - 1.0);How to generate that random texture usually(in application)? And what's the texture coordinate "uv*offset" meaning? That coordinate are out of range[0..1]!------------------------------------------------Please help me... Thank you for any advice... Do not ignore me...Thank you all!   
  It's quite easy, just write a little tool to generate random point in a cube and normalize the direction from the center to this point. The normalized direction is in fact a random point on a unit sphere.Pseudo code for random sphere vectors:// create random coords between -1...1 , random produced a value of [0..1] ,// map this value to [-1..1]float x = random() * 2.0f - 1.0f;float y = random() * 2.0f - 1.0f;float z = random() * 2.0f - 1.0f;// get lengthfloat length = sqrt(x*x+y*y+z*z);// normalizex /= length;y /= length;z /= length;printf("float3(%.8f,%.8f,%.8f)",x,y,z);// to create a random texture, do something like thisint w = 64;int h = 64;// create buffer with 3 components RGBbyte buffer = new byte[w*h*3];for(int x=0;x<w;x++){ for(int y=0;y<h;y++) {   .. calculate x,y,z (see above)   // map [-1..1] to [0.255] for texture component R,G,B   byte b = (byte)( ((x+1.0)*0.5)*255.0f);   byte g = (byte)( ((y+1.0)*0.5)*255.0f);   byte b = (byte)( ((z+1.0)*0.5)*255.0f);   // determine pixel index on texture   int pi = x + y * w;    // write components   buffer[i*3 + 0] = r;   buffer[i*3 + 1] = g;   buffer[i*3 + 2] = b; }}// now the buffer contains a 64x64 RGB texture with random normals... save buffer to i.e. tga file...I think that there will be better methods, but it will be enough for the start.   ;Quote:It's quite easy, just write a little tool to generate random point in a cube and normalize the direction from the center to this point. While this is true, you'd normally like to have an uniform distribution of the points on the spheres surfaces.Using your method you get a higher concentration of points "near the cube corners".To make things worse, when using these vectors for sampling (when the sample count is very low) it's more important to get the points evenly distributed over the sphere surface.Using random points might give you terrible results, what if all random points ended up in one octet? You would then miss the contribution to the ao term for 7/8 th of all possible viewing directions.So what you really wants is a way to place N points on the sphere as evenly distanced from each other as possible.One way (slow) to do this is to start with N points on the sphere (randomly long/lat points etc) and then iterate over these point and making small improvements until the things stabilizes (i.e adding springs between all points and let the system stabilize).In reality this could be done quite easy, i.e for each iteration:Find the two vertices that are closest to each other.Calculate the vector between them, i.e D = B - APush them apart slightly by using a fraction of D, i.e: A = A - D*f, B = B + D*fRe-normalize A and B (i.e move them back to the sphere surface).Scale down the fraction slightly on each iteration, i.e: f = f * 0.99 (start with a quite small fraction like 0.1).Run a lot of iteration and you should have N points on the sphere that is very close to being equally spaced on the surface.;  This is what I use most often to generate a randomly distributed point set:http://mathworld.wolfram.com/SpherePointPicking.htmlIf I need to make sure that they're evenly distributed, I use the point repulsion code by Vladimir Bulatov (akin to what eq mentions above):http://www.math.niu.edu/~rusin/known-math/96/repulsion;  Thank you all very much!Thanks for: Ashaman73 your whole procedureseq optimal adviceand taby valuable article.;  I had a similar problem recently which I described in this Gamedev Post. On the bottom of the post I provide a link to an algorithm I found on the internet that generates a really good uniform set of points on the unit sphere using only a few lines of code.It's really important to have a uniform distribution of points for all sampling algorithms because it reduces the generated noise and in some cases it can even perceptually remove it without increasing the amount of samples.   