mazahist

Member

6

Community Reputation

155 Neutral

• Rank
Newbie

How to correct this transition:
2. The use of spherical harmonics

I calculated spherical harmonics. How to use them in a scene?
3. smoothing normals

How to smooth normals? When I calculate the normal, they become flat.        var figure = {     vertex: [1, 1, -1, -1, 0, 0, -1, 1, -1, 1, 0, 1, 1, 0, 0, -1, 0, 1],     index: [0, 1, 2, 3, 1, 4, 0, 4, 1, 3, 5, 1]     };          function calcNormal(vertex, index) {     var vertNormal = [];     var surfNormal = [];     for (var i = 0; i < index.length; i += 3) {     var v0_v = [vertex[index[i + 0] * 3 + 0], vertex[index[i + 0] * 3 + 1], vertex[index[i + 0] * 3 + 2]];     var v1_v = [vertex[index[i + 1] * 3 + 0], vertex[index[i + 1] * 3 + 1], vertex[index[i + 1] * 3 + 2]];     var v2_v = [vertex[index[i + 2] * 3 + 0], vertex[index[i + 2] * 3 + 1], vertex[index[i + 2] * 3 + 2]];     var p = Vector3.minus(v1_v, v0_v);     var q = Vector3.minus(v2_v, v0_v);     var n = Vector3.cross(p, q);     //n = Vector3.normalize(n);     surfNormal.push(-n[0]);     surfNormal.push(-n[1]);     surfNormal.push(-n[2]);          vertNormal[index[i + 0] * 3 + 0] = -n[0]; vertNormal[index[i + 0] * 3 + 1] = -n[1]; vertNormal[index[i + 0] * 3 + 2] = -n[2];     vertNormal[index[i + 1] * 3 + 0] = -n[0]; vertNormal[index[i + 1] * 3 + 1] = -n[1]; vertNormal[index[i + 1] * 3 + 2] = -n[2];     vertNormal[index[i + 2] * 3 + 0] = -n[0]; vertNormal[index[i + 2] * 3 + 1] = -n[1]; vertNormal[index[i + 2] * 3 + 2] = -n[2];     };     //... calculation smooth normals     //...     //createBuffer(vertNormal)     }     calcNormal(figure.vertex, figure.index);
4. spherical harmonics coefficient

How to calculate 9 coefficients for spherical harmonics on the basis of cubemap texture? In the demo already contains the calculated coefficients; I need to get them on the basis of cubemap texture