本文整理汇总了C#中Texture.SetParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.SetParameter方法的具体用法?C# Texture.SetParameter怎么用?C# Texture.SetParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture.SetParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFloatTexture
public Texture GenerateFloatTexture()
{
this.TextureInternalFormat = PixelInternalFormat.R32f;
this.TexturePixelFormat = PixelFormat.Red;
this.TexturePixelType = PixelType.Float;
var t = new Texture(this.Width, this.Height, this.Target, this.TextureInternalFormat, this.TexturePixelFormat, this.TexturePixelType);
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat));
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat));
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear));
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear));
// allocate space for texture
var data = new float[this.Width * this.Height];
var rand = new Random();
float rx = (float)rand.NextDouble();
float ry = (float)rand.NextDouble();
// generate some noise
ParallelHelper.For2D(this.Width, this.Height, (x, y, i) =>
{
data[i] = SimplexNoise.wrapfbm(
(float)x, (float)y,
(float)this.Width, (float)this.Height,
rx, ry,
10, // octaves
0.005f, // scale
2.0f, // amplitude
h => Math.Abs(h),
h => h);
});
//data.Normalize();
float xmin = data.Min();
float xmax = data.Max();
float scale = xmax - xmin;
if (scale != 0.0f)
{
scale = 1.0f / scale;
}
else
{
scale = 1.0f;
}
ParallelHelper.For2D(this.Width, this.Height, (i) =>
{
data[i] = (data[i] - xmin) * scale;
});
t.Upload(data);
return t;
}