Exemple #1
0
        private void Render(Camera camera, CascadedShadowUniforms shadowSource)
        {
            lighting.UpdateDirectionalLight(camera);
            shadows.viewLightMatrices &= !shadowSource.viewLightMatrices;
            //shadows.lightSpaceMatrix &= !shadowSource.lightSpaceMatrix;

            foreach (var mesh in camera.NodesInView <Mesh <EntityVertex> > ())
            {
                Sampler.Bind(!samplers, mesh.Textures);
                transforms.UpdateModelViewAndNormalMatrices(camera.WorldToCamera * mesh.Transform);
                _entityShader.DrawElements(PrimitiveType.Triangles, mesh.VertexBuffer, mesh.IndexBuffer);
                Sampler.Unbind(!samplers, mesh.Textures);
            }
        }
Exemple #2
0
        private void Render(Camera camera, CascadedShadowUniforms shadowSource)
        {
            var worldToCamera = camera.WorldToCamera;

            lighting.UpdateDirectionalLight(camera);
            shadows.viewLightMatrices &= !shadowSource.viewLightMatrices;
            //shadows.lightSpaceMatrix &= !shadowSource.lightSpaceMatrix;

            foreach (var mesh in camera.NodesInView <TerrainMesh <TerrainVertex> > ())
            {
                if (mesh.VertexBuffer != null && mesh.IndexBuffers != null)
                {
                    transforms.UpdateModelViewAndNormalMatrices(worldToCamera * mesh.Transform);
                    var distance = -(worldToCamera * mesh.BoundingBox).Front;
                    var lod      = distance < 100 ? 0 :
                                   distance < 200 ? 1 :
                                   2;
                    _terrainShader.DrawElements(PrimitiveType.TriangleStrip, mesh.VertexBuffer,
                                                mesh.IndexBuffers[lod]);
                }
            }
        }