public static Image Create(Draw.Image image) { Image result = null; if (image is Raster.Image) { if (image is Raster.Bgra) result = new Bgra(image as Raster.Bgra); else if (image is Raster.Bgr) result = new Bgr(image as Raster.Bgr); else if (image is Raster.Monochrome) result = new Monochrome(image as Raster.Monochrome); else if (image is Raster.Yuv420) result = new Yuv420(image as Raster.Yuv420); else result = new Bgra(image.Convert<Raster.Bgra>()); } else if (image is Image) result = image.Copy() as Image; else if (image.NotNull()) result = new Bgra(image.Convert<Raster.Bgra>()); return result; }
public void Initialize() { //---------------------------------------------------------------- // グラフィックス設定 GraphicsSettings = LoadAsset <GraphicsSettings>("title:Resources/GraphicsSettings.json"); //---------------------------------------------------------------- // シーン設定 // TODO: ワールド設定としてどうするか再検討。 // いずれにせよ、SceneSettings はワールド設定と一対一。 SceneSettings = LoadAsset <SceneSettings>("title:Resources/SceneSettings.json"); //---------------------------------------------------------------- // シーン マネージャ設定 // TODO: リソースから取得する。 SceneManagerSettings = new SceneManager.Settings(); //---------------------------------------------------------------- // シーン マネージャ SceneManager = new SceneManager(SceneManagerSettings, GraphicsDevice); // 太陽と月をディレクショナル ライトとして登録。 SceneManager.DirectionalLights.Add(SceneSettings.Sunlight); SceneManager.DirectionalLights.Add(SceneSettings.Moonlight); // シャドウ マップ if (GraphicsSettings.ShadowMapEnabled) { var shadowMapEffect = LoadAsset <Effect>("content:Effects/ShadowMap"); var blurEffect = LoadAsset <Effect>("content:Effects/GaussianBlur"); ShadowMap = new ShadowMap(GraphicsDevice, GraphicsSettings.ShadowMap, spriteBatch, shadowMapEffect, blurEffect); SceneManager.ShadowMap = ShadowMap; } // レンズ フレア if (GraphicsSettings.LensFlareEnabled) { var glowSpite = LoadAsset <Texture2D>("content:Textures/LensFlare/Glow"); Texture2D[] flareSprites = { LoadAsset <Texture2D>("content:Textures/LensFlare/Flare1"), LoadAsset <Texture2D>("content:Textures/LensFlare/Flare2"), LoadAsset <Texture2D>("content:Textures/LensFlare/Flare3") }; LensFlare = new LensFlare(GraphicsDevice, spriteBatch, glowSpite, flareSprites); SceneManager.LensFlare = LensFlare; } // スクリーン スペース シャドウ マッピング if (GraphicsSettings.SssmEnabled) { // スクリーン スペース シャドウ マッピング モジュール var shadowSceneEffect = LoadAsset <Effect>("content:Effects/ShadowScene"); var sssmEffect = LoadAsset <Effect>("content:Effects/Sssm"); var blurEffect = LoadAsset <Effect>("content:Effects/GaussianBlur"); Sssm = new Sssm(spriteBatch, GraphicsSettings.ShadowMap, GraphicsSettings.Sssm, shadowSceneEffect, sssmEffect, blurEffect); Sssm.ShadowColor = SceneSettings.ShadowColor; SceneManager.PostProcessors.Add(Sssm); // SSSM は直接的なシャドウ描画を回避しなければならないため明示。 SceneManager.SssmEnabled = true; } // スクリーン スペース アンビエント オクルージョン if (GraphicsSettings.SsaoEnabled) { var normalDepthMapEffect = LoadAsset <Effect>("content:Effects/NormalDepthMap"); var ssaoMapEffect = LoadAsset <Effect>("content:Effects/SsaoMap"); var blurEffect = LoadAsset <Effect>("content:Effects/SsaoMapBlur"); var ssaoEffect = LoadAsset <Effect>("content:Effects/Ssao"); var randomNormalMap = LoadAsset <Texture2D>("content:Textures/RandomNormal"); Ssao = new Ssao(spriteBatch, GraphicsSettings.Ssao, normalDepthMapEffect, ssaoMapEffect, blurEffect, ssaoEffect, randomNormalMap); SceneManager.PostProcessors.Add(Ssao); } // エッジ強調 if (GraphicsSettings.EdgeEnabled) { var normalDepthMapEffect = LoadAsset <Effect>("content:Effects/NormalDepthMap"); var edgeEffect = LoadAsset <Effect>("content:Effects/Edge"); Edge = new Edge(spriteBatch, GraphicsSettings.Edge, normalDepthMapEffect, edgeEffect); SceneManager.PostProcessors.Add(Edge); } // ブルーム if (GraphicsSettings.BloomEnabled) { var bloomExtractEffect = LoadAsset <Effect>("content:Effects/BloomExtract"); var bloomEffect = LoadAsset <Effect>("content:Effects/Bloom"); var blurEffect = LoadAsset <Effect>("content:Effects/GaussianBlur"); Bloom = new Bloom(spriteBatch, GraphicsSettings.Bloom, bloomExtractEffect, bloomEffect, blurEffect); SceneManager.PostProcessors.Add(Bloom); } // 被写界深度 if (GraphicsSettings.DofEnabled) { var depthMapEffect = LoadAsset <Effect>("content:Effects/DepthMap"); var dofEffect = LoadAsset <Effect>("content:Effects/Dof"); var blurEffect = LoadAsset <Effect>("content:Effects/GaussianBlur"); Dof = new Dof(spriteBatch, GraphicsSettings.Dof, depthMapEffect, dofEffect, blurEffect); SceneManager.PostProcessors.Add(Dof); } // カラー オーバラップ if (GraphicsSettings.ColorOverlapEnabled) { ColorOverlap = new ColorOverlap(spriteBatch); SceneManager.PostProcessors.Add(ColorOverlap); } // モノクローム if (GraphicsSettings.MonochromeEnabled) { var monochromeEffect = LoadAsset <Effect>("content:Effects/Monochrome"); Monochrome = new Monochrome(spriteBatch, monochromeEffect); SceneManager.PostProcessors.Add(Monochrome); } // 走査線 if (GraphicsSettings.ScanlineEnabled) { var effect = LoadAsset <Effect>("content:Effects/Scanline"); Scanline = new Scanline(spriteBatch, effect); SceneManager.PostProcessors.Add(Scanline); } //---------------------------------------------------------------- // リージョン マネージャ RegionManager = new RegionManager(serviceProvider, SceneManager); RegionManager.Initialize(SceneSettings); // イベント ハンドラ // シャドウ マップ更新にあわせて、リージョン マネージャで管理しているエフェクトを準備する。 SceneManager.ShadowMapUpdated += RegionManager.OnShadowMapUpdated; //---------------------------------------------------------------- // チャンク マネージャ var chunkSettings = LoadAsset <ChunkSettings>("title:Resources/ChunkSettings.json"); ChunkManager = new ChunkManager(chunkSettings, GraphicsDevice, RegionManager, SceneManager); //---------------------------------------------------------------- // デフォルト カメラ //camera.View.Position = new Vector3(0, 16 * 18, 0); defaultCamera.View.Position = new Vector3(0, 16 * 16, 0); //camera.View.Position = new Vector3(0, 16 * 3, 0); //camera.View.Position = new Vector3(0, 16 * 2, 0); //defaultCamera.Projection.Fov = MathHelper.ToRadians(90); defaultCamera.Projection.AspectRatio = GraphicsDevice.Viewport.AspectRatio; // 最大アクティブ範囲を超えない位置へ FarPlaneDistance を設定。 // パーティション (チャンク) のサイズを掛けておく。 var minChunkSize = Math.Min(chunkSettings.ChunkSize.X, chunkSettings.ChunkSize.Y); minChunkSize = Math.Min(minChunkSize, chunkSettings.ChunkSize.Z); defaultCamera.Projection.FarPlaneDistance = (chunkSettings.MaxActiveVolume - 1) * minChunkSize; // 念のためここで一度更新。 defaultCamera.Update(); // シーン マネージャへ登録してアクティブ化。 SceneManager.Cameras.Add(defaultCamera); SceneManager.ActiveCameraName = defaultCamera.Name; }
public override int GetHashCode() { int hash = 1; if (CameraDev.Length != 0) { hash ^= CameraDev.GetHashCode(); } if (FrameId.Length != 0) { hash ^= FrameId.GetHashCode(); } if (PixelFormat.Length != 0) { hash ^= PixelFormat.GetHashCode(); } if (IoMethod != 0) { hash ^= IoMethod.GetHashCode(); } if (Width != 0) { hash ^= Width.GetHashCode(); } if (Height != 0) { hash ^= Height.GetHashCode(); } if (FrameRate != 0) { hash ^= FrameRate.GetHashCode(); } if (Monochrome != false) { hash ^= Monochrome.GetHashCode(); } if (Brightness != 0) { hash ^= Brightness.GetHashCode(); } if (Contrast != 0) { hash ^= Contrast.GetHashCode(); } if (Saturation != 0) { hash ^= Saturation.GetHashCode(); } if (Sharpness != 0) { hash ^= Sharpness.GetHashCode(); } if (Gain != 0) { hash ^= Gain.GetHashCode(); } if (AutoFocus != false) { hash ^= AutoFocus.GetHashCode(); } if (Focus != 0) { hash ^= Focus.GetHashCode(); } if (AutoExposure != false) { hash ^= AutoExposure.GetHashCode(); } if (Exposure != 0) { hash ^= Exposure.GetHashCode(); } if (AutoWhiteBalance != false) { hash ^= AutoWhiteBalance.GetHashCode(); } if (WhiteBalance != 0) { hash ^= WhiteBalance.GetHashCode(); } if (BytesPerPixel != 0) { hash ^= BytesPerPixel.GetHashCode(); } if (TriggerInternal != 0) { hash ^= TriggerInternal.GetHashCode(); } if (TriggerFps != 0) { hash ^= TriggerFps.GetHashCode(); } if (ChannelName.Length != 0) { hash ^= ChannelName.GetHashCode(); } if (DeviceWaitMs != 0) { hash ^= DeviceWaitMs.GetHashCode(); } if (SpinRate != 0) { hash ^= SpinRate.GetHashCode(); } if (OutputType != 0) { hash ^= OutputType.GetHashCode(); } if (compressConf_ != null) { hash ^= CompressConf.GetHashCode(); } return(hash); }