Introduce ghost mode for elements (#85)

Allows any element to be put in "ghost mode," decreasing its opacity and making it insensitive to click-to-select. Ghost mode is toggled using a checkbox in the outline view.

Co-authored-by: Aaron Fenyes <aaron.fenyes@fareycircles.ooo>
Reviewed-on: StudioInfinity/dyna3#85
Co-authored-by: Vectornaut <vectornaut@nobody@nowhere.net>
Co-committed-by: Vectornaut <vectornaut@nobody@nowhere.net>
This commit is contained in:
Vectornaut 2025-06-02 15:56:06 +00:00 committed by Glen Whitney
parent 2adf4669f4
commit a671a8273a
7 changed files with 77 additions and 31 deletions

View file

@ -17,7 +17,7 @@ struct vecInv {
const int SPHERE_MAX = 200;
uniform int sphere_cnt;
uniform vecInv sphere_list[SPHERE_MAX];
uniform vec3 color_list[SPHERE_MAX];
uniform vec4 color_list[SPHERE_MAX];
uniform float highlight_list[SPHERE_MAX];
// view
@ -25,7 +25,6 @@ uniform vec2 resolution;
uniform float shortdim;
// controls
uniform float opacity;
uniform int layer_threshold;
uniform bool debug_mode;
@ -69,7 +68,7 @@ struct Fragment {
vec4 color;
};
Fragment sphere_shading(vecInv v, vec3 pt, vec3 base_color) {
Fragment sphere_shading(vecInv v, vec3 pt, vec4 base_color) {
// the expression for normal needs to be checked. it's supposed to give the
// negative gradient of the lorentz product between the impact point vector
// and the sphere vector with respect to the coordinates of the impact
@ -79,7 +78,7 @@ Fragment sphere_shading(vecInv v, vec3 pt, vec3 base_color) {
float incidence = dot(normal, light_dir);
float illum = mix(0.4, 1.0, max(incidence, 0.0));
return Fragment(pt, normal, vec4(illum * base_color, opacity));
return Fragment(pt, normal, vec4(illum * base_color.rgb, base_color.a));
}
float intersection_dist(Fragment a, Fragment b) {
@ -192,10 +191,11 @@ void main() {
vec3 color = vec3(0.);
int layer = layer_cnt - 1;
TaggedDepth hit = top_hits[layer];
vec4 sphere_color = color_list[hit.id];
Fragment frag_next = sphere_shading(
sphere_list[hit.id],
hit.depth * dir,
hit.dimming * color_list[hit.id]
vec4(hit.dimming * sphere_color.rgb, sphere_color.a)
);
float highlight_next = highlight_list[hit.id];
--layer;
@ -206,10 +206,11 @@ void main() {
// shade the next fragment
hit = top_hits[layer];
sphere_color = color_list[hit.id];
frag_next = sphere_shading(
sphere_list[hit.id],
hit.depth * dir,
hit.dimming * color_list[hit.id]
vec4(hit.dimming * sphere_color.rgb, sphere_color.a)
);
highlight_next = highlight_list[hit.id];