本文整理汇总了C#中DeviceContext.GenerateMips方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceContext.GenerateMips方法的具体用法?C# DeviceContext.GenerateMips怎么用?C# DeviceContext.GenerateMips使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceContext
的用法示例。
在下文中一共展示了DeviceContext.GenerateMips方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToneMap
/// <summary>
/// Tone-maps a texture into another. The target dimensions,
/// source dimensions, and ToneMapper dimensions <b>must</b>
/// be exactly the same for correct operation.
/// </summary>
/// <param name="context">The device context.</param>
/// <param name="pass">A SurfacePass instance.</param>
/// <param name="target">The render target.</param>
/// <param name="source">The source texture.</param>
public void ToneMap(DeviceContext context, SurfacePass pass, RenderTargetView target, ShaderResourceView source)
{
pass.Pass(context, averageShader, temporary.Dimensions, temporary.RTV, new[] { source }, null);
context.GenerateMips(temporary.SRV);
DataStream cbuffer = new DataStream(8, true, true);
cbuffer.Write<float>((float)(1.0 / Gamma));
cbuffer.Write<float>((float)Exposure);
cbuffer.Position = 0;
pass.Pass(context, operateShader, temporary.Dimensions, target, new[] { temporary.SRV }, cbuffer);
cbuffer.Dispose();
}
示例2: Diffract
/// <summary>
/// Generates the diffraction spectrum of a texture. The source texture
/// must be the exact resolution specified in the constructor, however,
/// the output will be resized to the destination texture as needed.
/// </summary>
/// <param name="device">The graphics device to use.</param>
/// <param name="context">The device context to use.</param>
/// <param name="pass">A SurfacePass instance.</param>
/// <param name="renderSize">The dimensions of the render target.</param>
/// <param name="destination">The destination render target view.</param>
/// <param name="source">The source texture, can be the same resource as the render target.</param>
/// <param name="fNumber">The distance at which to evaluate the aperture transmission function.</param>
public void Diffract(Device device, DeviceContext context, SurfacePass pass, Size renderSize, RenderTargetView destination, ShaderResourceView source, double fNumber)
{
if (source.Description.Dimension != ShaderResourceViewDimension.Texture2D)
throw new ArgumentException("Source SRV must point to a Texture2D resource of suitable dimensions.");
//if (new Size(source.ResourceAs<Texture2D>().Description.Width, source.ResourceAs<Texture2D>().Description.Height) != resolution)
// throw new ArgumentException("Source texture must be the same dimensions as diffraction resolution.");
pass.Pass(context, Encoding.ASCII.GetString(Resources.DiffractionTexToBuf), new ViewportF(0, 0, resolution.Width, resolution.Height), null, new[] { source }, new[] { buffer.view }, null);
DataStream cbuffer = new DataStream(8, true, true);
cbuffer.Write<uint>((uint)resolution.Width);
cbuffer.Write<uint>((uint)resolution.Height);
cbuffer.Position = 0;
UnorderedAccessView fftView = fft.ForwardTransform(buffer.view);
pass.Pass(context, Encoding.ASCII.GetString(Resources.DiffractionBufToTex), new ViewportF(0, 0, transform.Dimensions.Width, transform.Dimensions.Height), transform.RTV, null, new[] { fftView }, cbuffer);
fftView.Dispose();
cbuffer.Dispose();
cbuffer = new DataStream(4, true, true);
cbuffer.Write<float>((float)fNumber);
cbuffer.Position = 0;
pass.Pass(context, Encoding.ASCII.GetString(Resources.DiffractionSpectrum), spectrum.Dimensions, spectrum.RTV, new[] { transform.SRV }, cbuffer);
context.GenerateMips(spectrum.SRV);
cbuffer.Dispose();
cbuffer = new DataStream(4, true, true);
cbuffer.Write<float>((float)fNumber);
cbuffer.Position = 0;
pass.Pass(context, Encoding.ASCII.GetString(Resources.DiffractionNormalize), renderSize, destination, new[] { spectrum.SRV }, cbuffer);
cbuffer.Dispose();
}