本文整理汇总了C#中RenderDrawContext类的典型用法代码示例。如果您正苦于以下问题:C# RenderDrawContext类的具体用法?C# RenderDrawContext怎么用?C# RenderDrawContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderDrawContext类属于命名空间,在下文中一共展示了RenderDrawContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:34,代码来源:SkyboxRenderFeature.cs
示例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);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:34,代码来源:SceneEffectRenderer.cs
示例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);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:34,代码来源:ComputeEffectShader.cs
示例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);
}
开发者ID:cg123,项目名称:xenko,代码行数:26,代码来源:SceneSystem.cs
示例5: Draw
public override void Draw(RenderDrawContext context, RenderView renderView, RenderViewStage renderViewStage, int startIndex, int endIndex)
{
lock (drawLock)
{
DrawInternal(context, renderView, renderViewStage, startIndex, endIndex);
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:UIRenderFeature.cs
示例6: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
using (context.RenderContext.PushTagAndRestore(SceneCameraSlotCollection.Current, Cameras))
{
base.DrawCore(context);
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:SceneGraphicsCompositorLayers.cs
示例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));
}
}
}
开发者ID:cg123,项目名称:xenko,代码行数:27,代码来源:GameRenderFeature.cs
示例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);
}
}
}
}
开发者ID:cg123,项目名称:xenko,代码行数:33,代码来源:SkinningRenderFeature.cs
示例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();
}
}
}
}
开发者ID:cg123,项目名称:xenko,代码行数:28,代码来源:SceneRendererBase.cs
示例10: PreDrawCore
protected override void PreDrawCore(RenderDrawContext context)
{
base.PreDrawCore(context);
// Default handler for parameters
UpdateParameters();
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:ImageEffectShader.cs
示例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);
}
}
}
}
开发者ID:cg123,项目名称:xenko,代码行数:25,代码来源:ClearRenderFrameRenderer.cs
示例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);
}
}
开发者ID:cg123,项目名称:xenko,代码行数:13,代码来源:SceneRendererBase.cs
示例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);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:ColorCombiner.cs
示例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();
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:EffectScript.cs
示例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);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:9,代码来源:SceneChildRenderer.cs
示例16: Draw
/// <summary>
/// Draws this renderer with the specified context.
/// </summary>
/// <param name="context">The context.</param>
/// <exception cref="System.ArgumentNullException">context</exception>
/// <exception cref="System.InvalidOperationException">Cannot use a different context between Load and Draw</exception>
public void Draw(RenderDrawContext context)
{
if (Enabled)
{
PreDrawCoreInternal(context);
DrawCore(context);
PostDrawCoreInternal(context);
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:15,代码来源:RendererBase.cs
示例17: Prepare
/// <inheritdoc/>
public override void Prepare(RenderDrawContext context)
{
base.Prepare(context);
// Prepare each sub render feature
foreach (var renderFeature in RenderFeatures)
{
renderFeature.Prepare(context);
}
}
开发者ID:cg123,项目名称:xenko,代码行数:11,代码来源:MeshRenderFeature.cs
示例18: Draw
protected override void Draw(GameTime gameTime)
{
if (!ScreenShotAutomationEnabled)
AdjustEffectParameters();
var renderDrawContext = new RenderDrawContext(Services, RenderContext.GetShared(Services), GraphicsContext);
DrawCustomEffect(renderDrawContext);
base.Draw(gameTime);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:10,代码来源:TestImageEffect.cs
示例19: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
var input = GetInput(0);
var output = GetOutput(0);
if (FadeOutSpeed == 0f)
{
// Nothing to do
if (input != output)
{
context.CommandList.Copy(input, output);
}
return;
}
if (input == output)
{
var newInput = NewScopedRenderTarget2D(input.Description);
context.CommandList.Copy(input, newInput);
input = newInput;
}
// Check we have a render target to hold the persistence over a few frames
if (persistenceTexture == null || persistenceTexture.Description != output.Description)
{
// We need to re-allocate the texture
if (persistenceTexture != null)
{
Context.Allocator.ReleaseReference(persistenceTexture);
}
persistenceTexture = Context.Allocator.GetTemporaryTexture2D(output.Description);
// Initializes to black
context.CommandList.Clear(persistenceTexture, Color.Black);
}
var accumulationPersistence = NewScopedRenderTarget2D(persistenceTexture.Description);
// For persistence, we combine the current brightness with the one of the previous frames.
bloomAfterimageShader.Parameters.Set(BloomAfterimageShaderKeys.FadeOutSpeed, FadeOutSpeed);
bloomAfterimageShader.Parameters.Set(BloomAfterimageShaderKeys.Sensitivity, Sensitivity / 100f);
bloomAfterimageShader.SetInput(0, input);
bloomAfterimageShader.SetInput(1, persistenceTexture);
bloomAfterimageShader.SetOutput(accumulationPersistence);
bloomAfterimageShader.Draw(context, "Afterimage persistence accumulation");
// Keep the final brightness buffer for the following frames
context.CommandList.Copy(accumulationPersistence, persistenceTexture);
// Merge persistence and current bloom into the final result
bloomAfterimageCombineShader.SetInput(0, input);
bloomAfterimageCombineShader.SetInput(1, persistenceTexture);
bloomAfterimageCombineShader.SetOutput(output);
bloomAfterimageCombineShader.Draw(context, "Afterimage persistence combine");
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:55,代码来源:Afterimage.cs
示例20: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
var output = PrefilteredRadiance;
if (output == null || (output.Dimension != TextureDimension.Texture2D && output.Dimension != TextureDimension.TextureCube) || output.ArraySize != 6)
throw new NotSupportedException("Only array of 2D textures are currently supported as output");
if (!output.IsRenderTarget)
throw new NotSupportedException("Only render targets are supported as output");
var input = RadianceMap;
if (input == null || input.Dimension != TextureDimension.TextureCube)
throw new NotSupportedException("Only cubemaps are currently supported as input");
var roughness = 0f;
var faceCount = output.ArraySize;
var levelSize = new Int2(output.Width, output.Height);
var mipCount = MipmapGenerationCount == 0 ? output.MipLevels : MipmapGenerationCount;
for (int mipLevel = 0; mipLevel < mipCount; mipLevel++)
{
if (mipLevel == 0 && DoNotFilterHighestLevel && input.Width >= output.Width)
{
var inputLevel = MathUtil.Log2(input.Width / output.Width);
for (int faceIndex = 0; faceIndex < 6; faceIndex++)
{
var inputSubresource = inputLevel + faceIndex * input.MipLevels;
var outputSubresource = 0 + faceIndex * output.MipLevels;
context.CommandList.CopyRegion(input, inputSubresource, null, output, outputSubresource);
}
}
else
{
for (int faceIndex = 0; faceIndex < faceCount; faceIndex++)
{
using (var outputView = output.ToTextureView(ViewType.Single, faceIndex, mipLevel))
{
shader.Parameters.Set(RadiancePrefilteringGGXNoComputeShaderKeys.Face, faceIndex);
shader.Parameters.Set(RadiancePrefilteringGGXNoComputeShaderKeys.Roughness, roughness);
shader.Parameters.Set(RadiancePrefilteringGGXNoComputeShaderKeys.MipmapCount, input.MipLevels - 1);
shader.Parameters.Set(RadiancePrefilteringGGXNoComputeShaderKeys.RadianceMap, input);
shader.Parameters.Set(RadiancePrefilteringGGXNoComputeShaderKeys.RadianceMapSize, input.Width);
shader.Parameters.Set(RadiancePrefilteringGGXNoComputeParams.NbOfSamplings, SamplingsCount);
shader.SetOutput(outputView);
((RendererBase)shader).Draw(context);
}
}
}
if (mipCount > 1)
{
roughness += 1f / (mipCount - 1);
levelSize /= 2;
}
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:55,代码来源:RadiancePrefilteringGGXNoCompute.cs
注:本文中的RenderDrawContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论