trying to fix noise.
This commit is contained in:
@@ -76,6 +76,7 @@ void Preview(Grid2& grid) {
|
|||||||
//std::vector<uint8_t> rgbData;
|
//std::vector<uint8_t> rgbData;
|
||||||
|
|
||||||
frame rgbData = grid.getGridAsFrame(frame::colormap::RGB);
|
frame rgbData = grid.getGridAsFrame(frame::colormap::RGB);
|
||||||
|
std::cout << "Frame looks like: " << rgbData << std::endl;
|
||||||
bool success = BMPWriter::saveBMP("output/grayscalesource.bmp", rgbData);
|
bool success = BMPWriter::saveBMP("output/grayscalesource.bmp", rgbData);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
std::cout << "yo! this failed in Preview" << std::endl;
|
std::cout << "yo! this failed in Preview" << std::endl;
|
||||||
@@ -261,13 +262,13 @@ void mainLogic(const AnimationConfig& config, Shared& state, int gradnoise) {
|
|||||||
// Print compression info for this frame
|
// Print compression info for this frame
|
||||||
if (i % 10 == 0 ) {
|
if (i % 10 == 0 ) {
|
||||||
frame bgrframe;
|
frame bgrframe;
|
||||||
std::cout << "Processing frame " << i + 1 << "/" << config.totalFrames << std::endl;
|
//std::cout << "Processing frame " << i + 1 << "/" << config.totalFrames << std::endl;
|
||||||
bgrframe = grid.getGridAsFrame(frame::colormap::BGR);
|
bgrframe = grid.getGridAsFrame(frame::colormap::BGR);
|
||||||
frames.push_back(bgrframe);
|
frames.push_back(bgrframe);
|
||||||
//bgrframe.decompress();
|
//bgrframe.decompress();
|
||||||
//BMPWriter::saveBMP(std::format("output/grayscalesource.{}.bmp", i), bgrframe);
|
//BMPWriter::saveBMP(std::format("output/grayscalesource.{}.bmp", i), bgrframe);
|
||||||
bgrframe.compressFrameLZ78();
|
bgrframe.compressFrameLZ78();
|
||||||
bgrframe.printCompressionStats();
|
//bgrframe.printCompressionStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exportavi(frames,config);
|
exportavi(frames,config);
|
||||||
|
|||||||
@@ -225,6 +225,9 @@ public:
|
|||||||
|
|
||||||
Grid2 noiseGenGrid(size_t minx,size_t miny, size_t maxx, size_t maxy
|
Grid2 noiseGenGrid(size_t minx,size_t miny, size_t maxx, size_t maxy
|
||||||
, float minChance = 0.1f, float maxChance = 1.0f, bool color = true) {
|
, float minChance = 0.1f, float maxChance = 1.0f, bool color = true) {
|
||||||
|
std::cout << "generating a noise grid with the following: (" << minx << ", " << miny
|
||||||
|
<< ") by (" << maxx << ", " << maxy << ") " << "chance: " << minChance
|
||||||
|
<< " max: " << maxChance << " gen colors: " << color << std::endl;
|
||||||
std::vector<Vec2> poses;
|
std::vector<Vec2> poses;
|
||||||
std::vector<Vec4> colors;
|
std::vector<Vec4> colors;
|
||||||
std::vector<float> sizes;
|
std::vector<float> sizes;
|
||||||
@@ -233,6 +236,7 @@ public:
|
|||||||
Vec2 pos = Vec2(x,y);
|
Vec2 pos = Vec2(x,y);
|
||||||
float alpha = noisegen.permute(Vec2(x,y));
|
float alpha = noisegen.permute(Vec2(x,y));
|
||||||
if (alpha > minChance && alpha < maxChance) {
|
if (alpha > minChance && alpha < maxChance) {
|
||||||
|
std::cout << "generating at: " << pos.x << ", " << pos.y << ")" << std::endl;
|
||||||
if (color) {
|
if (color) {
|
||||||
float red = noisegen.permute(pos);
|
float red = noisegen.permute(pos);
|
||||||
float green = noisegen.permute(pos);
|
float green = noisegen.permute(pos);
|
||||||
@@ -585,7 +589,7 @@ public:
|
|||||||
// no return because it passes back a 1d vector of ints between 0 and 255 with a width and height
|
// no return because it passes back a 1d vector of ints between 0 and 255 with a width and height
|
||||||
//get region as rgb
|
//get region as rgb
|
||||||
void getGridRegionAsRGB(const Vec2& minCorner, const Vec2& maxCorner,
|
void getGridRegionAsRGB(const Vec2& minCorner, const Vec2& maxCorner,
|
||||||
int& width, int& height, std::vector<uint8_t>& rgbData) const {
|
int& width, int& height, std::vector<uint8_t>& rgbData) const {
|
||||||
TIME_FUNCTION;
|
TIME_FUNCTION;
|
||||||
// Calculate dimensions
|
// Calculate dimensions
|
||||||
width = static_cast<int>(maxCorner.x - minCorner.x);
|
width = static_cast<int>(maxCorner.x - minCorner.x);
|
||||||
|
|||||||
@@ -14,13 +14,16 @@ private:
|
|||||||
std::default_random_engine rng;
|
std::default_random_engine rng;
|
||||||
float TR,TL,BR,BL;
|
float TR,TL,BR,BL;
|
||||||
public:
|
public:
|
||||||
PNoise2() {
|
PNoise2() : rng(std::random_device{}()){
|
||||||
permutation.reserve(256);
|
//permutation.reserve(256);
|
||||||
for (int i = 0; i < 256; i++){
|
std::vector<float> permutationt;
|
||||||
permutation[i] = i;
|
for (int i = 0; i < 255; i++){
|
||||||
|
//permutation[i] = i;
|
||||||
|
permutationt.push_back(i);
|
||||||
}
|
}
|
||||||
std::ranges::shuffle(permutation, rng);
|
std::ranges::shuffle(permutationt, rng);
|
||||||
permutation.insert(permutation.end(),permutation.begin(),permutation.end());
|
permutation.insert(permutation.end(),permutationt.begin(),permutationt.end());
|
||||||
|
permutation.insert(permutation.end(),permutationt.begin(),permutationt.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
float permute(Vec2 point) {
|
float permute(Vec2 point) {
|
||||||
|
|||||||
@@ -504,4 +504,43 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, frame& f) {
|
||||||
|
os << "Frame[" << f.getWidth() << "x" << f.getHeight() << "] ";
|
||||||
|
|
||||||
|
// Color format
|
||||||
|
os << "Format: ";
|
||||||
|
switch (f.colorFormat) {
|
||||||
|
case frame::colormap::RGB: os << "RGB"; break;
|
||||||
|
case frame::colormap::RGBA: os << "RGBA"; break;
|
||||||
|
case frame::colormap::BGR: os << "BGR"; break;
|
||||||
|
case frame::colormap::BGRA: os << "BGRA"; break;
|
||||||
|
case frame::colormap::B: os << "Grayscale"; break;
|
||||||
|
default: os << "Unknown"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compression info
|
||||||
|
os << " | Compression: " << f.getCompressionTypeString();
|
||||||
|
|
||||||
|
// Size info
|
||||||
|
if (f.isCompressed()) {
|
||||||
|
os << " | " << f.getSourceSize() << "B -> " << f.getTotalCompressedSize()
|
||||||
|
<< "B (ratio: " << std::fixed << std::setprecision(2) << f.getCompressionRatio() << ":1)";
|
||||||
|
} else {
|
||||||
|
os << " | Size: " << f.getData().size() << "B";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data status
|
||||||
|
os << " | Data: ";
|
||||||
|
if (!f.getData().empty()) {
|
||||||
|
os << "raw(" << f.getData().size() << " bytes)";
|
||||||
|
} else if (f.getCompressedDataSize() > 0) {
|
||||||
|
os << "compressed(" << f.getCompressedDataSize() << " words)";
|
||||||
|
} else {
|
||||||
|
os << "empty";
|
||||||
|
}
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user