Exemplo n.º 1
0
        public override void SetupEntity(MyEffectBase shader, MyRender.MyRenderElement renderElement)
        {
            MyEffectAtmosphere effectAtmosphere = shader as MyEffectAtmosphere;

            effectAtmosphere.SetWorldMatrix((Matrix)renderElement.WorldMatrixForDraw);
            effectAtmosphere.SetDiffuseColor(renderElement.Color);

            var atmosphere = renderElement.RenderObject as MyRenderAtmosphere;

            float depthScale = 0.2f;

            effectAtmosphere.SetInnerRadius(atmosphere.PlanetRadius);
            effectAtmosphere.SetOutherRadius(atmosphere.AtmosphereRadius);

            float scaleAtmosphere = 1.0f / (atmosphere.AtmosphereRadius - atmosphere.PlanetRadius);

            effectAtmosphere.SetScaleAtmosphere(scaleAtmosphere);
            effectAtmosphere.SetScaleAtmosphereOverScaleDepth(scaleAtmosphere / depthScale);

            Vector3 cameraToCenter = atmosphere.GetRelativeCameraPos(MyRenderCamera.Position);

            effectAtmosphere.SetRelativeCameraPos(cameraToCenter);

            effectAtmosphere.SetLightPos(-MySunGlare.GetSunDirection());
            effectAtmosphere.SetIsInside(atmosphere.IsInside(MyRenderCamera.Position));

            effectAtmosphere.SetScaleDepth(depthScale);

            effectAtmosphere.SetWavelength(atmosphere.AtmosphereWavelengths);
        }
        public override void SetupEntity(MyEffectBase shader, MyRender.MyRenderElement renderElement)
        {
            base.SetupEntity(shader, renderElement);

            var atmosphere = renderElement.RenderObject as MyRenderAtmosphere;

            if (atmosphere.IsInside(MyRenderCamera.Position))
            {
                MyEffectAtmosphere effectAtmosphere = shader as MyEffectAtmosphere;
                Matrix             optProjection    = Matrix.CreatePerspectiveFieldOfView(MyRenderCamera.FieldOfView, MyRenderCamera.AspectRatio, MyRenderCamera.NEAR_PLANE_DISTANCE, atmosphere.AtmosphereRadius * 2.0f / MyRenderAtmosphere.ATMOSPHERE_SCALE);
                effectAtmosphere.SetProjectionMatrix(ref optProjection);
            }
        }