mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Many fixes to improve GI Probe quality
This commit is contained in:
parent
5dd7c3b6ab
commit
3da3a36034
12 changed files with 105 additions and 18 deletions
|
|
@ -1172,6 +1172,7 @@ uniform highp vec3 gi_probe_bounds1;
|
|||
uniform highp vec3 gi_probe_cell_size1;
|
||||
uniform highp float gi_probe_multiplier1;
|
||||
uniform highp float gi_probe_bias1;
|
||||
uniform highp float gi_probe_normal_bias1;
|
||||
uniform bool gi_probe_blend_ambient1;
|
||||
|
||||
uniform mediump sampler3D gi_probe2; //texunit:-10
|
||||
|
|
@ -1180,12 +1181,12 @@ uniform highp vec3 gi_probe_bounds2;
|
|||
uniform highp vec3 gi_probe_cell_size2;
|
||||
uniform highp float gi_probe_multiplier2;
|
||||
uniform highp float gi_probe_bias2;
|
||||
uniform highp float gi_probe_normal_bias2;
|
||||
uniform bool gi_probe2_enabled;
|
||||
uniform bool gi_probe_blend_ambient2;
|
||||
|
||||
vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, bool blend_ambient, vec3 direction, float tan_half_angle, float max_distance, float p_bias) {
|
||||
|
||||
|
||||
float dist = p_bias;//1.0; //dot(direction,mix(vec3(-1.0),vec3(1.0),greaterThan(direction,vec3(0.0))))*2.0;
|
||||
float alpha=0.0;
|
||||
vec3 color = vec3(0.0);
|
||||
|
|
@ -1206,27 +1207,30 @@ vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, b
|
|||
return color;
|
||||
}
|
||||
|
||||
void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness,float p_bias, out vec4 out_spec, out vec4 out_diff) {
|
||||
void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness,float p_bias,float p_normal_bias, inout vec4 out_spec, inout vec4 out_diff) {
|
||||
|
||||
|
||||
|
||||
vec3 probe_pos = (probe_xform * vec4(pos,1.0)).xyz;
|
||||
vec3 ref_pos = (probe_xform * vec4(pos+ref_vec,1.0)).xyz;
|
||||
|
||||
ref_vec = normalize(ref_pos - probe_pos);
|
||||
|
||||
probe_pos+=(probe_xform * vec4(normal_mtx[2],0.0)).xyz*p_normal_bias;
|
||||
|
||||
/* out_diff.rgb = voxel_cone_trace(probe,cell_size,probe_pos,normalize((probe_xform * vec4(ref_vec,0.0)).xyz),0.0 ,100.0);
|
||||
out_diff.a = 1.0;
|
||||
return;*/
|
||||
//out_diff = vec4(textureLod(probe,probe_pos*cell_size,3.0).rgb,1.0);
|
||||
//return;
|
||||
|
||||
if (any(bvec2(any(lessThan(probe_pos,vec3(0.0))),any(greaterThan(probe_pos,bounds)))))
|
||||
//this causes corrupted pixels, i have no idea why..
|
||||
if (any(bvec2(any(lessThan(probe_pos,vec3(0.0))),any(greaterThan(probe_pos,bounds))))) {
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 blendv = probe_pos/bounds * 2.0 - 1.0;
|
||||
float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z));
|
||||
blend=1.0;
|
||||
//vec3 blendv = probe_pos/bounds * 2.0 - 1.0;
|
||||
//float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z));
|
||||
float blend=1.0;
|
||||
|
||||
float max_distance = length(bounds);
|
||||
|
||||
|
|
@ -1273,7 +1277,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
|
|||
|
||||
light*=multiplier;
|
||||
|
||||
out_diff = vec4(light*blend,blend);
|
||||
out_diff += vec4(light*blend,blend);
|
||||
|
||||
//irradiance
|
||||
|
||||
|
|
@ -1282,7 +1286,8 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
|
|||
irr_light *= multiplier;
|
||||
//irr_light=vec3(0.0);
|
||||
|
||||
out_spec = vec4(irr_light*blend,blend);
|
||||
out_spec += vec4(irr_light*blend,blend);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1308,11 +1313,11 @@ void gi_probes_compute(vec3 pos, vec3 normal, float roughness, inout vec3 out_sp
|
|||
|
||||
out_specular = vec3(0.0);
|
||||
|
||||
gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,gi_probe_bias1,spec_accum,diff_accum);
|
||||
gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,gi_probe_bias1,gi_probe_normal_bias1,spec_accum,diff_accum);
|
||||
|
||||
if (gi_probe2_enabled) {
|
||||
|
||||
gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,gi_probe_bias2,spec_accum,diff_accum);
|
||||
gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,gi_probe_bias2,gi_probe_normal_bias2,spec_accum,diff_accum);
|
||||
}
|
||||
|
||||
if (diff_accum.a>0.0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue