public void PrepareForDraw(MyEffectDistantImpostors effect)
            {
                if (!ImpostorProperties.Enabled)
                {
                    return;
                }

                if (ImpostorProperties.ImpostorType == MyImpostorType.Nebula)
                {
                    Matrix mat = Matrix.CreateScale(ImpostorProperties.MinDistance) * Matrix.CreateTranslation(MyCamera.Position * 0.5f);

                    Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyCamera.Zoom.GetFOV(), MyCamera.ForwardAspectRatio, 1000, 10000000);

                    effect.SetWorldMatrix(mat);
                    effect.SetViewProjectionMatrix(MyCamera.ViewMatrix * projection);
                    effect.SetScale(ImpostorProperties.Radius * 0.00018f);
                    effect.SetColor(ImpostorProperties.Color);

                    effect.SetContrastAndIntensity(new Vector2(ImpostorProperties.Contrast, ImpostorProperties.Intensity));
                    effect.SetAnimation(m_animationTime);
                    effect.SetCameraPos(MyCamera.Position);
                    effect.SetSunDirection(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());

                    effect.SetTechnique(MyEffectDistantImpostors.Technique.Textured3D);

                    effect.Begin();
                    MySimpleObjectDraw.ModelSphere.Render();
                    effect.End();
                }
            }
        public void Draw(MyEffectDistantImpostors effect)
        {
            LoadInDraw();

            Device device = MyMinerGame.Static.GraphicsDevice;

            RasterizerState.CullNone.Apply();
            MyStateObjects.NonPremultiplied_NoAlphaWrite_BlendState.Apply();
            MyStateObjects.DistantImpostorsDepthStencilState.Apply();


            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyCamera.Zoom.GetFOV(), MyCamera.ForwardAspectRatio, 1000, 10000000);

            effect.SetViewProjectionMatrix(MyCamera.ViewMatrix * projection);
            effect.SetSunDirection(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());
            MyCamera.SetupBaseEffect(effect);

            foreach (MyVoxelMapImpostorGroup group in m_voxelMapImpostorGroups)
            {
                group.Draw(effect, MyImpostorType.Billboards);
            }

            BlendState.NonPremultiplied.Apply();

            foreach (MyVoxelMapImpostorGroup group in m_voxelMapImpostorGroups)
            {
                group.Draw(effect, MyImpostorType.Nebula);
            }
        }
