Skip to content

Commit

Permalink
Merge pull request #1468 from zenustech/improve-for-terrian
Browse files Browse the repository at this point in the history
write 32 exr & ImageColor2
  • Loading branch information
littlemine authored Oct 13, 2023
2 parents 9e2924c + af819d7 commit 4ed3aa2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions projects/ImgCV/ImageProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,47 @@ ZENDEFNODE(ImageColor, {
{"image"},
},
{},
{ "deprecated" },
});
struct ImageColor2 : INode {
virtual void apply() override {
auto image = std::make_shared<PrimitiveObject>();
auto color = get_input2<vec3f>("Color");
auto alpha = get_input2<float>("Alpha");
auto size = get_input2<vec2i>("Size");
auto balpha = get_input2<bool>("alpha");
auto vertsize = size[0] * size[1];
image->verts.resize(vertsize);
image->userData().set2("isImage", 1);
image->userData().set2("w", size[0]);
image->userData().set2("h", size[1]);
if(balpha){
auto &alphaAttr = image->verts.add_attr<float>("alpha");
for (int i = 0; i < vertsize ; i++) {
image->verts[i] = {zeno::clamp(color[0], 0.0f, 1.0f), zeno::clamp(color[1], 0.0f, 1.0f), zeno::clamp(color[2], 0.0f, 1.0f)};
alphaAttr[i] = zeno::clamp(alpha, 0.0f, 1.0f);
}
}
else{
for (int i = 0; i < vertsize ; i++) {
image->verts[i] = {zeno::clamp(color[0], 0.0f, 1.0f), zeno::clamp(color[1], 0.0f, 1.0f), zeno::clamp(color[2], 0.0f, 1.0f)};
}
}
set_output("image", image);
}
};

ZENDEFNODE(ImageColor2, {
{
{"vec3f", "Color", "1,1,1"},
{"float", "Alpha", "1"},
{"vec2i", "Size", "1024,1024"},
{"bool", "alpha", "1"},
},
{
{"image"},
},
{},
{ "image" },
});

Expand Down
2 changes: 1 addition & 1 deletion zeno/src/nodes/prim/UVProjectFromPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ struct WriteImageFile : INode {
const char* err;
path += ".exr";
std::string native_path = std::filesystem::u8path(path).string();
int ret = SaveEXR(data2.data(),w,h,n,1,native_path.c_str(),&err);
int ret = SaveEXR(data2.data(),w,h,n,0,native_path.c_str(),&err);

if (ret != TINYEXR_SUCCESS) {
zeno::log_error("Error saving EXR file: {}\n", err);
Expand Down

0 comments on commit 4ed3aa2

Please sign in to comment.