• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


Commit MetaInfo

Révision508336c58ad6f456d1ea4f2c93834f0a96a93d1d (tree)
l'heure2021-05-19 10:19:30
Auteurmelchior <melchior@user...>
Commitermelchior

Message de Log

Fixed shading EDGE Defects on Chunk boundary / Missing data

Change Summary

Modification

--- a/Automap/Renderers/StandardRenderer.cs
+++ b/Automap/Renderers/StandardRenderer.cs
@@ -1,5 +1,8 @@
11 using System;
22 using System.Collections.Generic;
3+//using System.Drawing;
4+//using System.Drawing.Imaging;
5+//using System.IO;
36 using System.Linq;
47
58 using Hjg.Pngcs;
@@ -52,8 +55,8 @@ namespace Automap
5255
5356 // Prefetch map chunks, in pattern
5457 var corner_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y - 1);
55- var west_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y);
56- var north_pos = new Vec2i(chunkPos.X, chunkPos.Y - 1);
58+ var west_pos = new Vec2i(chunkPos.X, chunkPos.Y - 1);
59+ var north_pos = new Vec2i(chunkPos.X - 1 , chunkPos.Y);
5760
5861 uint missingRainmap = 0, missingHeightmap = 0;
5962
@@ -132,6 +135,8 @@ namespace Automap
132135
133136 if (badHeightData > 0)
134137 Logger.VerboseDebug("H.M Zeros# {0} , Missing Rainmaps {1} Heightmaps {2}",badHeightData ,missingRainmap, missingHeightmap);
138+
139+ //RenderDebugBitmap(overlapHeightmap, chunkPos);
135140 #endif
136141
137142
@@ -162,16 +167,18 @@ namespace Automap
162167 int west_Z = localZ + 1;
163168 int northWest_X = localX;
164169 int northWest_Z = localZ;
165-
170+ bool edge = localX == 0 || localZ == 0;
166171
167- northH = Math.Sign(localY - (overlapHeightmap[north_X, north_Z] == 0 ? avgOverlap_Y : overlapHeightmap[north_X, north_Z]));
168- northWestH = Math.Sign(localY - (overlapHeightmap[northWest_X, northWest_Z] == 0 ? avgOverlap_Y : overlapHeightmap[northWest_X, northWest_Z]));
169- westH = Math.Sign(localY - (overlapHeightmap[west_X, west_Z] == 0 ? avgOverlap_Y : overlapHeightmap[west_X, west_Z]));
172+ northH = Math.Sign(localY - (overlapHeightmap[north_X, north_Z] == 0 ? localY : overlapHeightmap[north_X, north_Z]));
173+ northWestH = Math.Sign(localY - (overlapHeightmap[northWest_X, northWest_Z] == 0 ? localY : overlapHeightmap[northWest_X, northWest_Z]));
174+ westH = Math.Sign(localY - (overlapHeightmap[west_X, west_Z] == 0 ? localY : overlapHeightmap[west_X, west_Z]));
170175
171176 float slopeness = (northH + northWestH + westH);
177+ float tolerance = edge ? 2.0f : 0f;
178+
172179
173- if (slopeness > 0) slopeBoost = 1.2f;
174- if (slopeness < 0) slopeBoost = 0.8f;
180+ if (slopeness > tolerance) slopeBoost = 1.2f;
181+ if (slopeness < tolerance) slopeBoost = 0.8f;
175182 if (Math.Abs(slopeness) <= float.Epsilon) slopeBoost = 1.0f;//Same height
176183 //slopeBoost -= 0.15f; //Slope boost value
177184
@@ -207,5 +214,29 @@ namespace Automap
207214
208215 this.PngWriter.End( );
209216 }
217+
218+ /*
219+ private void RenderDebugBitmap( ushort[ , ] heightmap, Vec2i chunkOrigin )
220+ {
221+ Bitmap mapBitmap = null;
222+ Graphics gContext = null;
223+ mapBitmap = new Bitmap(33, 33, PixelFormat.Format24bppRgb);
224+ gContext = Graphics.FromImage(mapBitmap);
225+
226+ for (int x = 0; x <= chunkSize; x++) {
227+ for (int y = 0; y <= chunkSize; y++) {
228+ ushort heightCol = heightmap[x, y];
229+ Color color= Color.FromArgb((byte)heightCol,( byte )heightCol,( byte )heightCol);
230+ mapBitmap.SetPixel(x, y, color);
231+ }
232+ }
233+
234+ gContext.Flush(System.Drawing.Drawing2D.FlushIntention.Sync);
235+
236+ var fileName = Path.Combine( ClientAPI.GetOrCreateDataPath("Heightmaps"),$"offhm_{chunkOrigin.X}-{chunkOrigin.Y}.png");
237+ mapBitmap.Save(fileName, ImageFormat.Png);
238+
239+ }
240+ */
210241 }
211242 }
\ No newline at end of file