Exemplo n.º 1
0
        private QuadTerrainRenderMesh GetRenderMesh(MeshType meshType)
        {
            var renderMesh = RenderMeshes[(int)meshType];

            if (renderMesh != null)
            {
                return(renderMesh);
            }

            renderMesh                 = new QuadTerrainRenderMesh();
            renderMesh.Mesh            = QuadTerrainConfig.Instance.GetMesh(meshType);
            renderMesh.Props           = new MaterialPropertyBlock();
            renderMesh.Matrices        = new Matrix4x4[1023];
            renderMesh.RenderingLayers = new Vector4[1023];

            int   flags      = 0xff; // enable all light layers
            float flagsFloat = BitConverter.ToSingle(BitConverter.GetBytes(flags), 0);

            for (int i = 0; i < renderMesh.RenderingLayers.Length; i++)
            {
                renderMesh.RenderingLayers[i] = new Vector4(flagsFloat, 0, 0, 0);
            }
            renderMesh.Props.SetVectorArray("unity_RenderingLayer", renderMesh.RenderingLayers);

            RenderMeshes[(int)meshType] = renderMesh;

            return(renderMesh);
        }
Exemplo n.º 2
0
 private void Draw(Material material, QuadTerrainRenderMesh item)
 {
     Graphics.DrawMeshInstanced(
         mesh: item.Mesh,
         submeshIndex: 0,
         material: material,
         matrices: item.Matrices,
         count: item.Count,
         properties: item.Props,
         castShadows: ShadowCastingMode.Off,
         receiveShadows: true,
         layer: 0,
         null,
         LightProbeUsage.Off
         );
 }