mirror of
https://github.com/godotengine/godot
synced 2024-09-05 05:58:29 +00:00
many fixes to image loader, voxel cone tracing, etc.
This commit is contained in:
parent
e79d7149ea
commit
8a1097a224
|
@ -24,7 +24,7 @@ layout(location = 0) out float visibility;
|
||||||
// Tunable Parameters:
|
// Tunable Parameters:
|
||||||
|
|
||||||
/** Increase to make depth edges crisper. Decrease to reduce flicker. */
|
/** Increase to make depth edges crisper. Decrease to reduce flicker. */
|
||||||
#define EDGE_SHARPNESS (1.0)
|
#define EDGE_SHARPNESS (4.0)
|
||||||
|
|
||||||
/** Step in 2-pixel intervals since we already blurred against neighbors in the
|
/** Step in 2-pixel intervals since we already blurred against neighbors in the
|
||||||
first AO pass. This constant can be increased while R decreases to improve
|
first AO pass. This constant can be increased while R decreases to improve
|
||||||
|
|
|
@ -256,6 +256,7 @@ static Ref<Image> _load_mem_png(const uint8_t *p_png, int p_size) {
|
||||||
static Ref<Image> _lossless_unpack_png(const PoolVector<uint8_t> &p_data) {
|
static Ref<Image> _lossless_unpack_png(const PoolVector<uint8_t> &p_data) {
|
||||||
|
|
||||||
int len = p_data.size();
|
int len = p_data.size();
|
||||||
|
ERR_FAIL_COND_V(len < 4, Ref<Image>());
|
||||||
PoolVector<uint8_t>::Read r = p_data.read();
|
PoolVector<uint8_t>::Read r = p_data.read();
|
||||||
ERR_FAIL_COND_V(r[0] != 'P' || r[1] != 'N' || r[2] != 'G' || r[3] != ' ', Ref<Image>());
|
ERR_FAIL_COND_V(r[0] != 'P' || r[1] != 'N' || r[2] != 'G' || r[3] != ' ', Ref<Image>());
|
||||||
return _load_mem_png(&r[4], len - 4);
|
return _load_mem_png(&r[4], len - 4);
|
||||||
|
|
|
@ -153,8 +153,8 @@ void image_compress_squish(Image *p_image, bool p_srgb) {
|
||||||
int bh = h % 4 != 0 ? h + (4 - h % 4) : h;
|
int bh = h % 4 != 0 ? h + (4 - h % 4) : h;
|
||||||
|
|
||||||
int src_ofs = p_image->get_mipmap_offset(i);
|
int src_ofs = p_image->get_mipmap_offset(i);
|
||||||
squish::CompressImage(&rb[src_ofs], bw, bh, &wb[dst_ofs], squish_comp);
|
squish::CompressImage(&rb[src_ofs], w, h, &wb[dst_ofs], squish_comp);
|
||||||
dst_ofs += (MAX(4, w) * MAX(4, h)) >> shift;
|
dst_ofs += (MAX(4, bw) * MAX(4, bh)) >> shift;
|
||||||
w >>= 1;
|
w >>= 1;
|
||||||
h >>= 1;
|
h >>= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -909,10 +909,11 @@ Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_colo
|
||||||
|
|
||||||
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
|
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
|
||||||
Color c;
|
Color c;
|
||||||
c.r = r[i * 4 + 0] / 255.0;
|
c.r = (r[i * 4 + 0] / 255.0) * p_color.r;
|
||||||
c.g = r[i * 4 + 1] / 255.0;
|
c.g = (r[i * 4 + 1] / 255.0) * p_color.g;
|
||||||
c.b = r[i * 4 + 2] / 255.0;
|
c.b = (r[i * 4 + 2] / 255.0) * p_color.b;
|
||||||
c.a = r[i * 4 + 3] / 255.0;
|
c.a = r[i * 4 + 3] / 255.0;
|
||||||
|
|
||||||
ret[i] = c;
|
ret[i] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -494,9 +494,9 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla
|
||||||
img = Image::lossy_unpacker(pv);
|
img = Image::lossy_unpacker(pv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img.is_null()) {
|
if (img.is_null() || img->empty()) {
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
ERR_FAIL_COND_V(img->empty(), ERR_FILE_CORRUPT);
|
ERR_FAIL_COND_V(img.is_null() || img->empty(), ERR_FILE_CORRUPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
total_size += img->get_data().size();
|
total_size += img->get_data().size();
|
||||||
|
|
Loading…
Reference in a new issue