-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor concrete texture generation methods #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Refactor concrete texture generation methods for clarity and efficiency. Improved blending and normalization processes.
Summary of ChangesHello @mawdesign, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant refactoring of the concrete texture generation methods, aiming to improve the modularity, clarity, and efficiency of the texture creation pipeline. The changes enable a more sophisticated approach to blending micro-details and handling normalization, allowing for the generation of highly customizable and realistic tileable concrete textures, either from scratch or by augmenting existing bump maps. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request significantly refactors the concrete texture generation logic, improving clarity, modularity, and efficiency. The introduction of new features like augmenting existing bump maps, making textures seamless, and adding high-pass filtering is a great enhancement. The code is now better structured with dedicated helper functions for normalization and blending. I have a few suggestions to further improve the code, mainly regarding minor code simplification and a potential performance optimization for bitmap processing. Overall, this is a very strong set of changes.
| Normalize01(pitsNoise); | ||
|
|
||
| float threshold = 1f - pitsDensity; // e.g., 0.98 -> 2% pits | ||
| int hh = h, ww = w; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| static float[,] BitmapToFloat01(Bitmap bmp) | ||
| { | ||
| int h = img.GetLength(0); | ||
| int w = img.GetLength(1); | ||
|
|
||
| // Normalize to [0,1] using min/max | ||
| float min = float.MaxValue, max = float.MinValue; | ||
| int w = bmp.Width, h = bmp.Height; | ||
| float[,] img = new float[h, w]; | ||
| for (int y = 0; y < h; y++) | ||
| { | ||
| for (int x = 0; x < w; x++) | ||
| { float v = img[y, x]; if (v < min) min = v; if (v > max) max = v; } | ||
| { | ||
| var c = bmp.GetPixel(x, y); | ||
| float v = (0.2126f * c.R + 0.7152f * c.G + 0.0722f * c.B) / 255f; // luminance | ||
| img[y, x] = v; | ||
| } | ||
| } | ||
| Normalize01(img); | ||
| return img; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Normalize01(baseLayer); Normalize01(grain); Normalize01(pitsNoise); | ||
|
|
||
| // Optional: expand contrast (simple min/max normalization happens in SaveGrayscale24) | ||
| int hh = h, ww = w; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor concrete texture generation methods for clarity and efficiency. Improved blending and normalization processes.