Fix image formats L8 and LA8 not being accepted by the Image2D node
parent
bebafd263e
commit
cef8bd927a
|
@ -25,6 +25,7 @@ Ongoing development - `godot4` branch
|
|||
- `VoxelBuffer`: frequently creating buffers with always different sizes no longer wastes memory
|
||||
- `Voxel`: properties of the inspector were not refreshed when changing `geometry_type`
|
||||
- `VoxelGeneratorGraph`: editor: fix inspector starting to throw errors after deleting a node, as it is still inspecting it
|
||||
- `VoxelGeneratorGraph`: fixed Image2D node not accepting image formats L8 and LA8
|
||||
- `VoxelTerrain`: fixed `Condition "mesh_block == nullptr" is true` which could happen in some conditions
|
||||
- `VoxelTool`: `raycast` locking up if you send a Vector3 containing NaN
|
||||
- `VoxelInstancer`: fix instances not refreshing when an item is modified and the mesh block size is 32
|
||||
|
|
|
@ -25,7 +25,9 @@ void ImageRangeGrid::clear() {
|
|||
_lod_count = 0;
|
||||
}
|
||||
|
||||
void ImageRangeGrid::generate(Image &im) {
|
||||
void ImageRangeGrid::generate(const Image &im) {
|
||||
ERR_FAIL_COND_MSG(im.is_compressed(), String("Image format not supported: {0}").format(varray(im.get_format())));
|
||||
|
||||
clear();
|
||||
|
||||
const int lod_base = 4; // Start at 16
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
~ImageRangeGrid();
|
||||
|
||||
void clear();
|
||||
void generate(Image &im);
|
||||
void generate(const Image &im);
|
||||
inline math::Interval get_range() const {
|
||||
return _total_range;
|
||||
}
|
||||
|
|
|
@ -221,46 +221,29 @@ Interval get_curve_range(Curve &curve, bool &is_monotonic_increasing) {
|
|||
return range;
|
||||
}
|
||||
|
||||
Interval get_heightmap_range(Image &im) {
|
||||
Interval get_heightmap_range(const Image &im) {
|
||||
return get_heightmap_range(im, Rect2i(0, 0, im.get_width(), im.get_height()));
|
||||
}
|
||||
|
||||
Interval get_heightmap_range(Image &im, Rect2i rect) {
|
||||
switch (im.get_format()) {
|
||||
case Image::FORMAT_R8:
|
||||
case Image::FORMAT_RG8:
|
||||
case Image::FORMAT_RGB8:
|
||||
case Image::FORMAT_RGBA8:
|
||||
case Image::FORMAT_RH:
|
||||
case Image::FORMAT_RGH:
|
||||
case Image::FORMAT_RGBH:
|
||||
case Image::FORMAT_RGBAH:
|
||||
case Image::FORMAT_RF:
|
||||
case Image::FORMAT_RGF:
|
||||
case Image::FORMAT_RGBF:
|
||||
case Image::FORMAT_RGBAF: {
|
||||
Interval r;
|
||||
Interval get_heightmap_range(const Image &im, Rect2i rect) {
|
||||
ERR_FAIL_COND_V_MSG(
|
||||
im.is_compressed(), Interval(), String("Image format not supported: {0}").format(varray(im.get_format())));
|
||||
|
||||
r.min = im.get_pixel(0, 0).r;
|
||||
r.max = r.min;
|
||||
Interval r;
|
||||
|
||||
const int max_x = rect.position.x + rect.size.x;
|
||||
const int max_y = rect.position.y + rect.size.y;
|
||||
r.min = im.get_pixel(0, 0).r;
|
||||
r.max = r.min;
|
||||
|
||||
for (int y = rect.position.y; y < max_y; ++y) {
|
||||
for (int x = rect.position.x; x < max_x; ++x) {
|
||||
r.add_point(im.get_pixel(x, y).r);
|
||||
}
|
||||
}
|
||||
const int max_x = rect.position.x + rect.size.x;
|
||||
const int max_y = rect.position.y + rect.size.y;
|
||||
|
||||
return r;
|
||||
} break;
|
||||
|
||||
default:
|
||||
ERR_FAIL_V_MSG(Interval(), "Image format not supported");
|
||||
break;
|
||||
for (int y = rect.position.y; y < max_y; ++y) {
|
||||
for (int x = rect.position.x; x < max_x; ++x) {
|
||||
r.add_point(im.get_pixel(x, y).r);
|
||||
}
|
||||
}
|
||||
return Interval();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
namespace math {
|
||||
|
@ -315,7 +298,8 @@ SdfAffectingArguments sdf_polynomial_smooth_union_side(Interval a, Interval b, f
|
|||
return SDF_BOTH;
|
||||
}
|
||||
|
||||
template <typename F> inline Interval sdf_smooth_op(Interval b, Interval a, float s, F smooth_op_func) {
|
||||
template <typename F>
|
||||
inline Interval sdf_smooth_op(Interval b, Interval a, float s, F smooth_op_func) {
|
||||
// Smooth union and subtract are a generalization of `min(a, b)` and `max(-a, b)`, with a smooth junction.
|
||||
// That junction runs in a diagonal crossing zero (with equation `y = -x`).
|
||||
// Areas on the two sides of the junction are monotonic, i.e their derivatives should never cross zero,
|
||||
|
|
|
@ -44,8 +44,8 @@ math::Interval get_curve_range(Curve &curve, const std::vector<CurveMonotonicSec
|
|||
// Legacy
|
||||
math::Interval get_curve_range(Curve &curve, bool &is_monotonic_increasing);
|
||||
|
||||
math::Interval get_heightmap_range(Image &im);
|
||||
math::Interval get_heightmap_range(Image &im, Rect2i rect);
|
||||
math::Interval get_heightmap_range(const Image &im);
|
||||
math::Interval get_heightmap_range(const Image &im, Rect2i rect);
|
||||
|
||||
namespace math {
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ VoxelGraphNodeDB *g_node_type_db = nullptr;
|
|||
|
||||
using namespace math;
|
||||
|
||||
template <typename F> inline void do_monop(VoxelGraphRuntime::ProcessBufferContext &ctx, F f) {
|
||||
template <typename F>
|
||||
inline void do_monop(VoxelGraphRuntime::ProcessBufferContext &ctx, F f) {
|
||||
const VoxelGraphRuntime::Buffer &a = ctx.get_input(0);
|
||||
VoxelGraphRuntime::Buffer &out = ctx.get_output(0);
|
||||
for (uint32_t i = 0; i < a.size; ++i) {
|
||||
|
@ -28,7 +29,8 @@ template <typename F> inline void do_monop(VoxelGraphRuntime::ProcessBufferConte
|
|||
}
|
||||
}
|
||||
|
||||
template <typename F> inline void do_binop(VoxelGraphRuntime::ProcessBufferContext &ctx, F f) {
|
||||
template <typename F>
|
||||
inline void do_binop(VoxelGraphRuntime::ProcessBufferContext &ctx, F f) {
|
||||
const VoxelGraphRuntime::Buffer &a = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &b = ctx.get_input(1);
|
||||
VoxelGraphRuntime::Buffer &out = ctx.get_output(0);
|
||||
|
@ -939,6 +941,10 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
|||
ctx.make_error("Image instance is null");
|
||||
return;
|
||||
}
|
||||
if (image->is_compressed()) {
|
||||
ctx.make_error("Image has a compressed format, this is not supported");
|
||||
return;
|
||||
}
|
||||
ImageRangeGrid *im_range = memnew(ImageRangeGrid);
|
||||
im_range->generate(**image);
|
||||
Params p;
|
||||
|
|
Loading…
Reference in New Issue