many fixes to image loader, voxel cone tracing, etc.

This commit is contained in:
Juan Linietsky 2017-06-02 22:08:41 -03:00
parent e79d7149ea
commit 8a1097a224
5 changed files with 10 additions and 8 deletions

View file

@ -24,7 +24,7 @@ layout(location = 0) out float visibility;
// Tunable Parameters:
/** 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
first AO pass. This constant can be increased while R decreases to improve

View file

@ -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) {
int len = p_data.size();
ERR_FAIL_COND_V(len < 4, Ref<Image>());
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>());
return _load_mem_png(&r[4], len - 4);

View file

@ -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 src_ofs = p_image->get_mipmap_offset(i);
squish::CompressImage(&rb[src_ofs], bw, bh, &wb[dst_ofs], squish_comp);
dst_ofs += (MAX(4, w) * MAX(4, h)) >> shift;
squish::CompressImage(&rb[src_ofs], w, h, &wb[dst_ofs], squish_comp);
dst_ofs += (MAX(4, bw) * MAX(4, bh)) >> shift;
w >>= 1;
h >>= 1;
}

View file

@ -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++) {
Color c;
c.r = r[i * 4 + 0] / 255.0;
c.g = r[i * 4 + 1] / 255.0;
c.b = r[i * 4 + 2] / 255.0;
c.r = (r[i * 4 + 0] / 255.0) * p_color.r;
c.g = (r[i * 4 + 1] / 255.0) * p_color.g;
c.b = (r[i * 4 + 2] / 255.0) * p_color.b;
c.a = r[i * 4 + 3] / 255.0;
ret[i] = c;
}

View file

@ -494,9 +494,9 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla
img = Image::lossy_unpacker(pv);
}
if (img.is_null()) {
if (img.is_null() || img->empty()) {
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();