From e79d7149ea751e32312cb8625548085d4537c591 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 1 Jun 2017 22:38:07 -0300 Subject: [PATCH] GI probes working back again --- drivers/gles3/shaders/scene.glsl | 8 ++++---- scene/3d/gi_probe.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 5c65e10dbe0..f35e04c5e43 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -672,7 +672,7 @@ LIGHT_SHADER_CODE diffuse+= light_color * diffuse_color * lightScatter * viewScatter * energyFactor; } #else - + //lambert diffuse += dotNL * light_color * diffuse_color; #endif @@ -1020,7 +1020,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta #ifdef USE_GI_PROBES -uniform mediump sampler3D gi_probe1; //texunit:-11 +uniform mediump sampler3D gi_probe1; //texunit:-10 uniform highp mat4 gi_probe_xform1; uniform highp vec3 gi_probe_bounds1; uniform highp vec3 gi_probe_cell_size1; @@ -1028,7 +1028,7 @@ uniform highp float gi_probe_multiplier1; uniform highp float gi_probe_bias1; uniform bool gi_probe_blend_ambient1; -uniform mediump sampler3D gi_probe2; //texunit:-10 +uniform mediump sampler3D gi_probe2; //texunit:-11 uniform highp mat4 gi_probe_xform2; uniform highp vec3 gi_probe_bounds2; uniform highp vec3 gi_probe_cell_size2; @@ -1345,7 +1345,7 @@ FRAGMENT_SHADER_CODE { //read radiance from dual paraboloid vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n); - ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz); + ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz); vec3 radiance = textureDualParabolod(radiance_map,ref_vec,lod) * bg_energy; specular_light = radiance; diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 96311236ef6..3542b8b8761 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -885,7 +885,7 @@ Vector GIProbe::_get_bake_texture(Ref p_image, const Color &p_colo Vector ret; - if (p_image.is_null()) { + if (p_image.is_null() || p_image->empty()) { ret.resize(bake_texture_size * bake_texture_size); for (int i = 0; i < bake_texture_size * bake_texture_size; i++) { @@ -894,9 +894,11 @@ Vector GIProbe::_get_bake_texture(Ref p_image, const Color &p_colo return ret; } + p_image = p_image->duplicate(); if (p_image->is_compressed()) { print_line("DECOMPRESSING!!!!"); + p_image->decompress(); } p_image->convert(Image::FORMAT_RGBA8); @@ -1277,6 +1279,7 @@ void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Refset_instance_transform(idx, xform); Color col = Color(p_baker->bake_cells[p_idx].albedo[0], p_baker->bake_cells[p_idx].albedo[1], p_baker->bake_cells[p_idx].albedo[2]); + //Color col = Color(p_baker->bake_cells[p_idx].emission[0], p_baker->bake_cells[p_idx].emission[1], p_baker->bake_cells[p_idx].emission[2]); p_multimesh->set_instance_color(idx, col); idx++; @@ -1464,7 +1467,7 @@ GIProbe::GIProbe() { subdiv = SUBDIV_128; dynamic_range = 4; energy = 1.0; - bias = 0.4; + bias = 1.8; propagation = 1.0; extents = Vector3(10, 10, 10); color_scan_cell_width = 4;