本文整理汇总了C#中Procedurality.Channel.putPixelWrap方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.putPixelWrap方法的具体用法?C# Channel.putPixelWrap怎么用?C# Channel.putPixelWrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Procedurality.Channel
的用法示例。
在下文中一共展示了Channel.putPixelWrap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: erode5
public static Channel erode5(Channel channel, Channel rain, float erosion_water, float erosion_flow, float evaporation, float water_threshold, float solulibility, int ipr, int iterations)
{
Channel w = new Channel(channel.width, channel.height); // water map
Channel dw = new Channel(channel.width, channel.height); // delta water map
Channel s = new Channel(channel.width, channel.height); // sediment map
Channel ds = new Channel(channel.width, channel.height); // delta sediment map
Console.Write("Hydraulic erosion 5: ");
for (int i = 0; i < iterations; i++) {
Console.Write(".");
// save frames
/*
if (channel.width > 128 && i%10 == 0) {
if (i < 10) {
channel.toLayer().saveAsPNG("erosion00" + i);
} else if (i < 100) {
channel.toLayer().saveAsPNG("erosion0" + i);
} else {
channel.toLayer().saveAsPNG("erosion" + i);
}
}
*/
// water is added according to rain map
if (i%ipr == 0) {
w.channelAdd(rain);
}
// the presence of water dissolves material
channel.channelSubtract(w.copy().multiply(erosion_water));
s.channelAdd(w.copy().multiply(erosion_water));
// water and sediment are transported
float h, h1, h2, h3, h4, d1, d2, d3, d4, total_height, total_height_diff, total_height_diff_inv, avr_height, water_amount;
int cells;
for (int y = 0; y < channel.height; y++) {
for (int x = 0; x < channel.width; x++) {
// water transport
// calculate total heights and height differences
h = channel.getPixel(x, y) + w.getPixel(x, y) + s.getPixel(x, y);
h1 = channel.getPixelWrap(x , y + 1) + w.getPixelWrap(x , y + 1) + s.getPixelWrap(x , y + 1);
h2 = channel.getPixelWrap(x - 1, y ) + w.getPixelWrap(x - 1, y ) + s.getPixelWrap(x - 1, y );
h3 = channel.getPixelWrap(x + 1, y ) + w.getPixelWrap(x + 1, y ) + s.getPixelWrap(x + 1, y );
h4 = channel.getPixelWrap(x , y - 1) + w.getPixelWrap(x , y - 1) + s.getPixelWrap(x , y - 1);
d1 = h - h1;
d2 = h - h2;
d3 = h - h3;
d4 = h - h4;
// calculate amount of water to transport
total_height = 0f;
total_height_diff = 0f;
cells = 1;
if (d1 > 0) {
total_height_diff+= d1;
total_height+= h1;
cells++;
}
if (d2 > 0) {
total_height_diff+= d2;
total_height+= h2;
cells++;
}
if (d3 > 0) {
total_height_diff+= d3;
total_height+= h3;
cells++;
}
if (d4 > 0) {
total_height_diff+= d4;
total_height+= h4;
cells++;
}
if (cells == 1) {
continue;
}
avr_height = total_height/cells;
water_amount = Math.Min(w.getPixel(x, y), h - avr_height);
dw.putPixel(x, y, dw.getPixel(x, y) - water_amount);
total_height_diff_inv = water_amount/total_height_diff;
// transport water
if (d1 > 0) {
dw.putPixelWrap(x, y + 1, dw.getPixelWrap(x, y + 1) + d1*total_height_diff_inv);
}
if (d2 > 0) {
dw.putPixelWrap(x - 1, y, dw.getPixelWrap(x - 1, y) + d2*total_height_diff_inv);
}
if (d3 > 0) {
dw.putPixelWrap(x + 1, y, dw.getPixelWrap(x + 1, y) + d3*total_height_diff_inv);
}
//.........这里部分代码省略.........