Beispiel #3
0
        public void Draw(MyEffectDistantImpostors effect)
        {
            int trianglesCount = m_impostors.Count * MyDistantObjectsImpostorsConstants.TRIANGLES_PER_IMPOSTOR;

            if (trianglesCount <= 0)
            {
                return;
            }

            CopyToVertexBuffer();

            Device device = MyMinerGame.Static.GraphicsDevice;

            RasterizerState.CullNone.Apply();
            BlendState.NonPremultiplied.Apply();
            DepthStencilState.None.Apply();

            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyCamera.Zoom.GetFOV(), MyCamera.ForwardAspectRatio, 1000, 10000000);

            effect.SetWorldMatrix(Matrix.CreateTranslation(-MyCamera.Position));
            effect.SetViewProjectionMatrix(MyCamera.ViewMatrix * projection);
            effect.SetSunDirection(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());

            for (int i = 0; i < m_impostorProperties.Length; i++)
            {
                effect.SetImpostorTexture(m_impostorProperties[i].Texture);
                effect.SetTechnique(m_impostorProperties[i].LitBySun ? MyEffectDistantImpostors.Technique.ColoredLit : MyEffectDistantImpostors.Technique.Colored);
                device.DrawUserPrimitives(PrimitiveType.TriangleList, m_impostorProperties[i].IndexStart, MyVoxelMapImpostorsConstants.TRIANGLES_PER_IMPOSTOR * m_impostorProperties[i].Count, m_vertices);
            }
        }
        public void Draw(MyEffectDistantImpostors effect)
        {
            LoadInDraw();

            Device device = MyRender.GraphicsDevice;

            RasterizerState.CullNone.Apply();
            MyStateObjects.NonPremultiplied_NoAlphaWrite_BlendState.Apply();
            MyStateObjects.DistantImpostorsDepthStencilState.Apply();


            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyRenderCamera.FieldOfView, MyRenderCamera.AspectRatio, 1000, 10000000);

            effect.SetViewProjectionMatrix((Matrix)(MyRenderCamera.ViewMatrix * projection));
            effect.SetSunDirection(MyRender.Sun.Direction);
            MyRenderCamera.SetupBaseEffect(effect, MyLodTypeEnum.LOD0);

            foreach (MyVoxelMapImpostorGroup group in m_voxelMapImpostorGroups)
            {
                group.Draw(effect, MyImpostorType.Billboards);
            }

            BlendState.NonPremultiplied.Apply();

            foreach (MyVoxelMapImpostorGroup group in m_voxelMapImpostorGroups)
            {
                group.Draw(effect, MyImpostorType.Nebula);
            }
        }
            public void PrepareForDraw(MyEffectDistantImpostors effect)
            {
                if (!ImpostorProperties.Enabled)
                {
                    return;
                }

                if (ImpostorProperties.ImpostorType == MyImpostorType.Nebula)
                {
                    Matrix mat = Matrix.CreateScale(ImpostorProperties.MinDistance) * Matrix.CreateTranslation((Vector3)MyRenderCamera.Position * 0.5f);

                    Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyRenderCamera.FieldOfView, MyRenderCamera.AspectRatio, 1000, 10000000);

                    effect.SetWorldMatrix(mat);
                    effect.SetViewProjectionMatrix((Matrix)(MyRenderCamera.ViewMatrix * projection));
                    effect.SetScale(ImpostorProperties.MaxRadius * 0.00018f);
                    effect.SetColor(ImpostorProperties.Color);

                    effect.SetContrastAndIntensity(new Vector2(ImpostorProperties.Contrast, ImpostorProperties.Intensity));
                    effect.SetAnimation(m_animationTime);
                    effect.SetCameraPos((Vector3)MyRenderCamera.Position);
                    effect.SetSunDirection(MyRender.Sun.Direction);

                    effect.SetTechnique(MyEffectDistantImpostors.Technique.Textured3D);

                    /* //todo missing texcoord0
                     * effect.Begin();
                     * MySimpleObjectDraw.ModelSphere.Render();
                     * effect.End(); */
                }
            }
        public void PrepareForDraw(MyEffectDistantImpostors effect)
        {
            RasterizerState.CullClockwise.Apply();
            BlendState.Opaque.Apply();
            MyMinerGame.SetRenderTarget(MyRender.GetRenderTarget(MyRenderTargets.AuxiliaryHalf0), null);

            foreach (MyVoxelMapImpostorGroup group in m_voxelMapImpostorGroups)
            {
                group.PrepareForDraw(effect);
            }
        }
        public void Draw(MyEffectDistantImpostors effect)
        {
            int trianglesCount = m_impostors.Count * MyDistantObjectsImpostorsConstants.TRIANGLES_PER_IMPOSTOR;

            if (trianglesCount <= 0)
            {
                return;
            }

            CopyToVertexBuffer();

            Device device = MyRender.GraphicsDevice;

            RasterizerState.CullNone.Apply();
            BlendState.NonPremultiplied.Apply();
            DepthStencilState.None.Apply();

            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyRenderCamera.FieldOfView, MyRenderCamera.AspectRatio, 1000, 10000000);

            effect.SetWorldMatrix((Matrix)MatrixD.CreateTranslation(-MyRenderCamera.Position));
            effect.SetViewProjectionMatrix((Matrix)MyRenderCamera.ViewMatrix * projection);
            effect.SetSunDirection(MyRender.Sun.Direction);

            device.VertexDeclaration = MyVertexFormatPositionTextureColor.VertexDeclaration;



            for (int i = 0; i < m_impostorProperties.Length; i++)
            {
                effect.SetImpostorTexture(m_impostorProperties[i].Texture);
                effect.SetTechnique(m_impostorProperties[i].LitBySun ? MyEffectDistantImpostors.Technique.ColoredLit : MyEffectDistantImpostors.Technique.Colored);
                effect.Begin();
                device.DrawUserPrimitives(PrimitiveType.TriangleList, m_impostorProperties[i].IndexStart, MyVoxelMapImpostorsConstants.TRIANGLES_PER_IMPOSTOR * m_impostorProperties[i].Count, m_vertices);
                effect.End();
            }
        }
            public void Draw(MyEffectDistantImpostors effect, MyImpostorType impostorType)
            {
                if (!ImpostorProperties.Enabled)
                {
                    return;
                }

                if (impostorType != ImpostorProperties.ImpostorType)
                {
                    return;
                }

                if (ImpostorProperties.ImpostorType == MyImpostorType.Billboards)
                {
                    if (m_trianglesCount <= 0)
                    {
                        return;
                    }

                    m_animationTime += ImpostorProperties.AnimationSpeed;

                    Device device = MyMinerGame.Static.GraphicsDevice;

                    if (MyRenderConstants.RenderQualityProfile.ForwardRender)
                    {
                        DepthStencilState.DepthRead.Apply();
                    }

                    Matrix worldMatrix = Matrix.Identity;

                    if (ImpostorProperties.AnimationSpeed.X > 0)
                    {
                        worldMatrix *= Matrix.CreateRotationX(m_animationTime.X);
                    }
                    if (ImpostorProperties.AnimationSpeed.Y > 0)
                    {
                        worldMatrix *= Matrix.CreateRotationX(m_animationTime.Y);
                    }
                    if (ImpostorProperties.AnimationSpeed.Z > 0)
                    {
                        worldMatrix *= Matrix.CreateRotationX(m_animationTime.Z);
                    }

                    worldMatrix.Translation = MyCamera.Position * 0.5f;
                    effect.SetWorldMatrix(worldMatrix);

                    MyTexture2D texture = null;
                    if (ImpostorProperties.Material.HasValue)
                    {
                        texture = MyTransparentGeometry.GetTexture(ImpostorProperties.Material.Value);
                    }
                    effect.SetImpostorTexture(texture);
                    device.SetStreamSource(0, m_vertexBuffer, 0, MyVertexFormatPositionTextureColor.Stride);
                    device.VertexDeclaration = MyVertexFormatPositionTextureColor.VertexDeclaration;

                    effect.SetTechnique(MyEffectDistantImpostors.Technique.ColoredLit);

                    effect.Begin();
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_trianglesCount);
                    effect.End();
                    MyPerformanceCounter.PerCameraDraw.TotalDrawCalls++;
                }
                else if (ImpostorProperties.ImpostorType == MyImpostorType.Nebula && !MyRenderConstants.RenderQualityProfile.ForwardRender)
                {
                    m_animationTime += ImpostorProperties.AnimationSpeed * (MyFpsManager.FrameTime / 100.0f);

                    BlendState.NonPremultiplied.Apply();
                    RasterizerState.CullCounterClockwise.Apply();
                    DepthStencilState.None.Apply();

                    MyRender.Blit(MyRender.GetRenderTarget(MyRenderTargets.AuxiliaryHalf0), true);
                }
            }