Exemplo n.º 1
0
        public void DrawLand(Vector4 clipPlane, Matrix view)
        {
            var viewProj = view * _proj;

            ImmediateContext.InputAssembler.SetVertexBuffers(0, new D3D11.VertexBufferBinding(_groundVB, VertexPN.Stride, 0));
            ImmediateContext.InputAssembler.SetIndexBuffer(_groundIB, DXGI.Format.R32_UInt, 0);

            int len;

            for (int p = 0; p < _tech.Description.PassCount; p++)
            {
                var wvp = _groundWorld * view * _proj;
                _fxWVP.SetMatrix(wvp);

                _fxClipPlane.Set(clipPlane);

                var invTranspose = Matrix.Invert(Matrix.Transpose(_groundWorld));

                _fxWIT.SetMatrix(invTranspose);
                _fxWorld.SetMatrix(_groundWorld);
                var array = Util.GetArray(_landMaterial, out len);
                _fxMaterial.SetRawValue(DataStream.Create <byte>(array, false, false), len);

                _fxDiffuseMap.SetResource(_groundMapSRV);

                var pass = _tech.GetPassByIndex(p);
                pass.Apply(ImmediateContext);

                ImmediateContext.DrawIndexed(_groundIndexCount, 0, 0);
                _fxDiffuseMap.SetResource(null);

                _fxClipPlane.Set(new float[] { 0, 0, 0, 1 });
            }
        }
Exemplo n.º 2
0
        public override void DrawScene()
        {
            base.DrawScene();

            //First update reflection and refraction maps
            RenderRefractionMap();
            RenderReflectionMap();

            ImmediateContext.ClearRenderTargetView(RenderTargetView, Color.LightSteelBlue);
            ImmediateContext.ClearDepthStencilView(DepthStencilView, D3D11.DepthStencilClearFlags.Depth | D3D11.DepthStencilClearFlags.Stencil, 1.0f, 0);

            ImmediateContext.InputAssembler.InputLayout       = _inputLayout;
            ImmediateContext.InputAssembler.PrimitiveTopology = D3D.PrimitiveTopology.TriangleList;

            int len;
            var array = Util.GetArray(_dirLight, out len);

            //Pass lights data and position of eye (used for specular lighting)
            _fxDirLight.SetRawValue(DataStream.Create <byte>(array, false, false), len);
            array = Util.GetArray(_pointLight, out len);
            _fxPointLight.SetRawValue(DataStream.Create <byte>(array, false, false), len);
            array = Util.GetArray(_spotLight, out len);
            _fxSpotLight.SetRawValue(DataStream.Create <byte>(array, false, false), len);

            _fxEyePosW.Set(_eyePosW);

            DrawLand();
            DrawWater();
            DrawBall();


            SwapChain.Present(0, DXGI.PresentFlags.None);
        }