private void CreateMeshes() { if (this.blitMesh == null) { this.blitMesh = ReflectionProbeEx.CreateBlitMesh(); } if (this.skyboxMesh == null) { this.skyboxMesh = ReflectionProbeEx.CreateSkyboxMesh(); } }
private void CreateMeshes() { if (Object.op_Equality((Object)this.blitMesh, (Object)null)) { this.blitMesh = ReflectionProbeEx.CreateBlitMesh(); } if (!Object.op_Equality((Object)this.skyboxMesh, (Object)null)) { return; } this.skyboxMesh = ReflectionProbeEx.CreateSkyboxMesh(); }
private static void SubdivideYOnly(List <ReflectionProbeEx.CubemapSkyboxVertex> destArray, ReflectionProbeEx.CubemapSkyboxVertex v1, ReflectionProbeEx.CubemapSkyboxVertex v2, ReflectionProbeEx.CubemapSkyboxVertex v3) { ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex; ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex1; ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex2; float single = Mathf.Abs(v2.y - v1.y); float single1 = Mathf.Abs(v2.y - v3.y); float single2 = Mathf.Abs(v3.y - v1.y); if (single < single1 && single < single2) { cubemapSkyboxVertex = v3; cubemapSkyboxVertex1 = v1; cubemapSkyboxVertex2 = v2; } else if (single1 >= single || single1 >= single2) { cubemapSkyboxVertex = v2; cubemapSkyboxVertex1 = v3; cubemapSkyboxVertex2 = v1; } else { cubemapSkyboxVertex = v1; cubemapSkyboxVertex1 = v2; cubemapSkyboxVertex2 = v3; } ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex3 = ReflectionProbeEx.SubDivVert(cubemapSkyboxVertex, cubemapSkyboxVertex1); ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex4 = ReflectionProbeEx.SubDivVert(cubemapSkyboxVertex, cubemapSkyboxVertex2); destArray.Add(cubemapSkyboxVertex); destArray.Add(cubemapSkyboxVertex3); destArray.Add(cubemapSkyboxVertex4); Vector3 vector3 = new Vector3(cubemapSkyboxVertex4.x - cubemapSkyboxVertex1.x, cubemapSkyboxVertex4.y - cubemapSkyboxVertex1.y, cubemapSkyboxVertex4.z - cubemapSkyboxVertex1.z); Vector3 vector31 = new Vector3(cubemapSkyboxVertex3.x - cubemapSkyboxVertex2.x, cubemapSkyboxVertex3.y - cubemapSkyboxVertex2.y, cubemapSkyboxVertex3.z - cubemapSkyboxVertex2.z); if (vector3.x * vector3.x + vector3.y * vector3.y + vector3.z * vector3.z > vector31.x * vector31.x + vector31.y * vector31.y + vector31.z * vector31.z) { destArray.Add(cubemapSkyboxVertex3); destArray.Add(cubemapSkyboxVertex1); destArray.Add(cubemapSkyboxVertex2); destArray.Add(cubemapSkyboxVertex4); destArray.Add(cubemapSkyboxVertex3); destArray.Add(cubemapSkyboxVertex2); return; } destArray.Add(cubemapSkyboxVertex4); destArray.Add(cubemapSkyboxVertex3); destArray.Add(cubemapSkyboxVertex1); destArray.Add(cubemapSkyboxVertex4); destArray.Add(cubemapSkyboxVertex1); destArray.Add(cubemapSkyboxVertex2); }
private static void Subdivide(List <ReflectionProbeEx.CubemapSkyboxVertex> destArray, ReflectionProbeEx.CubemapSkyboxVertex v1, ReflectionProbeEx.CubemapSkyboxVertex v2, ReflectionProbeEx.CubemapSkyboxVertex v3) { ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex = ReflectionProbeEx.SubDivVert(v1, v2); ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex1 = ReflectionProbeEx.SubDivVert(v2, v3); ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex2 = ReflectionProbeEx.SubDivVert(v1, v3); destArray.Add(v1); destArray.Add(cubemapSkyboxVertex); destArray.Add(cubemapSkyboxVertex2); destArray.Add(cubemapSkyboxVertex); destArray.Add(v2); destArray.Add(cubemapSkyboxVertex1); destArray.Add(cubemapSkyboxVertex1); destArray.Add(cubemapSkyboxVertex2); destArray.Add(cubemapSkyboxVertex); destArray.Add(v3); destArray.Add(cubemapSkyboxVertex2); destArray.Add(cubemapSkyboxVertex1); }
private static Mesh CreateSkyboxMesh() { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertices = new List <ReflectionProbeEx.CubemapSkyboxVertex>(); for (int i = 0; i < 24; i++) { ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex = new ReflectionProbeEx.CubemapSkyboxVertex(); Vector3 vector3 = Vector3.Normalize(new Vector3(ReflectionProbeEx.octaVerts[i * 3], ReflectionProbeEx.octaVerts[i * 3 + 1], ReflectionProbeEx.octaVerts[i * 3 + 2])); float single = vector3.x; float single1 = single; cubemapSkyboxVertex.tu = single; cubemapSkyboxVertex.x = single1; float single2 = vector3.y; single1 = single2; cubemapSkyboxVertex.tv = single2; cubemapSkyboxVertex.y = single1; float single3 = vector3.z; single1 = single3; cubemapSkyboxVertex.tw = single3; cubemapSkyboxVertex.z = single1; cubemapSkyboxVertex.color = Color.white; cubemapSkyboxVertices.Add(cubemapSkyboxVertex); } for (int j = 0; j < 3; j++) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertices1 = new List <ReflectionProbeEx.CubemapSkyboxVertex>(cubemapSkyboxVertices.Count); cubemapSkyboxVertices1.AddRange(cubemapSkyboxVertices); int count = cubemapSkyboxVertices1.Count; cubemapSkyboxVertices.Clear(); cubemapSkyboxVertices.Capacity = count * 4; for (int k = 0; k < count; k += 3) { ReflectionProbeEx.Subdivide(cubemapSkyboxVertices, cubemapSkyboxVertices1[k], cubemapSkyboxVertices1[k + 1], cubemapSkyboxVertices1[k + 2]); } } for (int l = 0; l < 2; l++) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertices2 = new List <ReflectionProbeEx.CubemapSkyboxVertex>(cubemapSkyboxVertices.Count); cubemapSkyboxVertices2.AddRange(cubemapSkyboxVertices); int num = cubemapSkyboxVertices2.Count; float single4 = Mathf.Pow(0.5f, (float)l + 1f); cubemapSkyboxVertices.Clear(); cubemapSkyboxVertices.Capacity = num * 4; for (int m = 0; m < num; m += 3) { if (Mathf.Max(Mathf.Max(Mathf.Abs(cubemapSkyboxVertices2[m].y), Mathf.Abs(cubemapSkyboxVertices2[m + 1].y)), Mathf.Abs(cubemapSkyboxVertices2[m + 2].y)) <= single4) { ReflectionProbeEx.SubdivideYOnly(cubemapSkyboxVertices, cubemapSkyboxVertices2[m], cubemapSkyboxVertices2[m + 1], cubemapSkyboxVertices2[m + 2]); } else { cubemapSkyboxVertices.Add(cubemapSkyboxVertices2[m]); cubemapSkyboxVertices.Add(cubemapSkyboxVertices2[m + 1]); cubemapSkyboxVertices.Add(cubemapSkyboxVertices2[m + 2]); } } } Mesh mesh = new Mesh(); Vector3[] vector3Array = new Vector3[cubemapSkyboxVertices.Count]; Vector2[] vector2Array = new Vector2[cubemapSkyboxVertices.Count]; int[] numArray = new int[cubemapSkyboxVertices.Count]; for (int n = 0; n < cubemapSkyboxVertices.Count; n++) { vector3Array[n] = new Vector3(cubemapSkyboxVertices[n].x, cubemapSkyboxVertices[n].y, cubemapSkyboxVertices[n].z); vector2Array[n] = new Vector3(cubemapSkyboxVertices[n].tu, cubemapSkyboxVertices[n].tv); numArray[n] = n; } mesh.vertices = vector3Array; mesh.uv = vector2Array; mesh.triangles = numArray; return(mesh); }
private static Mesh CreateSkyboxMesh() { List <ReflectionProbeEx.CubemapSkyboxVertex> destArray = new List <ReflectionProbeEx.CubemapSkyboxVertex>(); for (int index = 0; index < 24; ++index) { ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex = new ReflectionProbeEx.CubemapSkyboxVertex(); Vector3 vector3 = Vector3.Normalize(new Vector3(ReflectionProbeEx.octaVerts[index * 3], ReflectionProbeEx.octaVerts[index * 3 + 1], ReflectionProbeEx.octaVerts[index * 3 + 2])); cubemapSkyboxVertex.x = cubemapSkyboxVertex.tu = (float)vector3.x; cubemapSkyboxVertex.y = cubemapSkyboxVertex.tv = (float)vector3.y; cubemapSkyboxVertex.z = cubemapSkyboxVertex.tw = (float)vector3.z; cubemapSkyboxVertex.color = Color.get_white(); destArray.Add(cubemapSkyboxVertex); } for (int index1 = 0; index1 < 3; ++index1) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertexList = new List <ReflectionProbeEx.CubemapSkyboxVertex>(destArray.Count); cubemapSkyboxVertexList.AddRange((IEnumerable <ReflectionProbeEx.CubemapSkyboxVertex>)destArray); int count = cubemapSkyboxVertexList.Count; destArray.Clear(); destArray.Capacity = count * 4; for (int index2 = 0; index2 < count; index2 += 3) { ReflectionProbeEx.Subdivide(destArray, cubemapSkyboxVertexList[index2], cubemapSkyboxVertexList[index2 + 1], cubemapSkyboxVertexList[index2 + 2]); } } for (int index1 = 0; index1 < 2; ++index1) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertexList = new List <ReflectionProbeEx.CubemapSkyboxVertex>(destArray.Count); cubemapSkyboxVertexList.AddRange((IEnumerable <ReflectionProbeEx.CubemapSkyboxVertex>)destArray); int count = cubemapSkyboxVertexList.Count; float num = Mathf.Pow(0.5f, (float)index1 + 1f); destArray.Clear(); destArray.Capacity = count * 4; for (int index2 = 0; index2 < count; index2 += 3) { if ((double)Mathf.Max(Mathf.Max(Mathf.Abs(cubemapSkyboxVertexList[index2].y), Mathf.Abs(cubemapSkyboxVertexList[index2 + 1].y)), Mathf.Abs(cubemapSkyboxVertexList[index2 + 2].y)) > (double)num) { destArray.Add(cubemapSkyboxVertexList[index2]); destArray.Add(cubemapSkyboxVertexList[index2 + 1]); destArray.Add(cubemapSkyboxVertexList[index2 + 2]); } else { ReflectionProbeEx.SubdivideYOnly(destArray, cubemapSkyboxVertexList[index2], cubemapSkyboxVertexList[index2 + 1], cubemapSkyboxVertexList[index2 + 2]); } } } Mesh mesh = new Mesh(); Vector3[] vector3Array = new Vector3[destArray.Count]; Vector2[] vector2Array = new Vector2[destArray.Count]; int[] numArray = new int[destArray.Count]; for (int index = 0; index < destArray.Count; ++index) { vector3Array[index] = new Vector3(destArray[index].x, destArray[index].y, destArray[index].z); vector2Array[index] = Vector2.op_Implicit(new Vector3(destArray[index].tu, destArray[index].tv)); numArray[index] = index; } mesh.set_vertices(vector3Array); mesh.set_uv(vector2Array); mesh.set_triangles(numArray); return(mesh); }
private static void SubdivideYOnly( List <ReflectionProbeEx.CubemapSkyboxVertex> destArray, ReflectionProbeEx.CubemapSkyboxVertex v1, ReflectionProbeEx.CubemapSkyboxVertex v2, ReflectionProbeEx.CubemapSkyboxVertex v3) { float num1 = Mathf.Abs(v2.y - v1.y); float num2 = Mathf.Abs(v2.y - v3.y); float num3 = Mathf.Abs(v3.y - v1.y); ReflectionProbeEx.CubemapSkyboxVertex v1_1; ReflectionProbeEx.CubemapSkyboxVertex v2_1; ReflectionProbeEx.CubemapSkyboxVertex v2_2; if ((double)num1 < (double)num2 && (double)num1 < (double)num3) { v1_1 = v3; v2_1 = v1; v2_2 = v2; } else if ((double)num2 < (double)num1 && (double)num2 < (double)num3) { v1_1 = v1; v2_1 = v2; v2_2 = v3; } else { v1_1 = v2; v2_1 = v3; v2_2 = v1; } ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex1 = ReflectionProbeEx.SubDivVert(v1_1, v2_1); ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex2 = ReflectionProbeEx.SubDivVert(v1_1, v2_2); destArray.Add(v1_1); destArray.Add(cubemapSkyboxVertex1); destArray.Add(cubemapSkyboxVertex2); Vector3 vector3_1; ((Vector3) ref vector3_1).\u002Ector(cubemapSkyboxVertex2.x - v2_1.x, cubemapSkyboxVertex2.y - v2_1.y, cubemapSkyboxVertex2.z - v2_1.z); Vector3 vector3_2; ((Vector3) ref vector3_2).\u002Ector(cubemapSkyboxVertex1.x - v2_2.x, cubemapSkyboxVertex1.y - v2_2.y, cubemapSkyboxVertex1.z - v2_2.z); if (vector3_1.x * vector3_1.x + vector3_1.y * vector3_1.y + vector3_1.z * vector3_1.z > vector3_2.x * vector3_2.x + vector3_2.y * vector3_2.y + vector3_2.z * vector3_2.z) { destArray.Add(cubemapSkyboxVertex1); destArray.Add(v2_1); destArray.Add(v2_2); destArray.Add(cubemapSkyboxVertex2); destArray.Add(cubemapSkyboxVertex1); destArray.Add(v2_2); } else { destArray.Add(cubemapSkyboxVertex2); destArray.Add(cubemapSkyboxVertex1); destArray.Add(v2_1); destArray.Add(cubemapSkyboxVertex2); destArray.Add(v2_1); destArray.Add(v2_2); } }