本文整理汇总了C#中RenderDrawContext类的典型用法代码示例。如果您正苦于以下问题:C# RenderDrawContext类的具体用法?C# RenderDrawContext怎么用?C# RenderDrawContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderDrawContext类属于命名空间,在下文中一共展示了RenderDrawContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareEffectPermutationsImpl
/// <param name="context"></param>
/// <inheritdoc/>
public override void PrepareEffectPermutationsImpl(RenderDrawContext context)
{
var renderEffects = RenderData.GetData(RenderEffectKey);
foreach (var renderObject in RenderObjects)
{
var staticObjectNode = renderObject.StaticObjectNode;
for (int i = 0; i < EffectPermutationSlotCount; ++i)
{
var staticEffectObjectNode = staticObjectNode * EffectPermutationSlotCount + i;
var renderEffect = renderEffects[staticEffectObjectNode];
var renderSkybox = (RenderSkybox)renderObject;
// Skip effects not used during this frame
if (renderEffect == null || !renderEffect.IsUsedDuringThisFrame(RenderSystem))
continue;
var parameters = renderSkybox.Background == SkyboxBackground.Irradiance ? renderSkybox.Skybox.DiffuseLightingParameters : renderSkybox.Skybox.Parameters;
var shader = parameters.Get(SkyboxKeys.Shader);
if (shader == null)
{
renderEffect.EffectValidator.ShouldSkip = true;
}
renderEffect.EffectValidator.ValidateParameter(SkyboxKeys.Shader, shader);
}
}
transformRenderFeature.PrepareEffectPermutations(context);
}
示例2: DrawCore
protected override void DrawCore(RenderDrawContext context, RenderFrame output)
{
var input = Input.GetSafeRenderFrame(context.RenderContext);
// If RenderFrame input or output are null, we can't do anything
if (input == null)
{
return;
}
// If an effect is set, we are using it
if (Effect != null)
{
Effect.SetInput(0, input);
if (input.DepthStencil != null)
{
Effect.SetInput(1, input.DepthStencil);
}
Effect.SetOutput(output);
Effect.Draw(context);
}
else if (input != output)
{
// Else only use a scaler if input and output don't match
// TODO: Is this something we want by default or we just don't output anything?
var effect = context.GetSharedEffect<ImageScaler>();
effect.SetInput(0, input);
effect.SetOutput(output);
((RendererBase)effect).Draw(context);
}
// Switch back last output as render target
context.CommandList.ResourceBarrierTransition(output, GraphicsResourceState.RenderTarget);
}
示例3: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
if (string.IsNullOrEmpty(ShaderSourceName))
return;
Parameters.Set(ComputeEffectShaderKeys.ThreadNumbers, ThreadNumbers);
Parameters.Set(ComputeEffectShaderKeys.ComputeShaderName, ShaderSourceName);
Parameters.Set(ComputeShaderBaseKeys.ThreadGroupCountGlobal, ThreadGroupCounts);
if (EffectInstance.UpdateEffect(GraphicsDevice) || pipelineStateDirty || previousBytecode != EffectInstance.Effect.Bytecode)
{
// The EffectInstance might have been updated from outside
previousBytecode = EffectInstance.Effect.Bytecode;
pipelineState.State.SetDefaults();
pipelineState.State.RootSignature = EffectInstance.RootSignature;
pipelineState.State.EffectBytecode = EffectInstance.Effect.Bytecode;
pipelineState.Update();
pipelineStateDirty = false;
}
// Apply pipeline state
context.CommandList.SetPipelineState(pipelineState.CurrentState);
// Apply the effect
EffectInstance.Apply(context.GraphicsContext);
// Draw a full screen quad
context.CommandList.Dispatch(ThreadGroupCounts.X, ThreadGroupCounts.Y, ThreadGroupCounts.Z);
// Un-apply
//throw new InvalidOperationException();
//EffectInstance.Effect.UnbindResources(GraphicsDevice);
}
示例4: LoadContent
protected override void LoadContent()
{
var assetManager = Services.GetSafeServiceAs<ContentManager>();
var graphicsContext = Services.GetSafeServiceAs<GraphicsContext>();
// Preload the scene if it exists
if (InitialSceneUrl != null && assetManager.Exists(InitialSceneUrl))
{
SceneInstance = new SceneInstance(Services, assetManager.Load<Scene>(InitialSceneUrl));
}
if (MainRenderFrame == null)
{
// TODO GRAPHICS REFACTOR Check if this is a good idea to use Presenter targets
MainRenderFrame = RenderFrame.FromTexture(GraphicsDevice.Presenter?.BackBuffer, GraphicsDevice.Presenter?.DepthStencilBuffer);
if (MainRenderFrame != null)
{
previousWidth = MainRenderFrame.Width;
previousHeight = MainRenderFrame.Height;
}
}
// Create the drawing context
renderContext = RenderContext.GetShared(Services);
renderDrawContext = new RenderDrawContext(Services, renderContext, graphicsContext);
}
示例5: Draw
public override void Draw(RenderDrawContext context, RenderView renderView, RenderViewStage renderViewStage, int startIndex, int endIndex)
{
lock (drawLock)
{
DrawInternal(context, renderView, renderViewStage, startIndex, endIndex);
}
}
示例6: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
using (context.RenderContext.PushTagAndRestore(SceneCameraSlotCollection.Current, Cameras))
{
base.DrawCore(context);
}
}
示例7: PrepareEffectPermutations
/// <inheritdoc/>
public override void PrepareEffectPermutations(RenderDrawContext context)
{
var renderEffects = RootRenderFeature.RenderData.GetData(renderEffectKey);
int effectSlotCount = ((RootEffectRenderFeature)RootRenderFeature).EffectPermutationSlotCount;
foreach (var renderObject in RootRenderFeature.RenderObjects)
{
var staticObjectNode = renderObject.StaticObjectNode;
var renderMesh = (RenderMesh)renderObject;
for (int i = 0; i < effectSlotCount; ++i)
{
var staticEffectObjectNode = staticObjectNode * effectSlotCount + i;
var renderEffect = renderEffects[staticEffectObjectNode];
// Skip effects not used during this frame
if (renderEffect == null || !renderEffect.IsUsedDuringThisFrame(RenderSystem))
continue;
// Generate shader permuatations
renderEffect.EffectValidator.ValidateParameter(GameParameters.EnableBend, renderMesh.Mesh.Parameters.Get(GameParameters.EnableBend));
renderEffect.EffectValidator.ValidateParameter(GameParameters.EnableFog, renderMesh.Mesh.Parameters.Get(GameParameters.EnableFog));
renderEffect.EffectValidator.ValidateParameter(GameParameters.EnableOnflyTextureUVChange, renderMesh.Mesh.Parameters.Get(GameParameters.EnableOnflyTextureUVChange));
}
}
}
示例8: PrepareEffectPermutations
/// <param name="context"></param>
/// <inheritdoc/>
public override void PrepareEffectPermutations(RenderDrawContext context)
{
var renderEffects = RootRenderFeature.RenderData.GetData(renderEffectKey);
int effectSlotCount = ((RootEffectRenderFeature)RootRenderFeature).EffectPermutationSlotCount;
foreach (var renderObject in RootRenderFeature.RenderObjects)
{
var staticObjectNode = renderObject.StaticObjectNode;
for (int i = 0; i < effectSlotCount; ++i)
{
var staticEffectObjectNode = staticObjectNode * effectSlotCount + i;
var renderEffect = renderEffects[staticEffectObjectNode];
var renderMesh = (RenderMesh)renderObject;
// Skip effects not used during this frame
if (renderEffect == null || !renderEffect.IsUsedDuringThisFrame(RenderSystem))
continue;
if (renderMesh.Mesh.Skinning != null)
{
renderEffect.EffectValidator.ValidateParameter(MaterialKeys.HasSkinningPosition, renderMesh.Mesh.Parameters.Get(MaterialKeys.HasSkinningPosition));
renderEffect.EffectValidator.ValidateParameter(MaterialKeys.HasSkinningNormal, renderMesh.Mesh.Parameters.Get(MaterialKeys.HasSkinningNormal));
renderEffect.EffectValidator.ValidateParameter(MaterialKeys.HasSkinningTangent, renderMesh.Mesh.Parameters.Get(MaterialKeys.HasSkinningTangent));
var skinningBones = Math.Max(MaxBones, renderMesh.Mesh.Skinning.Bones.Length);
renderEffect.EffectValidator.ValidateParameter(MaterialKeys.SkinningMaxBones, skinningBones);
}
}
}
}
示例9: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
var output = GetOutput(context.RenderContext);
if (output != null)
{
try
{
// TODO GRAPHICS REFACTOR
//context.PushParameters(Parameters);
ActivateOutput(context);
DrawCore(context, output);
}
finally
{
// TODO GRAPHICS REFACTOR
//context.PopParameters();
if (ResetGraphicsStates)
{
// Make sure that states are clean after this rendering
// TODO GRAPHICS REFACTOR
//context.GraphicsDevice.ResetStates();
}
}
}
}
示例10: PreDrawCore
protected override void PreDrawCore(RenderDrawContext context)
{
base.PreDrawCore(context);
// Default handler for parameters
UpdateParameters();
}
示例11: DrawCore
protected override void DrawCore(RenderDrawContext context, RenderFrame output)
{
var commandList = context.CommandList;
// clear the targets
if (output.DepthStencil != null && (ClearFlags == ClearRenderFrameFlags.ColorAndDepth || ClearFlags == ClearRenderFrameFlags.DepthOnly))
{
const DepthStencilClearOptions ClearOptions = DepthStencilClearOptions.DepthBuffer | DepthStencilClearOptions.Stencil;
commandList.Clear(output.DepthStencil, ClearOptions, Depth, Stencil);
}
if (ClearFlags == ClearRenderFrameFlags.ColorAndDepth || ClearFlags == ClearRenderFrameFlags.ColorOnly)
{
foreach (var renderTarget in output.RenderTargets)
{
if (renderTarget != null)
{
// If color is in GammeSpace and rendertarget is either SRgb or HDR, use a linear value to clear the buffer.
// TODO: We will need to move this color transform code to a shareable component
var color = Color.ToColorSpace(ColorSpace, (renderTarget.Format.IsSRgb() || renderTarget.Format.IsHDR()) ? ColorSpace.Linear : context.GraphicsDevice.ColorSpace);
commandList.Clear(renderTarget, color);
}
}
}
}
示例12: ActivateOutput
/// <summary>
/// Activates the output to the current <see cref="GraphicsDevice"/>.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="disableDepth">if set to <c>true</c> [disable depth].</param>
public void ActivateOutput(RenderDrawContext context, bool disableDepth = false)
{
var output = GetOutput(context.RenderContext);
if (output != null)
{
ActivateOutputCore(context, output, disableDepth);
}
}
示例13: PreDrawCore
protected override void PreDrawCore(RenderDrawContext context)
{
base.PreDrawCore(context);
int value = InputCount;
Parameters.Set(FactorCount, value);
Parameters.Set(ColorCombinerShaderKeys.Factors, factors);
Parameters.Set(ColorCombinerShaderKeys.ModulateRGB, ModulateRGB);
}
示例14: RenderQuad
private void RenderQuad(RenderDrawContext renderContext, RenderFrame frame)
{
customEffectInstance.Parameters.Set(EffectKeys.Phase, -3 * (float)Game.UpdateTime.Total.TotalSeconds);
spriteBatch.Begin(renderContext.GraphicsContext, blendState: BlendStates.NonPremultiplied, depthStencilState: DepthStencilStates.None, effect: customEffectInstance);
spriteBatch.Draw(Logo, new RectangleF(0, 0, 1, 1), Color.White);
spriteBatch.End();
}
示例15: DrawCore
protected override void DrawCore(RenderDrawContext context, RenderFrame output)
{
var sceneInstance = GetChildSceneInstance();
if (sceneInstance == null)
return;
// Draw scene recursively
sceneInstance.Draw(context, output, GraphicsCompositorOverride);
}