159 state.overlay.bone_wire_alpha :
162 const bool use_wire_alpha = (wire_alpha < 1.0f);
164 gpu::Texture **depth_tex = (
state.xray_enabled) ? &res.depth_tx : &res.dummy_depth_tx;
169 res.select_bind(armature_ps_);
177 auto &sub = armature_ps_.sub(
"opaque.envelope_distance");
179 sub.shader_set(res.shaders->armature_envelope_fill.get());
180 sub.push_constant(
"alpha", 1.0f);
181 sub.push_constant(
"is_distance",
true);
182 opaque_.envelope_distance = ⊂
184 if (use_wire_alpha) {
185 auto &sub = armature_ps_.sub(
"transparent.envelope_distance");
187 sub.shader_set(res.shaders->armature_envelope_fill.get());
188 sub.push_constant(
"alpha", wire_alpha);
189 sub.push_constant(
"is_distance",
true);
190 transparent_.envelope_distance = ⊂
193 transparent_.envelope_distance = opaque_.envelope_distance;
197 auto &sub = armature_ps_.sub(
"opaque.degrees_of_freedom_fill");
198 sub.state_set(transparent_state,
state.clipping_plane_count);
199 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
200 sub.push_constant(
"alpha", 1.0f);
201 opaque_.degrees_of_freedom_fill = ⊂
203 if (use_wire_alpha) {
204 auto &sub = armature_ps_.sub(
"transparent.degrees_of_freedom_fill");
205 sub.state_set(transparent_state,
state.clipping_plane_count);
206 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
207 sub.push_constant(
"alpha", wire_alpha);
208 transparent_.degrees_of_freedom_fill = ⊂
211 transparent_.degrees_of_freedom_fill = opaque_.degrees_of_freedom_fill;
221 auto &sub = armature_ps_.sub(
"opaque.sphere_fill");
222 sub.state_set(default_state,
state.clipping_plane_count);
223 sub.shader_set(res.shaders->armature_sphere_fill.get());
224 sub.push_constant(
"alpha", 1.0f);
225 opaque_.sphere_fill = ⊂
228 auto &sub = armature_ps_.sub(
"transparent.sphere_fill");
230 state.clipping_plane_count);
231 sub.shader_set(res.shaders->armature_sphere_fill.get());
232 sub.push_constant(
"alpha", wire_alpha * 0.4f);
233 transparent_.sphere_fill = ⊂
237 auto &sub = armature_ps_.sub(
"opaque.shape_fill");
238 sub.state_set(default_state,
state.clipping_plane_count);
239 sub.shader_set(res.shaders->armature_shape_fill.get());
240 sub.push_constant(
"alpha", 1.0f);
241 opaque_.shape_fill = ⊂
244 auto &sub = armature_ps_.sub(
"transparent.shape_fill");
246 state.clipping_plane_count);
247 sub.shader_set(res.shaders->armature_shape_fill.get());
248 sub.push_constant(
"alpha", wire_alpha * 0.6f);
249 transparent_.shape_fill = ⊂
253 auto &sub = armature_ps_.sub(
"opaque.sphere_outline");
254 sub.state_set(default_state,
state.clipping_plane_count);
255 sub.shader_set(res.shaders->armature_sphere_outline.get());
256 sub.push_constant(
"alpha", 1.0f);
257 opaque_.sphere_outline = ⊂
259 if (use_wire_alpha) {
260 auto &sub = armature_ps_.sub(
"transparent.sphere_outline");
262 sub.shader_set(res.shaders->armature_sphere_outline.get());
263 sub.push_constant(
"alpha", wire_alpha);
264 transparent_.sphere_outline = ⊂
267 transparent_.sphere_outline = opaque_.sphere_outline;
271 auto &sub = armature_ps_.sub(
"opaque.shape_outline");
272 sub.state_set(default_state,
state.clipping_plane_count);
273 sub.shader_set(res.shaders->armature_shape_outline.get());
274 sub.push_constant(
"alpha", 1.0f);
275 opaque_.shape_outline = ⊂
277 if (use_wire_alpha) {
278 auto &sub = armature_ps_.sub(
"transparent.shape_outline");
280 sub.shader_set(res.shaders->armature_shape_outline.get());
281 sub.bind_texture(
"depth_tx", depth_tex);
282 sub.push_constant(
"alpha", wire_alpha * 0.6f);
283 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
284 transparent_.shape_outline = ⊂
287 transparent_.shape_outline = opaque_.shape_outline;
291 auto &sub = armature_ps_.sub(
"opaque.shape_wire");
293 sub.shader_set(res.shaders->armature_shape_wire.get());
294 sub.push_constant(
"alpha", 1.0f);
295 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
296 sub.push_constant(
"use_arrow_drawing",
false);
297 opaque_.shape_wire = ⊂
299 if (use_wire_alpha) {
300 auto &sub = armature_ps_.sub(
"transparent.shape_wire");
302 sub.shader_set(res.shaders->armature_shape_wire.get());
303 sub.bind_texture(
"depth_tx", depth_tex);
304 sub.push_constant(
"alpha", wire_alpha * 0.6f);
305 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
306 sub.push_constant(
"use_arrow_drawing",
false);
307 transparent_.shape_wire = ⊂
310 transparent_.shape_wire = opaque_.shape_wire;
314 auto &sub = armature_ps_.sub(
"opaque.shape_wire_strip");
316 sub.shader_set(res.shaders->armature_shape_wire_strip.get());
317 sub.push_constant(
"alpha", 1.0f);
318 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
319 sub.push_constant(
"use_arrow_drawing",
false);
320 opaque_.shape_wire_strip = ⊂
322 if (use_wire_alpha) {
323 auto &sub = armature_ps_.sub(
"transparent.shape_wire_strip");
325 sub.shader_set(res.shaders->armature_shape_wire_strip.get());
326 sub.bind_texture(
"depth_tx", depth_tex);
327 sub.push_constant(
"alpha", wire_alpha * 0.6f);
328 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
329 sub.push_constant(
"use_arrow_drawing",
false);
330 transparent_.shape_wire_strip = ⊂
333 transparent_.shape_wire_strip = opaque_.shape_wire_strip;
339 auto &sub = armature_ps_.sub(
"opaque.degrees_of_freedom_wire");
340 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
341 sub.push_constant(
"alpha", 1.0f);
342 opaque_.degrees_of_freedom_wire = ⊂
344 if (use_wire_alpha) {
345 auto &sub = armature_ps_.sub(
"transparent.degrees_of_freedom_wire");
346 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
347 sub.push_constant(
"alpha", wire_alpha);
348 transparent_.degrees_of_freedom_wire = ⊂
351 transparent_.degrees_of_freedom_wire = opaque_.degrees_of_freedom_wire;
357 auto &sub = armature_ps_.sub(
"opaque.stick");
358 sub.shader_set(res.shaders->armature_stick.get());
359 sub.push_constant(
"alpha", 1.0f);
360 opaque_.stick = ⊂
362 if (use_wire_alpha) {
363 auto &sub = armature_ps_.sub(
"transparent.stick");
365 sub.shader_set(res.shaders->armature_stick.get());
366 sub.push_constant(
"alpha", wire_alpha);
367 transparent_.stick = ⊂
370 transparent_.stick = opaque_.stick;
376 auto &sub = armature_ps_.sub(
"opaque.envelope_fill");
378 sub.shader_set(res.shaders->armature_envelope_fill.get());
379 sub.push_constant(
"is_distance",
false);
380 sub.push_constant(
"alpha", 1.0f);
381 opaque_.envelope_fill = ⊂
384 auto &sub = armature_ps_.sub(
"transparent.envelope_fill");
387 state.clipping_plane_count);
388 sub.shader_set(res.shaders->armature_envelope_fill.get());
389 sub.push_constant(
"alpha", wire_alpha * 0.6f);
390 transparent_.envelope_fill = ⊂
394 auto &sub = armature_ps_.sub(
"opaque.envelope_outline");
396 sub.shader_set(res.shaders->armature_envelope_outline.get());
397 sub.push_constant(
"alpha", 1.0f);
398 opaque_.envelope_outline = ⊂
400 if (use_wire_alpha) {
401 auto &sub = armature_ps_.sub(
"transparent.envelope_outline");
404 state.clipping_plane_count);
405 sub.shader_set(res.shaders->armature_envelope_outline.get());
406 sub.push_constant(
"alpha", wire_alpha);
407 transparent_.envelope_outline = ⊂
410 transparent_.envelope_outline = opaque_.envelope_outline;
415 auto &sub = armature_ps_.sub(
"opaque.wire");
416 sub.shader_set(res.shaders->armature_wire.get());
417 sub.push_constant(
"alpha", 1.0f);
420 if (use_wire_alpha) {
421 auto &sub = armature_ps_.sub(
"transparent.wire");
423 sub.shader_set(res.shaders->armature_wire.get());
424 sub.push_constant(
"alpha", wire_alpha);
425 transparent_.wire = ⊂
428 transparent_.wire = opaque_.wire;
433 auto &sub = armature_ps_.sub(
"opaque.arrow");
434 sub.shader_set(res.shaders->extra_shape.get());
435 opaque_.arrows = ⊂
436 transparent_.arrows = opaque_.arrows;
440 auto &sub = armature_ps_.sub(
"opaque.relations");
441 sub.shader_set(res.shaders->extra_wire.get());
442 opaque_.relations = ⊂
443 transparent_.relations = opaque_.relations;
446 auto shape_instance_bufs_begin_sync = [](BoneBuffers &bb) {
447 bb.envelope_fill_buf.clear();
448 bb.envelope_outline_buf.clear();
449 bb.envelope_distance_buf.clear();
450 bb.bbones_fill_buf.clear();
451 bb.bbones_outline_buf.clear();
452 bb.octahedral_fill_buf.clear();
453 bb.octahedral_outline_buf.clear();
454 bb.sphere_fill_buf.clear();
455 bb.sphere_outline_buf.clear();
456 bb.stick_buf.clear();
458 bb.arrows_buf.clear();
459 bb.degrees_of_freedom_fill_buf.clear();
460 bb.degrees_of_freedom_wire_buf.clear();
461 bb.relations_buf.clear();
464 bb.custom_shape_fill.clear();
465 bb.custom_shape_outline.clear();
466 bb.custom_shape_wire.clear();
467 bb.custom_shape_wire_strip.clear();
470 shape_instance_bufs_begin_sync(transparent_);
471 shape_instance_bufs_begin_sync(opaque_);
578 auto end_sync = [&](BoneBuffers &bb) {
579 bb.sphere_fill_buf.end_sync(*bb.sphere_fill, res.shapes.bone_sphere.get());
580 bb.sphere_outline_buf.end_sync(*bb.sphere_outline, res.shapes.bone_sphere_wire.get());
582 bb.octahedral_fill_buf.end_sync(*bb.shape_fill, res.shapes.bone_octahedron.get());
583 bb.octahedral_outline_buf.end_sync(
584 *bb.shape_outline, res.shapes.bone_octahedron_wire.get(),
GPU_PRIM_LINES, 1);
586 bb.bbones_fill_buf.end_sync(*bb.shape_fill, res.shapes.bone_box.get());
587 bb.bbones_outline_buf.end_sync(
588 *bb.shape_outline, res.shapes.bone_box_wire.get(),
GPU_PRIM_LINES, 1);
590 bb.envelope_fill_buf.end_sync(*bb.envelope_fill, res.shapes.bone_envelope.get());
591 bb.envelope_outline_buf.end_sync(*bb.envelope_outline, res.shapes.bone_envelope_wire.get());
592 bb.envelope_distance_buf.end_sync(*bb.envelope_distance, res.shapes.bone_envelope.get());
594 bb.stick_buf.end_sync(*bb.stick, res.shapes.bone_stick.get());
596 bb.wire_buf.end_sync(*bb.wire);
598 bb.arrows_buf.end_sync(*bb.arrows, res.shapes.arrows.get());
600 bb.degrees_of_freedom_fill_buf.end_sync(*bb.degrees_of_freedom_fill,
601 res.shapes.bone_degrees_of_freedom.get());
602 bb.degrees_of_freedom_wire_buf.end_sync(*bb.degrees_of_freedom_wire,
603 res.shapes.bone_degrees_of_freedom_wire.get());
605 bb.relations_buf.end_sync(*bb.relations);
609 gpu::Batch *arrow_batch = res.shapes.arrows.get();
610 for (CustomShapeBuf item : bb.custom_shape_fill.items()) {
611 item.value->end_sync(*bb.shape_fill, item.key);
613 for (CustomShapeBuf item : bb.custom_shape_outline.items()) {
614 item.value->end_sync(*bb.shape_outline, item.key,
GPU_PRIM_LINES, 1);
616 for (CustomShapeBuf item : bb.custom_shape_wire.items()) {
621 if (item.key == arrow_batch) {
622 bb.shape_wire->push_constant(
"use_arrow_drawing",
true);
625 item.value->end_sync(*bb.shape_wire, item.key,
GPU_PRIM_TRIS, 2);
627 if (item.key == arrow_batch) {
628 bb.shape_wire->push_constant(
"use_arrow_drawing",
false);
631 for (CustomShapeBuf item : bb.custom_shape_wire_strip.items()) {
632 item.value->end_sync(*bb.shape_wire_strip, item.key,
GPU_PRIM_TRIS, 2);