本文整理汇总了C#中Renderer.GetTransformMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.GetTransformMatrix方法的具体用法?C# Renderer.GetTransformMatrix怎么用?C# Renderer.GetTransformMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderer
的用法示例。
在下文中一共展示了Renderer.GetTransformMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginGaussianBlur
public static void BeginGaussianBlur(int radius, float viewportWidth, float viewportHeight, Renderer renderer)
{
if (radius < 1)
radius = 1;
if (renderer.IsDrawing)
renderer.End();
float[] pixelSize = new float[] { 1f / viewportWidth, 1f / viewportHeight };
if (radius > 5)
{
pixelSize[0] *= radius / 5;
pixelSize[1] *= radius / 5;
radius = 5;
}
//Pascal's triangle
float[] kernel = new float[radius * 2 + 1];
float[] t = new float[kernel.Length];
float[] p;
t[0] = 1;
kernel[0] = 1;
kernel[1] = 1;
for (int i = 2; i < kernel.Length; i++)
{
for (int j = 1; j < i; j++)
t[j] = kernel[j] + kernel[j - 1];
t[i] = 1;
p = t;
t = kernel;
kernel = p;
}
float sum = 1;
for (int i = 1; i < kernel.Length; i++)
sum += kernel[i];
for (int i = 0; i < kernel.Length; i++)
kernel[i] /= sum;
//actual shader setup
Matrix projection = Matrix.CreateOrthographicOffCenter(0, viewportWidth, viewportHeight, 0, 0, 1);
Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
gaussianBlur.Parameters["MatrixTransform"].SetValue(renderer.GetTransformMatrix() * halfPixelOffset * projection);
gaussianBlur.Parameters["range"].SetValue(radius);
gaussianBlur.Parameters["pixelSize"].SetValue(pixelSize);
gaussianBlur.Parameters["kernel"].SetValue(kernel);
renderer.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullNone, gaussianBlur);
}
示例2: Draw
public override void Draw(Renderer r)
{
Matrix projection = Matrix.CreateOrthographicOffCenter(0,
Main.renderer.GraphicsDevice.Viewport.Width, Main.renderer.GraphicsDevice.Viewport.Height, 0, 0, 1);
Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
Effects.Effects.lightning.Parameters["MatrixTransform"].SetValue(r.GetTransformMatrix() * halfPixelOffset * projection);
float[] p = new float[]{
1f/fbo.Width,
1f/fbo.Height};
Effects.Effects.lightning.Parameters["pixel"].SetValue(p);
r.End();
r.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone,
Effects.Effects.lightning);
Vector2 o = new Vector2(32, fbo.Height / 2);
r.Draw(fbo, new Rectangle((int)Position.X, (int)Position.Y, fbo.Width / 4, fbo.Height / 4), null,
Color.White, rot, o);
r.End();
r.Begin();
}