You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
ReflectionProbe add Blend Distance
This commit is contained in:
@@ -41,10 +41,14 @@ struct ReflectionData {
|
||||
uint mask;
|
||||
mediump vec3 ambient; // ambient color
|
||||
mediump float intensity;
|
||||
mediump float blend_distance;
|
||||
bool exterior;
|
||||
bool box_project;
|
||||
uint ambient_mode;
|
||||
float exposure_normalization;
|
||||
float pad0;
|
||||
float pad1;
|
||||
float pad2;
|
||||
//0-8 is intensity,8-9 is ambient, mode
|
||||
highp mat4 local_matrix; // up to here for spot and omni, rest is for directional
|
||||
// notes: for ambientblend, use distance to edge to blend between already existing global environment
|
||||
|
||||
@@ -876,11 +876,20 @@ void reflection_process(uint ref_index, vec3 vertex, vec3 ref_vec, vec3 normal,
|
||||
}
|
||||
|
||||
vec3 inner_pos = abs(local_pos / box_extents);
|
||||
float blend = max(inner_pos.x, max(inner_pos.y, inner_pos.z));
|
||||
//make blend more rounded
|
||||
blend = mix(length(inner_pos), blend, blend);
|
||||
blend *= blend;
|
||||
vec3 blend_axes = vec3(0.0, 0.0, 0.0);
|
||||
float blend = 0.0;
|
||||
if (reflections.data[ref_index].blend_distance != 0) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float axis_blend_distance = min(reflections.data[ref_index].blend_distance, box_extents[i]);
|
||||
blend_axes[i] = (inner_pos[i] * box_extents[i]) - box_extents[i] + axis_blend_distance;
|
||||
blend_axes[i] = blend_axes[i] / axis_blend_distance;
|
||||
blend_axes[i] = clamp(blend_axes[i], 0.0, 1.0);
|
||||
}
|
||||
blend = pow((1.0 - blend_axes.x) * (1.0 - blend_axes.y) * (1.0 - blend_axes.z), 2);
|
||||
blend = 1 - blend;
|
||||
}
|
||||
blend = max(0.0, 1.0 - blend);
|
||||
blend = clamp(blend, 0.0, 1.0);
|
||||
|
||||
if (reflections.data[ref_index].intensity > 0.0) { // compute reflection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user