Exemplo n.º 1
0
        private void RenderSplineMesh(Camera cam)
        {
            MaterialProperties.Clear();
            if (Profile.EnableReflection)
            {
                MaterialProperties.SetTexture(PMat.REFLECTION_TEX, GetReflectionRt(cam));
            }
            MaterialProperties.SetTexture(PMat.NOISE_TEX, PPoseidonSettings.Instance.NoiseTexture);

            PMat.SetActiveMaterial(MaterialToRender);
            PMat.SetKeywordEnable(PMat.KW_BACK_FACE, false);
            PMat.SetKeywordEnable(PMat.KW_MESH_NOISE, meshNoise != 0);
            PMat.SetFloat(PMat.MESH_NOISE, meshNoise);
            PMat.SetActiveMaterial(null);

            List <PSplineSegment> segments = Spline.Segments;

            for (int i = 0; i < segments.Count; ++i)
            {
                Graphics.DrawMesh(
                    segments[i].Mesh,
                    transform.localToWorldMatrix,
                    MaterialToRender,
                    gameObject.layer,
                    cam,
                    0,
                    MaterialProperties,
                    ShadowCastingMode.Off,
                    false,
                    null,
                    LightProbeUsage.BlendProbes,
                    null);
            }
        }
Exemplo n.º 2
0
        private void RenderTiledMesh(Camera cam)
        {
            bool isBackface = cam.transform.position.y < transform.position.y;

            if (isBackface && !ShouldRenderBackface)
            {
                return;
            }

            MaterialProperties.Clear();
            if (Profile.EnableReflection)
            {
                MaterialProperties.SetTexture(PMat.REFLECTION_TEX, GetReflectionRt(cam));
            }
            MaterialProperties.SetTexture(PMat.NOISE_TEX, PPoseidonSettings.Instance.NoiseTexture);

            Material mat = isBackface ? MaterialBackFace : MaterialToRender;

            PMat.SetActiveMaterial(mat);
            PMat.SetKeywordEnable(PMat.KW_MESH_NOISE, meshNoise != 0);
            PMat.SetFloat(PMat.MESH_NOISE, meshNoise);
            PMat.SetActiveMaterial(null);

            for (int i = 0; i < TileIndices.Count; ++i)
            {
                PIndex2D   index    = TileIndices[i];
                Vector3    pos      = transform.TransformPoint(new Vector3(index.X * TileSize.x, 0, index.Z * TileSize.y));
                Quaternion rotation = transform.rotation;
                Vector3    scale    = new Vector3(TileSize.x * transform.lossyScale.x, 1 * transform.lossyScale.y, TileSize.y * transform.lossyScale.z);

                Graphics.DrawMesh(
                    Mesh,
                    Matrix4x4.TRS(pos, rotation, scale),
                    mat,
                    gameObject.layer,
                    cam,
                    0,
                    MaterialProperties,
                    ShadowCastingMode.Off,
                    false,
                    null,
                    LightProbeUsage.BlendProbes,
                    null);
            }
        }