Beispiel #1
0
        public void DrawClippedSky(GraphicsDevice device, Effect effect, Camera camera)
        {
            DepthStencilState s = new DepthStencilState();
            s.DepthBufferWriteEnable = false;
            DepthStencilState bak = device.DepthStencilState;
            device.DepthStencilState = s;
            device.RasterizerState = new RasterizerState() { CullMode = CullMode.None, FillMode = FillMode.Solid };

            Matrix wMatrix = Matrix.CreateScale(scale) * Matrix.CreateTranslation(camera.position);

            effect.CurrentTechnique = effect.Techniques["SkyBox"];
            effect.Parameters["xView"].SetValue(camera.getview());
            effect.Parameters["xProjection"].SetValue(camera.GetProjection());
            effect.Parameters["xWorld"].SetValue(wMatrix);
            effect.Parameters["xCamPos"].SetValue(camera.position);
            effect.Parameters["xSkyBoxTexture"].SetValue(cloudMap);
            effect.Parameters["xEnableLighting"].SetValue(false);
            //currentEffect.Parameters["xClipping"].SetValue(true);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.SetVertexBuffer(vertexBuffer);
                device.Indices = indexBuffer;
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, indexBuffer.IndexCount, 0, indexBuffer.IndexCount / 3);
            }

            device.DepthStencilState = bak;
        }
Beispiel #2
0
        public void DrawRefractionMap(Camera c)
        {
            viewMatrix = c.getview();
            projectionMatrix = c.GetProjection();
            cameraPosition = c.position;

            Plane refractionPlane = CreatePlane(waterHeight + 50f, new Vector3(0, -1, 0), viewMatrix, projectionMatrix, false);
            effect.CurrentTechnique = effect.Techniques["Textured"];
            effect.Parameters["xClipPlane0"].SetValue(new Vector4(refractionPlane.Normal, refractionPlane.D));
            effect.Parameters["xClipping"].SetValue(true);

            device.SetRenderTarget(refractionRenderTarget);

            device.DepthStencilState = new DepthStencilState();
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 5.0f, 0);

            ground.DrawClippedGround(device, effect, c);

            effect.Parameters["xClipping"].SetValue(false);

            device.SetRenderTarget(null);

            refractionMap = (Texture2D)refractionRenderTarget;
        }
Beispiel #3
0
        public void DrawClippedGround(GraphicsDevice device, Effect effect, Camera camera)
        {
            effect.CurrentTechnique = effect.Techniques["MultiTextured"];
            effect.Parameters["xTexturesMap"].SetValue(biomeTexture);
            effect.Parameters["xView"].SetValue(camera.getview());
            effect.Parameters["xProjection"].SetValue(camera.GetProjection());
            effect.Parameters["xWorld"].SetValue(Matrix.Identity);

            device.RasterizerState = new RasterizerState() { CullMode = CullMode.CullClockwiseFace, FillMode = FillMode.Solid };
            device.BlendState = BlendState.Opaque;
            device.DepthStencilState = DepthStencilState.Default;

            //effect.Parameters["xTexture"].SetValue(Tools.Quick.groundTexture[gt]);
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.SetVertexBuffer(GroundVertices);
                device.Indices = GroundIndices;
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GroundIndices.IndexCount, 0, GroundIndices.IndexCount / 3);
            }
        }