public void DrawTextureToTarget( Texture2D texture, LightMapSize mapSize, BlendTechnique blend) { var techniqueName = ""; switch (blend) { case BlendTechnique.Add: techniqueName = "TextureToTarget_Add"; break; case BlendTechnique.Multiply: techniqueName = "TextureToTarget_Multiply"; break; default: throw new ArgumentOutOfRangeException(nameof(blend), blend, null); } var biasFactor = BiasFactorFromLightMapSize(mapSize); var texelBias = new Vector2 { X = biasFactor / GraphicsDevice.ScissorRectangle.Width, Y = biasFactor / GraphicsDevice.ScissorRectangle.Height, }; Effect.Parameters["Texture0"].SetValue(texture); Effect.Parameters["TexelBias"].SetValue(texelBias); Effect.CurrentTechnique = Effect.Techniques[techniqueName]; foreach (var effectPass in Effect.CurrentTechnique.Passes) { effectPass.Apply(); GraphicsDevice.DrawUserPrimitives( primitiveType: PrimitiveType.TriangleStrip, vertexData: UnitQuad, vertexOffset: 0, primitiveCount: 2); } }
public void DrawTextureToTarget(Texture2D texture, LightMapSize mapSize, BlendTechnique blend) { // Get the technique to use string techniqueName = ""; switch (blend) { case (BlendTechnique.Add): techniqueName = "TextureToTarget_Add"; break; case (BlendTechnique.Multiply): techniqueName = "TextureToTarget_Multiply"; break; } var biasFactor = KryptonRenderHelper.BiasFactorFromLightMapSize(mapSize); // Calculate the texel bias Vector2 texelBias = new Vector2() { X = biasFactor / this.mGraphicsDevice.ScissorRectangle.Width, Y = biasFactor / this.mGraphicsDevice.ScissorRectangle.Height, }; this.mEffect.Parameters["Texture0"].SetValue(texture); this.mEffect.Parameters["TexelBias"].SetValue(texelBias); this.mEffect.CurrentTechnique = this.mEffect.Techniques[techniqueName]; // Draw the quad foreach (var effectPass in this.mEffect.CurrentTechnique.Passes) { effectPass.Apply(); this.mGraphicsDevice.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleStrip, KryptonRenderHelper.UnitQuad, 0, 2); } }
public void DrawTextureToTarget(Texture2D texture, LightMapSize mapSize, BlendTechnique blend) { // Get the technique to use string techniqueName = ""; switch (blend) { case(BlendTechnique.Add): techniqueName = "TextureToTarget_Add"; break; case(BlendTechnique.Multiply): techniqueName = "TextureToTarget_Multiply"; break; } var biasFactor = KryptonRenderHelper.BiasFactorFromLightMapSize(mapSize); // Calculate the texel bias Vector2 texelBias = new Vector2() { X = biasFactor / this.mGraphicsDevice.ScissorRectangle.Width, Y = biasFactor / this.mGraphicsDevice.ScissorRectangle.Height, }; this.mEffect.Parameters["Texture0"].SetValue(texture); this.mEffect.Parameters["TexelBias"].SetValue(texelBias); this.mEffect.CurrentTechnique = this.mEffect.Techniques[techniqueName]; // Draw the quad foreach (var effectPass in this.mEffect.CurrentTechnique.Passes) { effectPass.Apply(); this.mGraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleStrip, KryptonRenderHelper.UnitQuad, 0, 2); } }