本文整理汇总了C#中RenderContext.GetCameraFromSlot方法的典型用法代码示例。如果您正苦于以下问题:C# RenderContext.GetCameraFromSlot方法的具体用法?C# RenderContext.GetCameraFromSlot怎么用?C# RenderContext.GetCameraFromSlot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderContext
的用法示例。
在下文中一共展示了RenderContext.GetCameraFromSlot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCore
protected override void DrawCore(RenderContext context, RenderFrame output)
{
// Early exit if some properties are null
if (Mode == null)
{
return;
}
// Gets the current camera state from the slot
var camera = context.GetCameraFromSlot(Camera);
// Draw this camera.
using (context.PushTagAndRestore(Current, this))
using (context.PushTagAndRestore(CameraComponentRenderer.Current, camera))
{
// Run all pre-renderers
foreach (var renderer in PreRenderers)
{
renderer.Draw(context);
}
// Draw the scene based on its drawing mode (e.g. implementation forward or deferred... etc.)
Mode.Draw(context);
// Run all post-renderers
foreach (var renderer in PostRenderers)
{
renderer.Draw(context);
}
}
}
示例2: DrawCore
protected override void DrawCore(RenderContext context)
{
var input = GetInput(0);
var output = GetOutput(0);
if (input == null || output == null)
{
return;
}
// Gets the current camera state
var camera = context.GetCameraFromSlot(Camera);
if (camera != null)
{
// Update the parameters for this post effect
CameraComponentRenderer.UpdateParameters(context, camera);
}
if (!Enabled)
{
if (input != output)
{
Scaler.SetInput(input);
Scaler.SetOutput(output);
Scaler.Draw(context);
}
return;
}
// If input == output, than copy the input to a temporary texture
if (input == output)
{
var newInput = NewScopedRenderTarget2D(input.Width, input.Height, input.Format);
GraphicsDevice.Copy(input, newInput);
input = newInput;
}
var currentInput = input;
if (depthOfField.Enabled && InputCount > 1 && GetInput(1) != null && GetInput(1).IsDepthStencil)
{
// DoF
var dofOutput = NewScopedRenderTarget2D(input.Width, input.Height, input.Format);
var inputDepthTexture = GetInput(1); // Depth
depthOfField.SetColorDepthInput(input, inputDepthTexture);
depthOfField.SetOutput(dofOutput);
depthOfField.Draw(context);
currentInput = dofOutput;
}
// Luminance pass (only if tone mapping is enabled)
// TODO: This is not super pluggable to have this kind of dependencies. Check how to improve this
var toneMap = colorTransformsGroup.Transforms.Get<ToneMap>();
if (colorTransformsGroup.Enabled && toneMap != null && toneMap.Enabled)
{
const int LocalLuminanceDownScale = 3;
// The luminance chain uses power-of-two intermediate targets, so it expects to output to one as well
var lumWidth = Math.Min(MathUtil.NextPowerOfTwo(currentInput.Size.Width), MathUtil.NextPowerOfTwo(currentInput.Size.Height));
lumWidth = Math.Max(1, lumWidth / 2);
var lumSize = new Size3(lumWidth, lumWidth, 1).Down2(LocalLuminanceDownScale);
var luminanceTexture = NewScopedRenderTarget2D(lumSize.Width, lumSize.Height, PixelFormat.R16_Float, 1);
luminanceEffect.SetInput(currentInput);
luminanceEffect.SetOutput(luminanceTexture);
luminanceEffect.Draw(context);
// Set this parameter that will be used by the tone mapping
colorTransformsGroup.Parameters.Set(LuminanceEffect.LuminanceResult, new LuminanceResult(luminanceEffect.AverageLuminance, luminanceTexture));
}
// Bright filter pass
Texture brightTexture = null;
if (bloom.Enabled || lightStreak.Enabled || lensFlare.Enabled)
{
brightTexture = NewScopedRenderTarget2D(currentInput.Width, currentInput.Height, currentInput.Format, 1);
brightFilter.SetInput(currentInput);
brightFilter.SetOutput(brightTexture);
brightFilter.Draw(context);
}
// Bloom pass
if (bloom.Enabled)
{
bloom.SetInput(brightTexture);
bloom.SetOutput(currentInput);
bloom.Draw(context);
}
// Light streak pass
if (lightStreak.Enabled)
{
lightStreak.SetInput(brightTexture);
lightStreak.SetOutput(currentInput);
lightStreak.Draw(context);
}
// Lens flare pass
if (lensFlare.Enabled)
//.........这里部分代码省略.........
示例3: DrawCore
protected override void DrawCore(RenderContext context)
{
var input = GetInput(0);
var output = GetOutput(0);
if (input == null || output == null)
{
return;
}
// Gets the current camera state
var camera = context.GetCameraFromSlot(Camera);
if (camera != null)
{
// Update the parameters for this post effect
CameraComponentRenderer.UpdateParameters(context, camera);
}
if (!Enabled)
{
if (input != output)
{
Scaler.SetInput(input);
Scaler.SetOutput(output);
Scaler.Draw(context);
}
return;
}
// If input == output, than copy the input to a temporary texture
if (input == output)
{
var newInput = NewScopedRenderTarget2D(input.Width, input.Height, input.Format);
GraphicsDevice.Copy(input, newInput);
input = newInput;
}
var currentInput = input;
if (depthOfField.Enabled && InputCount > 1 && GetInput(1) != null && GetInput(1).IsDepthStencil)
{
// DoF
var dofOutput = NewScopedRenderTarget2D(input.Width, input.Height, input.Format);
var inputDepthTexture = GetInput(1); // Depth
depthOfField.SetColorDepthInput(input, inputDepthTexture);
depthOfField.SetOutput(dofOutput);
depthOfField.Draw(context);
currentInput = dofOutput;
}
// Luminance pass (only if tone mapping is enabled)
// TODO: This is not super pluggable to have this kind of dependencies. Check how to improve this
if (colorTransformsGroup.Enabled && colorTransformsGroup.Transforms.IsEnabled<ToneMap>())
{
const int LocalLuminanceDownScale = 3;
var lumSize = currentInput.Size.Down2(LocalLuminanceDownScale);
var luminanceTexture = NewScopedRenderTarget2D(lumSize.Width, lumSize.Height, PixelFormat.R16_Float, 1);
luminanceEffect.SetInput(currentInput);
luminanceEffect.SetOutput(luminanceTexture);
luminanceEffect.Draw(context);
// Set this parameter that will be used by the tone mapping
colorTransformsGroup.Parameters.Set(LuminanceEffect.LuminanceResult, new LuminanceResult(luminanceEffect.AverageLuminance, luminanceTexture));
}
// Bright filter pass
Texture brightTexture = null;
if (bloom.Enabled || lightStreak.Enabled || lensFlare.Enabled)
{
brightTexture = NewScopedRenderTarget2D(currentInput.Width, currentInput.Height, currentInput.Format, 1);
brightFilter.SetInput(currentInput);
brightFilter.SetOutput(brightTexture);
brightFilter.Draw(context);
}
// Bloom pass
if (bloom.Enabled)
{
bloom.SetInput(brightTexture);
bloom.SetOutput(currentInput);
bloom.Draw(context);
}
// Light streak pass
if (lightStreak.Enabled)
{
lightStreak.SetInput(brightTexture);
lightStreak.SetOutput(currentInput);
lightStreak.Draw(context);
}
// Lens flare pass
if (lensFlare.Enabled)
{
lensFlare.SetInput(brightTexture);
lensFlare.SetOutput(currentInput);
lensFlare.Draw(context);
}
//.........这里部分代码省略.........