Refactor/Rewrite overlay wire colors #110097

Closed
Gilberto Rodrigues wants to merge 19 commits from Gilberto.R/blender:temp-fresnelpref into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 11 additions and 27 deletions
Showing only changes of commit 5bd7099eb9 - Show all commits

View File

@ -68,38 +68,15 @@ void main()
bool selected_coloring = is_selected && useColoring;
/* Base Color */
vec3 wire_col, rim_col, no_fresnel_col, fresnel_col;
if (isRandomColor) { /* Dim random color. */
float hue = ObjectInfo.z;
vec3 hsv = vec3(hue, 0.75, 0.8);
wire_col = hsv_to_rgb(hsv);
finalColor.rgb = hsv_to_rgb(hsv);
}
else { /* Initialize variable. */
wire_col = ObjectColor.rgb;
finalColor.rgb = ObjectColor.rgb;
}
wire_col = (isSingleColor) ? colorWire.rgb : wire_col;
/* Fresnel */
no_fresnel_col = wire_col;
rim_col = wire_col;
/* "Normalize" color. */
wire_col += 1e-4; /* Avoid division by 0. */
float brightness = max(wire_col.x, max(wire_col.y, wire_col.z));
wire_col *= 0.5 / brightness;
rim_col += 0.75;
facing = clamp(abs(facing), 0.0, 1.0);
/* Do interpolation in a non-linear space to have a better visual result. */
rim_col = pow(rim_col, vec3(1.0 / 2.2));
wire_col = pow(wire_col, vec3(1.0 / 2.2));
fresnel_col = mix(rim_col, wire_col, 0.35);
fresnel_col = mix(rim_col, fresnel_col, facing);
fresnel_col = pow(fresnel_col, vec3(2.2));
finalColor.rgb = mix(no_fresnel_col.rgb, fresnel_col, fresnelMix);
finalColor.rgb = (isSingleColor) ? colorWire.rgb : finalColor.rgb;
/* Selection Color */
if (selected_coloring) {
@ -113,8 +90,15 @@ void main()
finalColor.rgb = colorSelect.rgb;
}
}
/* Fresnel */
facing = clamp(abs(facing), 0.0, 1.0);
float fresnel_alpha;
finalColor.a = wireOpacity;
fresnel_alpha = mix(0.0, 0.8, facing);
fresnel_alpha *= fresnelMix;
finalColor.a = wireOpacity - fresnel_alpha;
finalColor.rgb *= wireOpacity;
view_clipping_distances(wpos);
}