private BloomEffect bloomEffect; //BloomEffect /// <summary> /// Effectを管理するクラス /// </summary> /// <param name="graphicsDevice">グラフィック機器</param> /// <param name="contents">コンテントマネージャー</param> public EffectManager(GraphicsDevice graphicsDevice, ContentManager contents) { this.graphicsDevice = graphicsDevice; basicEffect = new BasicEffect(graphicsDevice); miniMapEffect = new BasicEffect(graphicsDevice); basicEffect.VertexColorEnabled = true; //頂点色を有効 miniMapEffect.VertexColorEnabled = true; //頂点色を有効 currentEffect = basicEffect; blurEffect = new BlurEffect( //BlurEffectをShaderから読み取って生成する graphicsDevice, contents.Load <Effect>("./Effect/blur")); blurEffect.Initialize(); //初期化 polygonEffect = new PolygonEffect( contents.Load <Effect>("./Effect/polygon")); depthEffect = new DepthEffect( graphicsDevice, contents.Load <Effect>("./Effect/depth")); bloomEffect = new BloomEffect( graphicsDevice, contents.Load <Effect>("./Effect/hightLight"), contents.Load <Effect>("./Effect/bloom"), new BlurEffect( graphicsDevice, contents.Load <Effect>("./Effect/blur"))); }
public void init(int lvl) { this.lvl = lvl; gameObject.transform.localScale = new Vector3(1.1f, 1.1f, 1); sr = gameObject.AddComponent <SpriteRenderer> (); sr.material = new Material(Shader.Find("Custom/BloomShader")); sr.sprite = Resources.Load <Sprite> ("Sprites/UI/T_Wood"); be = gameObject.AddComponent <BloomEffect> (); coll = gameObject.AddComponent <BoxCollider2D> (); coll.isTrigger = true; textObj = new GameObject("Button Text"); textObj.transform.parent = transform; textObj.transform.localPosition = new Vector3(0, 0, -0.1f); tm = textObj.AddComponent <TextMesh>(); tm.text = GameManager.GetLevel(lvl).GetSceneName(); tm.color = Color.black; tm.font = UIManager.GetFont(); tm.alignment = TextAlignment.Center; tm.anchor = TextAnchor.MiddleCenter; tm.fontSize = 89; tm.characterSize = 0.05f; tm.GetComponent <Renderer>().material = UIManager.GetFont().material; }
protected override void InitializationProcess() { MainFramebuffer = CreateWindowFramebuffer(8, PixelInformation.RGBA_HDR, true); _postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false); Framebuffers.Add(_postBuffer); _bloom = new BloomEffect(true, true) { Radius = 20, AmountMap = new Texture(new System.Drawing.Bitmap("bloom_amountMap.png")) }; PostProcessEffects.Add(_bloom); _vittage = new STPostProcessEffect(Program.portal.DrawNodes.Find(a => a.Variables.ContainsKey("_ViewportSize"))) { Arguments = { { "CheckSize", 10f }, { "Strength", .25f }, { "TargetSize", 5f }, { "Move", 3.33f } } }; PostProcessEffects.Add(_vittage); }
public Bloom(SpriteBatch spriteBatch, Settings settings, Effect bloomExtractEffect, Effect bloomEffect, Effect blurEffect) : base(spriteBatch) { if (settings == null) throw new ArgumentNullException("settings"); if (bloomExtractEffect == null) throw new ArgumentNullException("bloomExtractEffect"); if (bloomEffect == null) throw new ArgumentNullException("bloomEffect"); if (blurEffect == null) throw new ArgumentNullException("blurEffect"); this.settings = settings; //---------------------------------------------------------------- // エフェクト this.bloomExtractEffect = new BloomExtractEffect(bloomExtractEffect); this.bloomEffect = new BloomEffect(bloomEffect); //---------------------------------------------------------------- // レンダ ターゲット var pp = GraphicsDevice.PresentationParameters; var width = (int) (pp.BackBufferWidth * settings.MapScale); var height = (int) (pp.BackBufferHeight * settings.MapScale); bloomExtractMap = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); //---------------------------------------------------------------- // ブラー blur = new GaussianBlur(blurEffect, spriteBatch, width, height, SurfaceFormat.Color, settings.Blur.Radius, settings.Blur.Amount); }
void Start() { var filter = GetComponent<MeshFilter>(); filter.mesh = CreateMesh(); bloom = Camera.main.GetComponent<BloomEffect>(); }
public static bool SetBloom(this Camera camera, float value, float duration = 0f) { BloomEffect bloom = camera.GetComponent <BloomEffect>(); if (bloom == null) { return(false); } bloom.SetEffectScale(value, duration); return(true); }
// Update internal state with a given bloom instance. public void Prepare(BloomEffect bloom) { _rangeX = 6; _rangeY = 1.5f; _threshold = bloom.thresholdLinear; _knee = bloom.softKnee * _threshold + 1e-5f; // Intensity is capped to prevent sampling errors. _intensity = Mathf.Min(bloom.intensity, 10); }
// Use this for initialization void Start() { blurEffect = camera.GetComponent <BlurEffect>(); bloomEffect = camera.GetComponent <BloomEffect>(); dofEffect = camera.GetComponent <DOFEffect>(); colorgradingEffect = camera.GetComponent <ColorGrading>(); tonemappingEffect = camera.GetComponent <Tonemapper>(); oilpaintingEffect = camera.GetComponent <OilPaintingEffect>(); aoEffect = camera.GetComponent <MSSAO>(); UpdateValues(); }
public void init(Sprite sprite, Action func) { this.func = func; sr = gameObject.AddComponent <SpriteRenderer> (); sr.material = new Material(Shader.Find("Custom/BloomShader")); sr.sprite = sprite; coll = gameObject.AddComponent <BoxCollider2D> (); coll.isTrigger = true; be = gameObject.AddComponent <BloomEffect> (); }
public Bloom(SpriteBatch spriteBatch, Settings settings, Effect bloomExtractEffect, Effect bloomEffect, Effect blurEffect) : base(spriteBatch) { if (settings == null) { throw new ArgumentNullException("settings"); } if (bloomExtractEffect == null) { throw new ArgumentNullException("bloomExtractEffect"); } if (bloomEffect == null) { throw new ArgumentNullException("bloomEffect"); } if (blurEffect == null) { throw new ArgumentNullException("blurEffect"); } this.settings = settings; //---------------------------------------------------------------- // エフェクト this.bloomExtractEffect = new BloomExtractEffect(bloomExtractEffect); this.bloomEffect = new BloomEffect(bloomEffect); //---------------------------------------------------------------- // レンダ ターゲット var pp = GraphicsDevice.PresentationParameters; var width = (int)(pp.BackBufferWidth * settings.MapScale); var height = (int)(pp.BackBufferHeight * settings.MapScale); bloomExtractMap = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); //---------------------------------------------------------------- // ブラー blur = new GaussianBlur(blurEffect, spriteBatch, width, height, SurfaceFormat.Color, settings.Blur.Radius, settings.Blur.Amount); }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. SpriteBatch = new SpriteBatch(GraphicsDevice); GameSettings = new GameSettings(this); Textures.LoadContent(Content); ParticleEngine = new ParticleEngine(); ParticleModifiers = new List <IEmitterModifier>(); Ripple = new RippleEffect(GraphicsDevice); Bloom = new BloomEffect(GraphicsDevice); ParticleTarget = new RenderTarget2D( GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); MainMenuState = new MainMenu(this); CurrentState = MainMenuState; Pixel = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); Pixel.SetData(new[] { Color.White }); }
protected override void LoadContent() { #region Effects bloomExtractEffect = EffectManager.Load<BloomExtractEffect>(); bloomEffect = EffectManager.Load<BloomEffect>(); #endregion #region Back buffers var pp = GraphicsDevice.PresentationParameters; var width = (int) (pp.BackBufferWidth * Settings.MapScale); var height = (int) (pp.BackBufferHeight * Settings.MapScale); bloomExtractMapBackBuffer = BackBufferManager.Load("BloomExtractMap"); bloomExtractMapBackBuffer.Width = width; bloomExtractMapBackBuffer.Height = height; bloomExtractMapBackBuffer.MipMap = false; bloomExtractMapBackBuffer.SurfaceFormat = pp.BackBufferFormat; bloomExtractMapBackBuffer.DepthFormat = DepthFormat.Depth24Stencil8; bloomExtractMapBackBuffer.MultiSampleCount = 0; bloomExtractMapBackBuffer.Enabled = Enabled; #endregion #region Gaussian blur gaussianBlur = new GaussianBlur(RenderContext, width, height, bloomExtractMapBackBuffer.SurfaceFormat); gaussianBlur.LoadContent(); gaussianBlur.Enabled = Enabled; #endregion base.LoadContent(); }
public BaseDeferredRenderGame() : base() { graphics = new GraphicsDeviceManager(this); graphics.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings); Content.RootDirectory = "Content"; inputHandler = new InputHandlerService(this); assetManager = new AssetManager(this); renderer = new DeferredRender(this); rnd = new Random(DateTime.Now.Millisecond); //ggr = new GeographicGridRegistrationSystem(this, new Vector3(10, 5, 20), new BoundingBox(-Vector3.One * 2f, Vector3.One * 2f)); ppManager = new PostProcessingManager(this); test = new TesterEffect(this); test.Enabled = false; ppManager.AddEffect(test); SSAO = new SSAOEffect(this, .1f, 1f, .5f, 1f); SSAO.Enabled = false; ppManager.AddEffect(SSAO); //stHPe = new STHardPointEffect(this, 25, 30, new Color(48, 89, 122)); stHPe = new STHardPointEffect(this, 25, 30, new Color(41, 77, 107), new Color(.125f, .125f, .125f, 1.0f)); stHPe.Enabled = false; ppManager.AddEffect(stHPe); sun = new SunEffect(this, SunPosition); sun.Enabled = false; ppManager.AddEffect(sun); water = new WaterEffect(this); water.waterHeight = -25f; water.Enabled = false; ppManager.AddEffect(water); dof = new DepthOfFieldEffect(this, 5, 30); dof.Enabled = false; ppManager.AddEffect(dof); bloom = new BloomEffect(this, 1.25f, 1f, 1f, 1f, .25f, 4f); bloom.Enabled = false; ppManager.AddEffect(bloom); haze = new HeatHazeEffect(this, "Textures/bumpmap", false); haze.Enabled = false; ppManager.AddEffect(haze); radialBlur = new RadialBlurEffect(this, 0.009f); radialBlur.Enabled = false; ppManager.AddEffect(radialBlur); ripple = new RippleEffect(this); ripple.Enabled = false; ppManager.AddEffect(ripple); fog = new FogEffect(this, 50, 100, Color.DarkSlateGray); fog.Enabled = false; ppManager.AddEffect(fog); godRays = new CrepuscularRays(this, SunPosition, "Textures/flare", 1500, 1f, .99f, 1f, .15f, .25f); //godRays = new CrepuscularRays(this, SunPosition, "Textures/flare", 1500, 1f, .99f, .1f, 0.12f, .25f); godRays.Enabled = false; ppManager.AddEffect(godRays); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.GraphicsProfile = GraphicsProfile.HiDef; graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; IsMouseVisible = true; kbm = new KeyboardStateManager(this); camera = new Base3DCamera(this, .5f, 20000); camera.Position = new Vector3(0, 0, 0); Components.Add(camera); Services.AddService(typeof(Base3DCamera), camera); skyBox = new BaseSkyBox(this, "Textures/SkyBox/NebulaBlue"); Components.Add(skyBox); bunny = new Base3DObject(this, "Models/bunny", "Shaders/RenderObjectNotTangentsOrTexCoords"); bunny.Position = new Vector3(2, -1.5f, -20); bunny.LightPosition = LightPosition; Components.Add(bunny); cube = new Base3DObject(this, "Models/cube"); cube.Position = new Vector3(0, 0, -10); cube.ColorAsset = "Textures/h2mcpCube"; cube.BumpAsset = "Textures/h2mcpCubeNormal"; cube.LightPosition = LightPosition; Components.Add(cube); bunnies = new Base3DObject[10]; for (int s = 0; s < 10; s++) { bunnies[s] = new Base3DObject(this, "Models/Bunny"); bunnies[s].Position = new Vector3(20 + (s * 12), -1.5f, -10 - (s * 12)); bunnies[s].ColorAsset = "Textures/WindmillTopColor"; bunnies[s].BumpAsset = "Textures/WindmillTopNormal"; bunnies[s].LightPosition = LightPosition; Components.Add(bunnies[s]); } landShark = new Base3DObject(this, "Models/landShark"); landShark.Position = new Vector3(-20, 0, -10); landShark.ColorAsset = "Textures/Speeder_diff"; landShark.BumpAsset = "Textures/Speeder_bump"; landShark.LightPosition = LightPosition; Components.Add(landShark); earth = new Base3DObject(this, "Models/sphere"); earth.Position = new Vector3(0, 0, -200); earth.ColorAsset = "Textures/Earth_Diffuse"; earth.BumpAsset = "Textures/Earth_NormalMap"; earth.LightPosition = LightPosition; Components.Add(earth); ppManager = new PostProcessingManager(this); fog = new FogEffect(this, 50, 100, Color.DarkSlateGray); fog.Enabled = false; ppManager.AddEffect(fog); GodRays = new CrepuscularRays(this, LightPosition, "Textures/flare", 1500, .99f, .99f, .5f, .12f, .25f); GodRays.Enabled = false; ppManager.AddEffect(GodRays); sun = new SunEffect(this, LightPosition); sun.Enabled = false; ppManager.AddEffect(sun); bloom = new BloomEffect(this, 1.25f, 1f, 1f, 1f, .25f, 4f); bloom.Enabled = false; ppManager.AddEffect(bloom); dof = new DepthOfFieldEffect(this, 5, 30); dof.Enabled = false; ppManager.AddEffect(dof); haze = new HeatHazeEffect(this, "Textures/bumpmap", false); haze.Enabled = false; ppManager.AddEffect(haze); radialBlur = new RadialBlurEffect(this, 0.009f); radialBlur.Enabled = false; ppManager.AddEffect(radialBlur); ripple = new RippleEffect(this); ripple.Enabled = false; ppManager.AddEffect(ripple); sepia = new SepiaEffect(this); sepia.Enabled = false; ppManager.AddEffect(sepia); greyScale = new GreyScaleEffect(this); greyScale.Enabled = false; ppManager.AddEffect(greyScale); invert = new InvertColorEffect(this); invert.Enabled = false; ppManager.AddEffect(invert); colorFilter = new ColorFilterEffect(this, Color.White, .5f, .5f, .5f); colorFilter.Enabled = false; ppManager.AddEffect(colorFilter); bleach = new BleachEffect(this, 1); bleach.Enabled = false; ppManager.AddEffect(bleach); scanLines = new ScanLinesEffect(this, .001f, .001f, 128); scanLines.Enabled = false; ppManager.AddEffect(scanLines); deRezed = new DeRezedEffect(this, 128); deRezed.Enabled = false; ppManager.AddEffect(deRezed); }