1 2uniform bool isTransform; 3 4#if !defined(USE_GPENCIL) && !defined(POINTCLOUD) 5in vec3 pos; 6#endif 7 8#ifdef USE_GEOM 9out vec3 vPos; 10out uint objectId_g; 11# define objectId objectId_g 12#else 13 14flat out uint objectId; 15#endif 16 17uint outline_colorid_get(void) 18{ 19 int flag = int(abs(ObjectInfo.w)); 20 bool is_from_dupli = (flag & DRW_BASE_FROM_DUPLI) != 0; 21 bool is_active = (flag & DRW_BASE_ACTIVE) != 0; 22 23 if (is_from_dupli) { 24 if (isTransform) { 25 return 0u; /* colorTransform */ 26 } 27 else { 28 return 2u; /* colorDupliSelect */ 29 } 30 } 31 32 if (isTransform) { 33 return 0u; /* colorTransform */ 34 } 35 else if (is_active) { 36 return 3u; /* colorActive */ 37 } 38 else { 39 return 1u; /* colorSelect */ 40 } 41 42 return 0u; 43} 44 45/* Replace top 2 bits (of the 16bit output) by outlineId. 46 * This leaves 16K different IDs to create outlines between objects. 47 * SHIFT = (32 - (16 - 2)) */ 48#define SHIFT 18u 49 50void main() 51{ 52#ifdef USE_GPENCIL 53 gpencil_vertex(); 54# ifdef USE_WORLD_CLIP_PLANES 55 vec3 world_pos = point_object_to_world(pos1.xyz); 56# endif 57 58#else 59# ifdef POINTCLOUD 60 vec3 world_pos = pointcloud_get_pos(); 61# else 62 vec3 world_pos = point_object_to_world(pos); 63# endif 64 gl_Position = point_world_to_ndc(world_pos); 65# ifdef USE_GEOM 66 vPos = point_world_to_view(world_pos); 67# endif 68#endif 69 /* Small bias to always be on top of the geom. */ 70 gl_Position.z -= 1e-3; 71 72 /* ID 0 is nothing (background) */ 73 objectId = uint(resource_handle + 1); 74 75 /* Should be 2 bits only [0..3]. */ 76 uint outline_id = outline_colorid_get(); 77 78 /* Combine for 16bit uint target. */ 79 objectId = (outline_id << 14u) | ((objectId << SHIFT) >> SHIFT); 80 81#ifdef USE_WORLD_CLIP_PLANES 82 world_clip_planes_calc_clip_distance(world_pos); 83#endif 84} 85