本文整理汇总了C#中IRenderContext.PushEffect方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.PushEffect方法的具体用法?C# IRenderContext.PushEffect怎么用?C# IRenderContext.PushEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.PushEffect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
/// <summary>
/// Renders the specified chunk with the specified rendering context.
/// </summary>
/// <param name="renderContext">The rendering context.</param>
/// <param name="runtimeChunk">The runtime chunk to render.</param>
public void Render(IRenderContext renderContext, IChunk runtimeChunk)
{
if (!renderContext.Is3DContext)
{
return;
}
if (runtimeChunk.GraphicsEmpty)
{
return;
}
if (runtimeChunk.Generated && runtimeChunk.VertexBuffer == null && runtimeChunk.IndexBuffer == null)
{
this.CalculateBuffers(renderContext, runtimeChunk);
}
if (runtimeChunk.VertexBuffer != null && runtimeChunk.IndexBuffer != null)
{
renderContext.PushEffect(this.m_TerrainEffectAsset.Effect);
renderContext.EnableTextures();
renderContext.SetActiveTexture(this.m_TextureAtlasAsset.TextureAtlas.Texture);
renderContext.GraphicsDevice.Indices = runtimeChunk.IndexBuffer;
renderContext.GraphicsDevice.SetVertexBuffer(runtimeChunk.VertexBuffer);
renderContext.World = Matrix.CreateScale(32);
foreach (var pass in renderContext.Effect.CurrentTechnique.Passes)
{
pass.Apply();
renderContext.GraphicsDevice.DrawIndexedPrimitives(
PrimitiveType.TriangleList,
0,
0,
runtimeChunk.VertexBuffer.VertexCount,
0,
runtimeChunk.IndexBuffer.IndexCount / 3);
}
renderContext.PopEffect();
}
}
示例2: RenderBelow
//.........这里部分代码省略.........
this.m_LightingEffect.Effect.Parameters["LightColours4"].SetValue(
new Matrix(
lights[12].LightColor.R / 255f,
lights[12].LightColor.G / 255f,
lights[12].LightColor.B / 255f,
1,
lights[13].LightColor.R / 255f,
lights[13].LightColor.G / 255f,
lights[13].LightColor.B / 255f,
1,
lights[14].LightColor.R / 255f,
lights[14].LightColor.G / 255f,
lights[14].LightColor.B / 255f,
1,
lights[15].LightColor.R / 255f,
lights[15].LightColor.G / 255f,
lights[15].LightColor.B / 255f,
1));
this.m_LightingEffect.Effect.Parameters["Lights1"].SetValue(
new Matrix(
lights[0].LightPosition.X,
lights[0].LightPosition.Y,
lights[0].LightPosition.Z,
lights[0].LightDistance,
lights[1].LightPosition.X,
lights[1].LightPosition.Y,
lights[1].LightPosition.Z,
lights[1].LightDistance,
lights[2].LightPosition.X,
lights[2].LightPosition.Y,
lights[2].LightPosition.Z,
lights[2].LightDistance,
lights[3].LightPosition.X,
lights[3].LightPosition.Y,
lights[3].LightPosition.Z,
lights[3].LightDistance));
this.m_LightingEffect.Effect.Parameters["Lights2"].SetValue(
new Matrix(
lights[4].LightPosition.X,
lights[4].LightPosition.Y,
lights[4].LightPosition.Z,
lights[4].LightDistance,
lights[5].LightPosition.X,
lights[5].LightPosition.Y,
lights[5].LightPosition.Z,
lights[5].LightDistance,
lights[6].LightPosition.X,
lights[6].LightPosition.Y,
lights[6].LightPosition.Z,
lights[6].LightDistance,
lights[7].LightPosition.X,
lights[7].LightPosition.Y,
lights[7].LightPosition.Z,
lights[7].LightDistance));
this.m_LightingEffect.Effect.Parameters["Lights3"].SetValue(
new Matrix(
lights[8].LightPosition.X,
lights[8].LightPosition.Y,
lights[8].LightPosition.Z,
lights[8].LightDistance,
lights[9].LightPosition.X,
lights[9].LightPosition.Y,
lights[9].LightPosition.Z,
lights[9].LightDistance,
lights[10].LightPosition.X,
lights[10].LightPosition.Y,
lights[10].LightPosition.Z,
lights[10].LightDistance,
lights[11].LightPosition.X,
lights[11].LightPosition.Y,
lights[11].LightPosition.Z,
lights[11].LightDistance));
this.m_LightingEffect.Effect.Parameters["Lights4"].SetValue(
new Matrix(
lights[12].LightPosition.X,
lights[12].LightPosition.Y,
lights[12].LightPosition.Z,
lights[12].LightDistance,
lights[13].LightPosition.X,
lights[13].LightPosition.Y,
lights[13].LightPosition.Z,
lights[13].LightDistance,
lights[14].LightPosition.X,
lights[14].LightPosition.Y,
lights[14].LightPosition.Z,
lights[14].LightDistance,
lights[15].LightPosition.X,
lights[15].LightPosition.Y,
lights[15].LightPosition.Z,
lights[15].LightDistance));
renderContext.PushEffect(this.m_LightingEffect.Effect);
player.SetCamera(renderContext);
}
示例3: Blit
public void Blit(IRenderContext renderContext, RenderTarget2D source, RenderTarget2D destination = null, Effect shader = null)
{
float destWidth, destHeight;
if (destination != null)
{
renderContext.PushRenderTarget(destination);
destWidth = destination.Width;
destHeight = destination.Height;
}
else
{
// TODO: renderContext.GraphicsDevice.GetRenderTargets();
destWidth = renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth;
destHeight = renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight;
}
if (shader == null)
{
shader = _blitEffect;
}
if (_vertexBuffer == null)
{
_vertexBuffer = new VertexBuffer(renderContext.GraphicsDevice, typeof (VertexPositionTexture),
_vertexes.Length, BufferUsage.WriteOnly);
_vertexBuffer.SetData(_vertexes);
}
if (_indexBuffer == null)
{
_indexBuffer = new IndexBuffer(renderContext.GraphicsDevice, typeof (short), _indicies.Length,
BufferUsage.WriteOnly);
_indexBuffer.SetData(_indicies);
}
var oldWorld = renderContext.World;
var oldProjection = renderContext.Projection;
var oldView = renderContext.View;
renderContext.GraphicsDevice.BlendState = BlendState.Opaque;
renderContext.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
renderContext.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
renderContext.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
renderContext.World = Matrix.CreateScale(destWidth, destHeight, 1);
#if PLATFORM_WINDOWS
renderContext.Projection = Matrix.CreateOrthographicOffCenter(0, destWidth, destHeight, 0, 0, 1);
#else
renderContext.Projection = Matrix.CreateTranslation(-0.5f, -0.5f, 0) *
Matrix.CreateOrthographicOffCenter(0, destWidth, destHeight, 0, 0, 1);
#endif
renderContext.View = Matrix.Identity;
renderContext.PushEffect(shader);
renderContext.EnableTextures();
renderContext.SetActiveTexture(source);
renderContext.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
renderContext.GraphicsDevice.Indices = _indexBuffer;
foreach (var pass in shader.CurrentTechnique.Passes)
{
pass.Apply();
renderContext.GraphicsDevice.DrawIndexedPrimitives(
PrimitiveType.TriangleStrip,
0,
0,
4,
0,
2);
}
renderContext.PopEffect();
renderContext.World = oldWorld;
renderContext.Projection = oldProjection;
renderContext.View = oldView;
if (destination != null)
{
renderContext.PopRenderTarget();
}
}