Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/armature_dof_vert.glsl
| /* ---- Instantiated Attrs ---- */ | /* ---- Instantiated Attrs ---- */ | ||||
| in vec2 pos; | in vec2 pos; | ||||
| /* ---- Per instance Attrs ---- */ | /* ---- Per instance Attrs ---- */ | ||||
| /* Assumed to be in world coordinate already. */ | /* Assumed to be in world coordinate already. */ | ||||
| in vec4 color; | in vec4 color; | ||||
| in mat4 inst_obmat; | in mat4 inst_obmat; | ||||
| flat out vec4 finalColor; | flat out vec4 finalColor; | ||||
| #ifdef EDGE | |||||
| flat out vec2 edgeStart; | flat out vec2 edgeStart; | ||||
| noperspective out vec2 edgePos; | noperspective out vec2 edgePos; | ||||
| #endif | |||||
| vec3 sphere_project(float ax, float az) | vec3 sphere_project(float ax, float az) | ||||
| { | { | ||||
| float sine = 1.0 - ax * ax - az * az; | float sine = 1.0 - ax * ax - az * az; | ||||
| float q3 = sqrt(max(0.0, sine)); | float q3 = sqrt(max(0.0, sine)); | ||||
| return vec3(-az * q3, 0.5 - sine, ax * q3) * 2.0; | return vec3(-az * q3, 0.5 - sine, ax * q3) * 2.0; | ||||
| } | } | ||||
| Show All 9 Lines | void main() | ||||
| vec3 final_pos = sphere_project(pos.x * abs((pos.x > 0.0) ? amax.x : amin.x), | vec3 final_pos = sphere_project(pos.x * abs((pos.x > 0.0) ? amax.x : amin.x), | ||||
| pos.y * abs((pos.y > 0.0) ? amax.y : amin.y)); | pos.y * abs((pos.y > 0.0) ? amax.y : amin.y)); | ||||
| vec3 world_pos = (model_mat * vec4(final_pos, 1.0)).xyz; | vec3 world_pos = (model_mat * vec4(final_pos, 1.0)).xyz; | ||||
| gl_Position = point_world_to_ndc(world_pos); | gl_Position = point_world_to_ndc(world_pos); | ||||
| finalColor = color; | finalColor = color; | ||||
| #ifdef EDGE | |||||
| edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; | edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; | ||||
| #endif | |||||
| #ifdef USE_WORLD_CLIP_PLANES | #ifdef USE_WORLD_CLIP_PLANES | ||||
| world_clip_planes_calc_clip_distance(world_pos); | world_clip_planes_calc_clip_distance(world_pos); | ||||
| #endif | #endif | ||||
| } | } | ||||