Exemplo n.º 1
0
        /// <summary>
        /// Render method is called directly by renderer. Depending on stage, post process can do various things
        /// </summary>
        /// <param name="postProcessStage">Stage indicating in which part renderer currently is.</param>public override void RenderAfterBlendLights()
        public override Texture Render(PostProcessStage postProcessStage, Texture source, Texture availableRenderTarget)
        {
            switch (postProcessStage)
            {
            case PostProcessStage.AlphaBlended:
            {
                MyRender.SetRenderTarget(availableRenderTarget, null);
                MyEffectContrast effectContrast = MyRender.GetEffect(MyEffects.Contrast) as MyEffectContrast;


                effectContrast.SetDiffuseTexture(source);
                effectContrast.SetHalfPixel(MyUtilsRender9.GetHalfPixel(source.GetLevelDescription(0).Width, source.GetLevelDescription(0).Height));
                effectContrast.SetContrast(Contrast);
                effectContrast.SetHue(Hue);
                effectContrast.SetSaturation(Saturation);

                MyRender.GetFullscreenQuad().Draw(effectContrast);

                return(availableRenderTarget);
            }
            break;
            }

            return(source);
        }
Exemplo n.º 2
0
        public void SetHalfPixel(int screenSizeX, int screenSizeY)
        {
            Vector2 halfPixel = MyUtilsRender9.GetHalfPixel(screenSizeX, screenSizeY);

            m_D3DEffect.SetValue(m_halfPixel, halfPixel);
            m_D3DEffect.SetValue(m_fullPixel, 2.0f * halfPixel);
        }
Exemplo n.º 3
0
 public void SetHalfPixel(int screenSizeX, int screenSizeY)
 {
     if (m_screenSizeXLocal != screenSizeX || m_screenSizeYLocal != screenSizeY)
     {
         m_D3DEffect.SetValue(m_halfPixel, MyUtilsRender9.GetHalfPixel(screenSizeX, screenSizeY));
         m_screenSizeXLocal = screenSizeX;
         m_screenSizeYLocal = screenSizeY;
     }
 }
Exemplo n.º 4
0
 public void SetHalfPixel(int screenSizeX, int screenSizeY)
 {
     m_D3DEffect.SetValue(m_halfPixel, MyUtilsRender9.GetHalfPixel(screenSizeX, screenSizeY));
 }
 public void SetDepthRT(Texture depthRT)
 {
     m_D3DEffect.SetTexture(m_depthRT, depthRT);
     m_D3DEffect.SetValue(m_halfPixel, MyUtilsRender9.GetHalfPixel(depthRT.GetLevelDescription(0).Width, depthRT.GetLevelDescription(0).Height));
 }
Exemplo n.º 6
0
        public void SetHalfPixelAndScale(int screenSizeX, int screenSizeY, Vector2 scale)
        {
            Vector2 halfPixel = MyUtilsRender9.GetHalfPixel(screenSizeX, screenSizeY);

            m_D3DEffect.SetValue(m_halfPixelAndScale, new Vector4(halfPixel.X, halfPixel.Y, scale.X, scale.Y));
        }
Exemplo n.º 7
0
        public static void Draw()
        {
            if (!Visible)
            {
                return;
            }

            MyRenderModel model = MyRenderModels.GetModel(Model);//MySession.Static.PlayerShip.CockpitGlassModelEnum);

            RasterizerState.CullNone.Apply();

            MyStateObjects.DepthStencil_StencilReadOnly.Apply();

            BlendState.NonPremultiplied.Apply();

            MyEffectCockpitGlass effect = (MyEffectCockpitGlass)MyRender.GetEffect(MyEffects.CockpitGlass);

            effect.SetGlassDirtLevelAlpha(new Vector4(GlassDirtAlpha, 0, 0, 0));

            var     inMatrix = PlayerHeadForCockpitInteriorWorldMatrix;
            MatrixD drawMatrix;

            MatrixD.Multiply(ref inMatrix, ref MyRenderCamera.InversePositionTranslationMatrix, out drawMatrix);

            effect.SetWorldMatrix((Matrix)drawMatrix);
            effect.SetViewMatrix((Matrix)MyRenderCamera.ViewMatrix);

            Matrix projection = MyRenderCamera.ProjectionMatrixForNearObjects;

            effect.SetWorldViewProjectionMatrix((Matrix)(drawMatrix * MyRenderCamera.ViewMatrixAtZero * projection));

            MyRenderMeshMaterial cockpitMaterial = model.GetMeshList()[0].Material;

            cockpitMaterial.PreloadTexture();
            effect.SetCockpitGlassTexture(cockpitMaterial.DiffuseTexture);

            Texture depthRT = MyRender.GetRenderTarget(MyRenderTargets.Depth);

            effect.SetDepthTexture(depthRT);

            effect.SetHalfPixel(MyUtilsRender9.GetHalfPixel(depthRT.GetLevelDescription(0).Width, depthRT.GetLevelDescription(0).Height));

            Vector4 sunColor = MyRender.Sun.Color;

            effect.SetSunColor(new Vector3(sunColor.X, sunColor.Y, sunColor.Z));

            effect.SetDirectionToSun(-MyRender.Sun.Direction);

            effect.SetAmbientColor(Vector3.Zero);
            effect.SetReflectorPosition((Vector3)((Vector3)MyRenderCamera.Position - 4 * MyRenderCamera.ForwardVector));

            if (MyRender.RenderLightsForDraw.Count > 0)
            {
                effect.SetNearLightColor(MyRender.RenderLightsForDraw[0].Color);
                effect.SetNearLightRange(MyRender.RenderLightsForDraw[0].Range);
            }

            MyRender.GetShadowRenderer().SetupShadowBaseEffect(effect);
            effect.SetShadowBias(0.001f);

            MyLights.UpdateEffect(effect, true);

            effect.Begin();
            model.Render();
            effect.End();

            //MyDebugDraw.DrawSphereWireframe(PlayerHeadForCockpitInteriorWorldMatrix, Vector3.One, 1);
        }
Exemplo n.º 8
0
 public void SetHalfPixel(int width, int height)
 {
     m_D3DEffect.SetValue(m_halfPixel, MyUtilsRender9.GetHalfPixel(width, height));
 }
Exemplo n.º 9
0
 public void SetSourceTexture(Texture renderTarget2D)
 {
     m_D3DEffect.SetTexture(m_source, renderTarget2D);
     m_D3DEffect.SetValue(m_halfPixel, MyUtilsRender9.GetHalfPixel(renderTarget2D.GetLevelDescription(0).Width, renderTarget2D.GetLevelDescription(0).Height));
 }
Exemplo n.º 10
0
        public void SetDiffuseTexture(Texture dt)
        {
            m_D3DEffect.SetTexture(m_diffuseTexture, dt);

            SetHalfPixel(MyUtilsRender9.GetHalfPixel(dt.GetLevelDescription(0).Width, dt.GetLevelDescription(0).Height));
        }
Exemplo n.º 11
0
 public void SetEnvironmentMap(CubeTexture environmentMap)
 {
     m_D3DEffect.SetTexture(m_environmentMap, environmentMap);
     m_D3DEffect.SetValue(m_halfPixel, MyUtilsRender9.GetHalfPixel(environmentMap.GetLevelDescription(0).Width, environmentMap.GetLevelDescription(0).Height));
 }