161 state.overlay.bone_wire_alpha :
164 const bool use_wire_alpha = (wire_alpha < 1.0f);
166 gpu::Texture **depth_tex = (
state.xray_enabled) ? &res.depth_tx : &res.dummy_depth_tx;
171 res.select_bind(armature_ps_);
179 auto &sub = armature_ps_.sub(
"opaque.envelope_distance");
181 sub.shader_set(res.shaders->armature_envelope_fill.get());
182 sub.push_constant(
"alpha", 1.0f);
183 sub.push_constant(
"is_distance",
true);
184 opaque_.envelope_distance = ⊂
186 if (use_wire_alpha) {
187 auto &sub = armature_ps_.sub(
"transparent.envelope_distance");
189 sub.shader_set(res.shaders->armature_envelope_fill.get());
190 sub.push_constant(
"alpha", wire_alpha);
191 sub.push_constant(
"is_distance",
true);
192 transparent_.envelope_distance = ⊂
195 transparent_.envelope_distance = opaque_.envelope_distance;
199 auto &sub = armature_ps_.sub(
"opaque.degrees_of_freedom_fill");
200 sub.state_set(transparent_state,
state.clipping_plane_count);
201 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
202 sub.push_constant(
"alpha", 1.0f);
203 opaque_.degrees_of_freedom_fill = ⊂
205 if (use_wire_alpha) {
206 auto &sub = armature_ps_.sub(
"transparent.degrees_of_freedom_fill");
207 sub.state_set(transparent_state,
state.clipping_plane_count);
208 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
209 sub.push_constant(
"alpha", wire_alpha);
210 transparent_.degrees_of_freedom_fill = ⊂
213 transparent_.degrees_of_freedom_fill = opaque_.degrees_of_freedom_fill;
223 auto &sub = armature_ps_.sub(
"opaque.sphere_fill");
224 sub.state_set(default_state,
state.clipping_plane_count);
225 sub.shader_set(res.shaders->armature_sphere_fill.get());
226 sub.push_constant(
"alpha", 1.0f);
227 opaque_.sphere_fill = ⊂
230 auto &sub = armature_ps_.sub(
"transparent.sphere_fill");
232 state.clipping_plane_count);
233 sub.shader_set(res.shaders->armature_sphere_fill.get());
234 sub.push_constant(
"alpha", wire_alpha * 0.4f);
235 transparent_.sphere_fill = ⊂
239 auto &sub = armature_ps_.sub(
"opaque.shape_fill");
240 sub.state_set(default_state,
state.clipping_plane_count);
241 sub.shader_set(res.shaders->armature_shape_fill.get());
242 sub.push_constant(
"alpha", 1.0f);
243 opaque_.shape_fill = ⊂
246 auto &sub = armature_ps_.sub(
"transparent.shape_fill");
248 state.clipping_plane_count);
249 sub.shader_set(res.shaders->armature_shape_fill.get());
250 sub.push_constant(
"alpha", wire_alpha * 0.6f);
251 transparent_.shape_fill = ⊂
255 auto &sub = armature_ps_.sub(
"opaque.sphere_outline");
256 sub.state_set(default_state,
state.clipping_plane_count);
257 sub.shader_set(res.shaders->armature_sphere_outline.get());
258 sub.push_constant(
"alpha", 1.0f);
259 opaque_.sphere_outline = ⊂
261 if (use_wire_alpha) {
262 auto &sub = armature_ps_.sub(
"transparent.sphere_outline");
264 sub.shader_set(res.shaders->armature_sphere_outline.get());
265 sub.push_constant(
"alpha", wire_alpha);
266 transparent_.sphere_outline = ⊂
269 transparent_.sphere_outline = opaque_.sphere_outline;
273 auto &sub = armature_ps_.sub(
"opaque.shape_outline");
274 sub.state_set(default_state,
state.clipping_plane_count);
275 sub.shader_set(res.shaders->armature_shape_outline.get());
276 sub.push_constant(
"alpha", 1.0f);
277 opaque_.shape_outline = ⊂
279 if (use_wire_alpha) {
280 auto &sub = armature_ps_.sub(
"transparent.shape_outline");
282 sub.shader_set(res.shaders->armature_shape_outline.get());
283 sub.bind_texture(
"depth_tx", depth_tex);
284 sub.push_constant(
"alpha", wire_alpha * 0.6f);
285 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
286 transparent_.shape_outline = ⊂
289 transparent_.shape_outline = opaque_.shape_outline;
293 auto &sub = armature_ps_.sub(
"opaque.shape_wire");
295 sub.shader_set(res.shaders->armature_shape_wire.get());
296 sub.push_constant(
"alpha", 1.0f);
297 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
298 sub.push_constant(
"use_arrow_drawing",
false);
299 opaque_.shape_wire = ⊂
301 if (use_wire_alpha) {
302 auto &sub = armature_ps_.sub(
"transparent.shape_wire");
304 sub.shader_set(res.shaders->armature_shape_wire.get());
305 sub.bind_texture(
"depth_tx", depth_tex);
306 sub.push_constant(
"alpha", wire_alpha * 0.6f);
307 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
308 sub.push_constant(
"use_arrow_drawing",
false);
309 transparent_.shape_wire = ⊂
312 transparent_.shape_wire = opaque_.shape_wire;
316 auto &sub = armature_ps_.sub(
"opaque.shape_wire_strip");
318 sub.shader_set(res.shaders->armature_shape_wire_strip.get());
319 sub.push_constant(
"alpha", 1.0f);
320 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
321 sub.push_constant(
"use_arrow_drawing",
false);
322 opaque_.shape_wire_strip = ⊂
324 if (use_wire_alpha) {
325 auto &sub = armature_ps_.sub(
"transparent.shape_wire_strip");
327 sub.shader_set(res.shaders->armature_shape_wire_strip.get());
328 sub.bind_texture(
"depth_tx", depth_tex);
329 sub.push_constant(
"alpha", wire_alpha * 0.6f);
330 sub.push_constant(
"do_smooth_wire", do_smooth_wire);
331 sub.push_constant(
"use_arrow_drawing",
false);
332 transparent_.shape_wire_strip = ⊂
335 transparent_.shape_wire_strip = opaque_.shape_wire_strip;
341 auto &sub = armature_ps_.sub(
"opaque.degrees_of_freedom_wire");
342 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
343 sub.push_constant(
"alpha", 1.0f);
344 opaque_.degrees_of_freedom_wire = ⊂
346 if (use_wire_alpha) {
347 auto &sub = armature_ps_.sub(
"transparent.degrees_of_freedom_wire");
348 sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
349 sub.push_constant(
"alpha", wire_alpha);
350 transparent_.degrees_of_freedom_wire = ⊂
353 transparent_.degrees_of_freedom_wire = opaque_.degrees_of_freedom_wire;
359 auto &sub = armature_ps_.sub(
"opaque.stick");
360 sub.shader_set(res.shaders->armature_stick.get());
361 sub.push_constant(
"alpha", 1.0f);
362 opaque_.stick = ⊂
364 if (use_wire_alpha) {
365 auto &sub = armature_ps_.sub(
"transparent.stick");
367 sub.shader_set(res.shaders->armature_stick.get());
368 sub.push_constant(
"alpha", wire_alpha);
369 transparent_.stick = ⊂
372 transparent_.stick = opaque_.stick;
378 auto &sub = armature_ps_.sub(
"opaque.envelope_fill");
380 sub.shader_set(res.shaders->armature_envelope_fill.get());
381 sub.push_constant(
"is_distance",
false);
382 sub.push_constant(
"alpha", 1.0f);
383 opaque_.envelope_fill = ⊂
386 auto &sub = armature_ps_.sub(
"transparent.envelope_fill");
389 state.clipping_plane_count);
390 sub.shader_set(res.shaders->armature_envelope_fill.get());
391 sub.push_constant(
"alpha", wire_alpha * 0.6f);
392 transparent_.envelope_fill = ⊂
396 auto &sub = armature_ps_.sub(
"opaque.envelope_outline");
398 sub.shader_set(res.shaders->armature_envelope_outline.get());
399 sub.push_constant(
"alpha", 1.0f);
400 opaque_.envelope_outline = ⊂
402 if (use_wire_alpha) {
403 auto &sub = armature_ps_.sub(
"transparent.envelope_outline");
406 state.clipping_plane_count);
407 sub.shader_set(res.shaders->armature_envelope_outline.get());
408 sub.push_constant(
"alpha", wire_alpha);
409 transparent_.envelope_outline = ⊂
412 transparent_.envelope_outline = opaque_.envelope_outline;
417 auto &sub = armature_ps_.sub(
"opaque.wire");
418 sub.shader_set(res.shaders->armature_wire.get());
419 sub.push_constant(
"alpha", 1.0f);
422 if (use_wire_alpha) {
423 auto &sub = armature_ps_.sub(
"transparent.wire");
425 sub.shader_set(res.shaders->armature_wire.get());
426 sub.push_constant(
"alpha", wire_alpha);
427 transparent_.wire = ⊂
430 transparent_.wire = opaque_.wire;
435 auto &sub = armature_ps_.sub(
"opaque.arrow");
436 sub.shader_set(res.shaders->extra_shape.get());
437 opaque_.arrows = ⊂
438 transparent_.arrows = opaque_.arrows;
442 auto &sub = armature_ps_.sub(
"opaque.relations");
443 sub.shader_set(res.shaders->extra_wire.get());
444 opaque_.relations = ⊂
445 transparent_.relations = opaque_.relations;
448 auto shape_instance_bufs_begin_sync = [](BoneBuffers &bb) {
449 bb.envelope_fill_buf.clear();
450 bb.envelope_outline_buf.clear();
451 bb.envelope_distance_buf.clear();
452 bb.bbones_fill_buf.clear();
453 bb.bbones_outline_buf.clear();
454 bb.octahedral_fill_buf.clear();
455 bb.octahedral_outline_buf.clear();
456 bb.sphere_fill_buf.clear();
457 bb.sphere_outline_buf.clear();
458 bb.stick_buf.clear();
460 bb.arrows_buf.clear();
461 bb.degrees_of_freedom_fill_buf.clear();
462 bb.degrees_of_freedom_wire_buf.clear();
463 bb.relations_buf.clear();
466 bb.custom_shape_fill.clear();
467 bb.custom_shape_outline.clear();
468 bb.custom_shape_wire.clear();
469 bb.custom_shape_wire_strip.clear();
472 shape_instance_bufs_begin_sync(transparent_);
473 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);