/// <summary> /// Function called when the effect is being initialized. /// </summary> /// <remarks> /// Use this method to set up the effect upon its creation. For example, this method could be used to create the required shaders for the effect. /// <para>When creating a custom effect, use this method to initialize the effect. Do not put initialization code in the effect constructor.</para> /// </remarks> protected override void OnInitialize() { base.OnInitialize(); _point = Gorgon2D.Renderables.CreatePoint("Effect.OldFilm.DustPoint", Vector2.Zero, GorgonColor.Black); // Create pixel shader. Passes[0].PixelShader = Graphics.Shaders.CreateShader <GorgonPixelShader>("Effect.OldFilm.PS", "GorgonPixelShaderFilmGrain", Encoding.UTF8.GetString(Resources.FilmGrain)); _timingBuffer = Graphics.Buffers.CreateConstantBuffer("Effect.OldFilm.TimingBuffer", new GorgonConstantBufferSettings { SizeInBytes = 16 }); _scratchBuffer = Graphics.Buffers.CreateConstantBuffer("Effect.OldFilm.ScratchSettingsBuffer", new GorgonConstantBufferSettings { SizeInBytes = DirectAccess.SizeOf <ScratchSettings>() }); _sepiaBuffer = Graphics.Buffers.CreateConstantBuffer("Effect.OldFilm.SepaSettingsBuffer", new GorgonConstantBufferSettings { SizeInBytes = DirectAccess.SizeOf <SepiaSettings>() }); DirtPercent = 5; DirtAmount = 10; _scratchSettings = new ScratchSettings { ScratchIntensity = 0.49f, ScratchScrollSpeed = 0.01f, ScratchVisibleTime = 0.003f, ScratchWidth = 0.01f }; _sepiaSettings = new SepiaSettings { SepiaDesaturationAmount = 0.0f, SepiaToneAmount = 0.5f, SepiaLightColor = new GorgonColor(1, 0.9f, 0.65f, 1.0f), SepiaDarkColor = new GorgonColor(0.2f, 0.102f, 0, 1.0f) }; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonDrawing"/> class. /// </summary> /// <param name="gorgon2D">The gorgon 2D interface that owns this object.</param> internal GorgonDrawing(Gorgon2D gorgon2D) { _depthStencil = new GorgonRenderable.DepthStencilStates(); _sampler = new GorgonRenderable.TextureSamplerState(); _blend = new GorgonRenderable.BlendState(); // Default to modulated blending for drawing operations. BlendingMode = BlendingMode.Modulate; CullingMode = CullingMode.Back; _rect = new GorgonRectangle(gorgon2D, "Gorgon2D.Rectangle", false) { Position = Vector2.Zero, Size = Vector2.Zero }; _point = new GorgonPoint(gorgon2D, "Gorgon2D.Point") { Position = Vector2.Zero, Color = GorgonColor.White }; _line = new GorgonLine(gorgon2D, "Gorgon2D.Line") { Color = GorgonColor.White, StartPoint = Vector2.Zero, EndPoint = Vector2.Zero }; _ellipse = new GorgonEllipse(gorgon2D, "Gorgon2D.Ellipse") { Quality = 64, Color = GorgonColor.White }; _triangle = new GorgonTriangle(gorgon2D, "Gorgon2D.Triangle") { IsFilled = false }; _string = gorgon2D.Renderables.CreateText("Gorgon2D.String"); }