Exemplo n.º 1
0
        public MasterRenderer(Camera camera, Loader loader, DirectionalLight sun, int width, int height)
        {
            Gl.Enable(EnableCap.DepthTest);
            this.clientWidth      = width;
            this.clientHeight     = height;
            this.projectionMatrix = Maths.CreateProjectionMatrix(FOV, AspectRatio, NEAR_PLANE, FAR_PLANE);

            //Entities
            this.entityShader   = new StaticShader();
            this.entityRenderer = new EntityRenderer(entityShader, width, height, this.projectionMatrix);
            this.entities       = new Dictionary <TextureModel, List <Entity> >();

            //Skybox
            this.skyboxRenderer = new SkyboxRenderer(loader, this.projectionMatrix);

            //Shadow
            this.shadowDepthShader      = new ShadowDepthShader();
            this.shadowDepthFrameBuffer = new ShadowDepthFrameBuffer();
            this.shadowRenderer         = new ShadowRenderer(sun, shadowDepthShader, shadowDepthFrameBuffer);

            //Terrain
            this.terrainShader   = new TerrainShader();
            this.terrainRenderer = new TerrainRenderer(this.terrainShader, this.projectionMatrix, this.shadowRenderer);
            this.terrainList     = new List <Terrain>();
        }
Exemplo n.º 2
0
        public ShadowRenderer(DirectionalLight sun, ShadowDepthShader shader, ShadowDepthFrameBuffer depthFrameBuffer)
        {
            this.shader           = shader;
            this.depthFrameBuffer = depthFrameBuffer;

            Matrix4x4f lightProjection = Matrix4x4f.Ortho(-100.0f, 100.0f, -100.0f, 100.0f, near_plane, far_plane);
            Matrix4x4f lightView       = Matrix4x4f.LookAt(sun.Position, sun.Position + sun.Direction, Vertex3f.UnitY);

            LightSpaceMatrix = lightProjection * lightView;
            this.shader.Start();
            this.shader.LoadLightSpaceMatrixMatrix(LightSpaceMatrix);
            this.shader.Stop();
        }