Exemplo n.º 1
0
        void Update()
        {
            if (dirty)
            {
                dirty = false;
                DoCleanup();
                DoUpdate();
            }

            if (playerCamera == null || playerCamera.gameObject != player)
            {
                playerCamera = player.GetComponent <Camera>();
            }

            ReconciliationData reconciliationData = ReconciliationData.GetData(context, playerCamera);

            if (reconciliationData == null)
            {
                return;
            }

            if (Time.time >= lastReconciliationTime + reconciliationInterval)
            {
                Reconciler.Reconcile(context, reconciliationData);
                lastReconciliationTime = Time.time;
            }
        }
Exemplo n.º 2
0
        void DoUpdate()
        {
            MeshModifier meshModifier = displacementSettings.GetMeshModifier();

            meshModifier.ModifyMaterial(material);

            Context.Constants constants = new Context.Constants
            {
                desiredScreenSpaceLength = desiredScreenSpaceLength,
                gameObject   = gameObject,
                material     = material,
                maxDepth     = maxDepth,
                resolution   = resolution * 2 - 1, // We can only use odd resolutions.,
                meshModifier = meshModifier
            };

            Context.Branch[]    branches  = Context.Branch.GetFromConstants(constants);
            Context.Depth[]     depths    = Context.Depth.GetFromConstants(constants);
            Context.Triangles[] triangles = Context.Triangles.GetFromConstants(constants);
            Node[] roots = new Node[6];
            for (int i = 0; i < 6; i++)
            {
                roots[i] = Node.CreateRoot(constants, depths[0], branches[i]);
            }

            context = new Context
            {
                constants = constants,
                branches  = branches,
                depths    = depths,
                triangles = triangles,
                roots     = roots
            };

            Reconciler.Initialize(context);
            lastReconciliationTime = Time.time;
        }