Skip to content

Commit 5758487

Browse files
author
LoneWandererProductions
committed
Generate more Textures
1 parent e4f9c48 commit 5758487

3 files changed

Lines changed: 385 additions & 4 deletions

File tree

Imaging.Texture.Tests/TextureMathEngineTests.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,39 @@ public void GeneratePlasmaArc_VisualTest()
182182
SaveBufferToImage(buffer, "11_PlasmaArc.png");
183183
}
184184

185+
/// <summary>
186+
/// Generates the furrowed tree bark visual test.
187+
/// </summary>
188+
[TestMethod]
189+
public void GenerateTreeBark_VisualTest()
190+
{
191+
// Anisotropic domain warped vertical grain lines
192+
var buffer = TextureMathEngine.GenerateTreeBark(TestWidth, TestHeight, _noiseGenerator);
193+
SaveBufferToImage(buffer, "12_TreeBark.png");
194+
}
195+
196+
/// <summary>
197+
/// Generates the pointed leaf foliage visual test.
198+
/// </summary>
199+
[TestMethod]
200+
public void GenerateFoliage_VisualTest()
201+
{
202+
// Distance-pinched cellular matrix mapping
203+
var buffer = TextureMathEngine.GenerateFoliage(TestWidth, TestHeight);
204+
SaveBufferToImage(buffer, "13_Foliage.png");
205+
}
206+
207+
/// <summary>
208+
/// Generates the longitudinal wooden plank board visual test.
209+
/// </summary>
210+
[TestMethod]
211+
public void GenerateWoodPlank_VisualTest()
212+
{
213+
// Longitudinal sawn tree trunk ellipse mapping
214+
var buffer = TextureFactory.GenerateWoodPlank(TestWidth, TestHeight, _noiseGenerator);
215+
SaveBufferToImage(buffer, "14_WoodPlank.png");
216+
}
217+
185218
/// <summary>
186219
/// Converts the RawTextureBuffer span (BGRA) into a standard PNG file.
187220
/// </summary>
@@ -212,4 +245,4 @@ private void SaveBufferToImage(RawTextureBuffer buffer, string filename)
212245
Trace.WriteLine($"Saved: {filePath}");
213246
}
214247
}
215-
}
248+
}

Imaging.Texture/TextureFactory.cs

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* PROGRAMMER: Peter Geinitz (Wayfarer)
77
*/
88

9+
using System.Runtime.CompilerServices;
10+
911
namespace Imaging.Texture
1012
{
1113
/// <summary>
@@ -103,6 +105,50 @@ public static TextureConfig GetPlasmaArcConfig()
103105
};
104106
}
105107

108+
/// <summary>
109+
/// Gets the furrowed tree bark configuration.
110+
/// </summary>
111+
/// <returns>The tree bark configuration.</returns>
112+
public static TextureConfig GetTreeBarkConfig()
113+
{
114+
return new TextureConfig
115+
{
116+
TurbulenceSize = 16.0, // Maps to horizontal frequency scale
117+
WarpStrength = 12.0, // Grain twisting displacement power
118+
CenterRgb = [140, 95, 55], // Bright ridge wood highlight color
119+
EdgeRgb = [75, 45, 25] // Dark deep furrow crease color
120+
};
121+
}
122+
123+
/// <summary>
124+
/// Gets the leaf foliage configuration.
125+
/// </summary>
126+
/// <returns>The leaf foliage configuration.</returns>
127+
public static TextureConfig GetFoliageConfig()
128+
{
129+
return new TextureConfig
130+
{
131+
CellSize = 40,
132+
CenterRgb = [34, 110, 24], // Primary outer leaf green color
133+
EdgeRgb = [12, 35, 10] // Deep background ambient shadow drop color
134+
};
135+
}
136+
137+
/// <summary>
138+
/// Gets the wooden plank board configuration.
139+
/// </summary>
140+
/// <returns>The wooden plank board configuration.</returns>
141+
public static TextureConfig GetWoodPlankConfig()
142+
{
143+
return new TextureConfig
144+
{
145+
TurbulenceSize = 32.0,
146+
WarpStrength = 0.15, // Reusing WarpStrength for internal Engine TurbulencePower
147+
CenterRgb = [130, 85, 45], // Base board brown
148+
EdgeRgb = [70, 40, 20] // Dark grain accent lines
149+
};
150+
}
151+
106152
// --- GENERATORS ---
107153

108154
/// <summary>
@@ -211,5 +257,73 @@ public static RawTextureBuffer GeneratePlasmaArc(int width, int height, object n
211257
width, height, noiseGen, config.RgbRamp,
212258
config.TurbulenceSize, config.Octaves, config.Persistence, 255);
213259
}
260+
261+
/// <summary>
262+
/// Generates the furrowed organic tree bark.
263+
/// </summary>
264+
/// <param name="width">The width.</param>
265+
/// <param name="height">The height.</param>
266+
/// <param name="noiseGen">The noise gen instance wrapper.</param>
267+
/// <returns>The generated raw texture buffer containing tree bark.</returns>
268+
public static RawTextureBuffer GenerateTreeBark(int width, int height, object noiseGen)
269+
{
270+
var config = GetTreeBarkConfig();
271+
272+
return TextureMathEngine.GenerateTreeBark(
273+
width,
274+
height,
275+
noiseGen,
276+
255,
277+
config.TurbulenceSize,
278+
70.0, // Stretched macro Y-scaling baseline footprint
279+
config.WarpStrength,
280+
config.EdgeRgb[0], config.EdgeRgb[1], config.EdgeRgb[2],
281+
config.CenterRgb[0], config.CenterRgb[1], config.CenterRgb[2]
282+
);
283+
}
284+
285+
/// <summary>
286+
/// Generates the interlocking leaf foliage canopy.
287+
/// </summary>
288+
/// <param name="width">The width.</param>
289+
/// <param name="height">The height.</param>
290+
/// <returns>The generated raw texture buffer containing leaf foliage.</returns>
291+
public static RawTextureBuffer GenerateFoliage(int width, int height)
292+
{
293+
var config = GetFoliageConfig();
294+
295+
return TextureMathEngine.GenerateFoliage(
296+
width,
297+
height,
298+
config.CellSize,
299+
255,
300+
config.CenterRgb[0], config.CenterRgb[1], config.CenterRgb[2],
301+
config.EdgeRgb[0], config.EdgeRgb[1], config.EdgeRgb[2]
302+
);
303+
}
304+
305+
/// <summary>
306+
/// Generates a longitudinal sawn wood board texture.
307+
/// </summary>
308+
/// <param name="width">The width.</param>
309+
/// <param name="height">The height.</param>
310+
/// <param name="noiseGen">The noise gen instance wrapper.</param>
311+
/// <returns>The generated raw texture buffer containing a wood plank.</returns>
312+
public static RawTextureBuffer GenerateWoodPlank(int width, int height, object noiseGen)
313+
{
314+
var config = GetWoodPlankConfig();
315+
316+
return TextureMathEngine.GenerateWoodPlank(
317+
width,
318+
height,
319+
noiseGen,
320+
255,
321+
6.0,
322+
config.WarpStrength,
323+
config.TurbulenceSize,
324+
config.CenterRgb[0], config.CenterRgb[1], config.CenterRgb[2],
325+
config.EdgeRgb[0], config.EdgeRgb[1], config.EdgeRgb[2]
326+
);
327+
}
214328
}
215-
}
329+
}

0 commit comments

Comments
 (0)