public static void Draw() { if (!CanDrawCockpit()) { return; } MyModel model = MyModels.GetModelForDraw(MySession.PlayerShip.CockpitGlassModelEnum); RasterizerState.CullNone.Apply(); if (MyRenderConstants.RenderQualityProfile.ForwardRender) { DepthStencilState.DepthRead.Apply(); } else { MyStateObjects.DepthStencil_StencilReadOnly.Apply(); } BlendState.NonPremultiplied.Apply(); MyEffectCockpitGlass effect = (MyEffectCockpitGlass)MyRender.GetEffect(MyEffects.CockpitGlass); float glassDirtAlpha = MathHelper.Lerp(MyCockpitGlassConstants.GLASS_DIRT_MIN, MyCockpitGlassConstants.GLASS_DIRT_MAX, MySession.PlayerShip.GlassDirtLevel); effect.SetGlassDirtLevelAlpha(new Vector4(glassDirtAlpha, 0, 0, 0)); effect.SetWorldMatrix(MySession.PlayerShip.PlayerHeadForCockpitInteriorWorldMatrix); effect.SetViewMatrix(MyCamera.ViewMatrix); if (!MyRenderConstants.RenderQualityProfile.ForwardRender) { Matrix projection = MyCamera.ProjectionMatrixForNearObjects; effect.SetWorldViewProjectionMatrix(MySession.PlayerShip.PlayerHeadForCockpitInteriorWorldMatrix * MyCamera.ViewMatrixAtZero * projection); } else { effect.SetWorldViewProjectionMatrix(MySession.PlayerShip.PlayerHeadForCockpitInteriorWorldMatrix * MyCamera.ViewProjectionMatrixAtZero); } MyMeshMaterial cockpitMaterial = model.GetMeshList()[0].Materials[0]; cockpitMaterial.PreloadTexture(); effect.SetCockpitGlassTexture(cockpitMaterial.DiffuseTexture); if (!MyRenderConstants.RenderQualityProfile.ForwardRender) { Texture depthRT = MyRender.GetRenderTarget(MyRenderTargets.Depth); effect.SetDepthTexture(depthRT); effect.SetHalfPixel(MyUtils.GetHalfPixel(depthRT.GetLevelDescription(0).Width, depthRT.GetLevelDescription(0).Height)); } Vector4 sunColor = MySunWind.GetSunColor(); effect.SetSunColor(new Vector3(sunColor.X, sunColor.Y, sunColor.Z)); effect.SetDirectionToSun(MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized()); effect.SetAmbientColor(Vector3.Zero); effect.SetReflectorPosition(MyCamera.Position - 4 * MySession.PlayerShip.WorldMatrix.Forward); if (MySession.PlayerShip.Light != null) { effect.SetNearLightColor(MySession.PlayerShip.Light.Color); effect.SetNearLightRange(MySession.PlayerShip.Light.Range); } MyRender.GetShadowRenderer().SetupShadowBaseEffect(effect); effect.SetShadowBias(0.001f); m_boundingSphereForLights.Center = MySession.PlayerShip.GetPosition(); MyLights.UpdateEffect(effect, ref m_boundingSphereForLights, true); effect.Begin(); model.Render(); effect.End(); MyCockpitGlassDecals.Draw(effect); }
private void SetRenderSetup() { return; m_setup = new MyRender.MyRenderSetup(); //m_setup.Fov = MathHelper.ToRadians(75); m_setup.CallerID = MyRenderCallerEnum.GUIPreview; m_setup.RenderTargets = new Texture[1]; m_setup.EnabledModules = new HashSet <MyRenderModuleEnum>(); m_setup.EnabledModules.Add(MyRenderModuleEnum.VoxelHand); m_setup.EnabledModules.Add(MyRenderModuleEnum.Decals); m_setup.EnabledModules.Add(MyRenderModuleEnum.CockpitWeapons); m_setup.EnabledModules.Add(MyRenderModuleEnum.SectorBorder); m_setup.EnabledModules.Add(MyRenderModuleEnum.DrawSectorBBox); m_setup.EnabledModules.Add(MyRenderModuleEnum.DrawCoordSystem); m_setup.EnabledModules.Add(MyRenderModuleEnum.Explosions); m_setup.EnabledModules.Add(MyRenderModuleEnum.BackgroundCube); m_setup.EnabledModules.Add(MyRenderModuleEnum.GPS); m_setup.EnabledModules.Add(MyRenderModuleEnum.TestField); m_setup.EnabledModules.Add(MyRenderModuleEnum.AnimatedParticles); m_setup.EnabledModules.Add(MyRenderModuleEnum.Lights); m_setup.EnabledModules.Add(MyRenderModuleEnum.TransparentGeometryForward); m_setup.EnabledModules.Add(MyRenderModuleEnum.Projectiles); m_setup.EnabledModules.Add(MyRenderModuleEnum.DebrisField); m_setup.EnabledModules.Add(MyRenderModuleEnum.ThirdPerson); m_setup.EnabledModules.Add(MyRenderModuleEnum.Editor); m_setup.EnabledModules.Add(MyRenderModuleEnum.SolarObjects); m_setup.EnabledModules.Add(MyRenderModuleEnum.SolarMapGrid); m_setup.EnabledModules.Add(MyRenderModuleEnum.PrunningStructure); m_setup.EnabledModules.Add(MyRenderModuleEnum.SunWind); m_setup.EnabledModules.Add(MyRenderModuleEnum.IceStormWind); m_setup.EnabledModules.Add(MyRenderModuleEnum.PrefabContainerManager); m_setup.EnabledModules.Add(MyRenderModuleEnum.PhysicsPrunningStructure); m_setup.EnabledRenderStages = new HashSet <MyRenderStage>(); m_setup.EnabledRenderStages.Add(MyRenderStage.PrepareForDraw); m_setup.EnabledRenderStages.Add(MyRenderStage.Background); m_setup.EnabledRenderStages.Add(MyRenderStage.LODDrawStart); m_setup.EnabledRenderStages.Add(MyRenderStage.LODDrawEnd); m_setup.EnabledRenderStages.Add(MyRenderStage.AlphaBlendPreHDR); m_setup.EnabledRenderStages.Add(MyRenderStage.AlphaBlend); m_setup.EnabledPostprocesses = new HashSet <MyPostProcessEnum>(); m_setup.EnabledPostprocesses.Add(MyPostProcessEnum.VolumetricSSAO2); m_setup.EnabledPostprocesses.Add(MyPostProcessEnum.HDR); //m_setup.BackgroundColor = new Color(0.17f, 0.18f, .25f, 0.0f); m_setup.BackgroundColor = new Color(Vector4.Zero); m_setup.EnableHDR = false; m_setup.EnableSun = true; m_setup.ShadowRenderer = MyRender.GetShadowRenderer(); // Default shadow render m_setup.EnableSmallLights = true; m_setup.EnableDebugHelpers = false; m_setup.EnableEnvironmentMapping = false; m_setup.EnableOcclusionQueries = false; m_setup.LodTransitionNear = 20000; m_setup.LodTransitionFar = 21000; m_setup.LodTransitionBackgroundStart = 50000; m_setup.LodTransitionBackgroundStart = 51000; m_setup.RenderElementsToDraw = new List <MyRender.MyRenderElement>(); m_setup.TransparentRenderElementsToDraw = new List <MyRender.MyRenderElement>(); m_setup.LightsToUse = new List <MyLight>(); var fillLight = new MyLight(); fillLight.Start(MyLight.LightTypeEnum.PointLight, .5f * new Vector4(1, 0.95f, 0.8f, 1), 1, 119); // fill light m_setup.LightsToUse.Add(fillLight); var backLight = new MyLight(); backLight.Start(MyLight.LightTypeEnum.PointLight, .5f * new Vector4(1, 0.9f, 0.9f, 1), 1, 119); // back light m_setup.LightsToUse.Add(backLight); }
public override void RecreateControls(bool contructor) { Controls.Clear(); m_scale = 0.7f; AddCaption(new System.Text.StringBuilder("Render optimizations"), Color.Yellow.ToVector4()); MyGuiControlLabel label = new MyGuiControlLabel(this, new Vector2(0.01f, -m_size.Value.Y / 2.0f + 0.07f), null, new System.Text.StringBuilder("(press ALT to share focus)"), Color.Yellow.ToVector4(), MyGuiConstants.LABEL_TEXT_SCALE * 0.7f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP); Controls.Add(label); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f); m_currentPosition.Y += 0.01f; AddLabel(new StringBuilder("Optimizations"), Color.Yellow.ToVector4(), 1.2f); AddCheckBox(new StringBuilder("Show particles overdraw"), null, MemberHelper.GetMember(() => TransparentGeometry.MyTransparentGeometry.VisualiseOverdraw)); AddCheckBox(new StringBuilder("Enable stencil optimization"), null, MemberHelper.GetMember(() => MyRender.EnableStencilOptimization)); //AddCheckBox(new StringBuilder("Enable LOD blending"), null, MemberHelper.GetMember(() => MyRender.EnableLODBlending)); //AddCheckBox(new StringBuilder("Enable stencil optimization LOD1"), null, MemberHelper.GetMember(() => MyRender.EnableStencilOptimizationLOD1)); //AddCheckBox(new StringBuilder("Show stencil optimization"), null, MemberHelper.GetMember(() => MyRender.ShowStencilOptimization)); AddCheckBox(new StringBuilder("Respect cast shadows flag"), null, MemberHelper.GetMember(() => MyShadowRenderer.RespectCastShadowsFlags)); AddCheckBox(new StringBuilder("Multithreaded shadows"), MyRender.GetShadowRenderer(), MemberHelper.GetMember(() => MyRender.GetShadowRenderer().MultiThreaded)); AddCheckBox(new StringBuilder("Multithreaded entities prepare"), null, MemberHelper.GetMember(() => MyRender.EnableEntitiesPrepareInBackground)); m_currentPosition.Y += 0.01f; AddLabel(new StringBuilder("HW Occ queries"), Color.Yellow.ToVector4(), 1.2f); AddCheckBox(new StringBuilder("Enable"), null, MemberHelper.GetMember(() => MyRender.EnableHWOcclusionQueries)); AddCheckBox(new StringBuilder("Enable shadow occ.q."), null, MemberHelper.GetMember(() => MyRender.EnableHWOcclusionQueriesForShadows)); AddCheckBox(new StringBuilder("Show occ queries"), null, MemberHelper.GetMember(() => MyRender.ShowHWOcclusionQueries)); m_currentPosition.Y += 0.01f; AddLabel(new StringBuilder("Rendering"), Color.Yellow.ToVector4(), 1.2f); AddCheckBox(new StringBuilder("Alternative sort"), null, MemberHelper.GetMember(() => MyRender.AlternativeSort)); AddCheckBox(new StringBuilder("Skip LOD NEAR"), null, MemberHelper.GetMember(() => MyRender.SkipLOD_NEAR)); AddCheckBox(new StringBuilder("Skip LOD0"), null, MemberHelper.GetMember(() => MyRender.SkipLOD_0)); AddCheckBox(new StringBuilder("Skip LOD1"), null, MemberHelper.GetMember(() => MyRender.SkipLOD_1)); AddCheckBox(new StringBuilder("Skip Voxels"), null, MemberHelper.GetMember(() => MyRender.SkipVoxels)); AddCheckBox(new StringBuilder("Show render stats"), null, MemberHelper.GetMember(() => MyRender.ShowEnhancedRenderStatsEnabled)); AddCheckBox(new StringBuilder("Show resources stats"), null, MemberHelper.GetMember(() => MyRender.ShowResourcesStatsEnabled)); AddCheckBox(new StringBuilder("Show textures stats"), null, MemberHelper.GetMember(() => MyRender.ShowTexturesStatsEnabled)); AddCheckBox(new StringBuilder("Show entities stats"), null, MemberHelper.GetMember(() => MyEntities.ShowDebugDrawStatistics)); m_currentPosition.Y += 0.01f; AddLabel(new StringBuilder("Voxel Mesh reduction"), Color.Yellow.ToVector4(), 1.2f); var checkBox = AddCheckBox(new StringBuilder("Enable decimation"), null, MemberHelper.GetMember(() => MyFakes.SIMPLIFY_VOXEL_MESH)); checkBox.OnCheck += delegate(MyGuiControlCheckbox sender) { // just to trigger recalculation of voxel map MyMeshSimplifier.MinEdgeLength = MyMeshSimplifier.MinEdgeLength; RecreateControls(false); }; var slider = AddSlider(new StringBuilder("Min Edge Length"), 0, 30, null, MemberHelper.GetMember(() => MyMeshSimplifier.MinEdgeLength)); AddLabel(new StringBuilder("Voxel precalc time: " + MyMeshSimplifier.VoxelRecalcTime + " ms"), Color.Red.ToVector4(), 1.15f); slider.OnChange += delegate(MyGuiControlSlider sender) { RecreateControls(false); }; AddButton(new StringBuilder("Textures to Log"), delegate { MyTextureManager.DbgDumpLoadedTexturesBetter(); }); AddButton(new StringBuilder("Wrong entities to Log"), delegate { MyEntities.DumpWrongEntities(); }); AddButton(new StringBuilder("Dump all entities to Log"), delegate { MyRender.DumpAllEntities(); }); }