Skip to content

Commit

Permalink
Merge branch 'master' into coloreditor
Browse files Browse the repository at this point in the history
  • Loading branch information
miyanyan committed Sep 20, 2023
2 parents 0e499e7 + 7d29ecf commit 9ee569d
Show file tree
Hide file tree
Showing 29 changed files with 13,457 additions and 649 deletions.
2 changes: 1 addition & 1 deletion projects/Alembic/Alembic
Submodule Alembic updated 2 files
+2 −2 CMakeLists.txt
+1 −1 openexr
26 changes: 26 additions & 0 deletions projects/Alembic/png16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ static std::shared_ptr<zeno::PrimitiveObject> read_png(const char* file_path) {
png_bytep* row_pointers = png_get_rows(png_ptr, info_ptr);
std::vector<zeno::vec3f> image_data;
image_data.reserve(width * height);
std::vector<float> alpha_data;
alpha_data.reserve(width * height);

for (int y = 0; y < height; y++) {
png_bytep row = row_pointers[y];
for (int x = 0; x < width; x++) {
zeno::vec3f color;
float alpha = 1;
if (bit_depth == 16) {
if (channels == 1) {
uint16_t value = (row[x * 2] << 8) | row[x * 2 + 1];
Expand All @@ -75,6 +78,16 @@ static std::shared_ptr<zeno::PrimitiveObject> read_png(const char* file_path) {
color[0] = float(r) / 65535.0f;
color[1] = float(g) / 65535.0f;
color[2] = float(b) / 65535.0f;
} else if (channels == 4) {
uint16_t r = (row[x * 8] << 8) | row[x * 8 + 1];
uint16_t g = (row[x * 8 + 2] << 8) | row[x * 8 + 3];
uint16_t b = (row[x * 8 + 4] << 8) | row[x * 8 + 5];
uint16_t a = (row[x * 8 + 6] << 8) | row[x * 8 + 7];

color[0] = float(r) / 65535.0f;
color[1] = float(g) / 65535.0f;
color[2] = float(b) / 65535.0f;
alpha = float(a) / 65535.0f;
}
} else if (bit_depth == 8) {
if (channels == 1) {
Expand All @@ -89,17 +102,30 @@ static std::shared_ptr<zeno::PrimitiveObject> read_png(const char* file_path) {
color[0] = float(r) / 255.0f;
color[1] = float(g) / 255.0f;
color[2] = float(b) / 255.0f;
} else if (channels == 4) {
uint8_t r = row[x * 4];
uint8_t g = row[x * 4 + 1];
uint8_t b = row[x * 4 + 2];
uint8_t a = row[x * 4 + 4];

color[0] = float(r) / 255.0f;
color[1] = float(g) / 255.0f;
color[2] = float(b) / 255.0f;
alpha = float(a) / 255.0f;
}
}

image_data.push_back(color);
alpha_data.push_back(alpha);
}
}

png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
fclose(file);
zeno::image_flip_vertical(image_data.data(), width, height);
img->verts.values = image_data;
zeno::image_flip_vertical(alpha_data.data(), width, height);
img->add_attr<float>("alpha") = alpha_data;
img->userData().set2("isImage", 1);
img->userData().set2("w", width);
img->userData().set2("h", height);
Expand Down
5 changes: 5 additions & 0 deletions projects/FastFLIP/FLIP_vdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2902,13 +2902,18 @@ void FLIP_vdb::apply_pressure_gradient(
bool has_pressure_below = pressure_axr.isValueOn(lower_gcoord);

if (has_pressure || has_pressure_below) {
has_update = true;

#if 0
// To do: fix the deactivated flip particles
auto phi_this = phi_axr.getValue(gcoord);
auto phi_below = phi_axr.getValue(lower_gcoord);

if((phi_this + phi_below)<0)
has_update = true;
else
has_update = false;
#endif
}

if (has_update) {
Expand Down
Loading

0 comments on commit 9ee569d

Please sign in to comment.