Differential D17089 Diff 60052 source/blender/draw/engines/overlay/shaders/overlay_volume_velocity_vert.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/overlay_volume_velocity_vert.glsl
| #pragma BLENDER_REQUIRE(common_view_lib.glsl) | #pragma BLENDER_REQUIRE(common_view_lib.glsl) | ||||
| const vec3 corners[4] = vec3[4](vec3(0.0, 0.2, -0.5), | |||||
| vec3(-0.2 * 0.866, -0.2 * 0.5, -0.5), | |||||
| vec3(0.2 * 0.866, -0.2 * 0.5, -0.5), | |||||
| vec3(0.0, 0.0, 0.5)); | |||||
| const int indices[12] = int[12](0, 1, 1, 2, 2, 0, 0, 3, 1, 3, 2, 3); | |||||
| /* Straight Port from BKE_defvert_weight_to_rgb() | /* Straight Port from BKE_defvert_weight_to_rgb() | ||||
| * TODO: port this to a color ramp. */ | * TODO: port this to a color ramp. */ | ||||
| vec3 weight_to_color(float weight) | vec3 weight_to_color(float weight) | ||||
| { | { | ||||
| vec3 r_rgb = vec3(0.0); | vec3 r_rgb = vec3(0.0); | ||||
| float blend = ((weight / 2.0) + 0.5); | float blend = ((weight / 2.0) + 0.5); | ||||
| if (weight <= 0.25) { /* blue->cyan */ | if (weight <= 0.25) { /* blue->cyan */ | ||||
| ▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | #else | ||||
| } | } | ||||
| else if (length(vector) == 0.0) { | else if (length(vector) == 0.0) { | ||||
| vector_length = 0.0; | vector_length = 0.0; | ||||
| } | } | ||||
| mat3 rot_mat = rotation_from_vector(vector); | mat3 rot_mat = rotation_from_vector(vector); | ||||
| # ifdef USE_NEEDLE | # ifdef USE_NEEDLE | ||||
| /* NOTE(Metal): Declaring constant arrays in function scope to avoid increasing local shader | |||||
| * memory pressure. */ | |||||
| const vec3 corners[4] = vec3[4](vec3(0.0, 0.2, -0.5), | |||||
| vec3(-0.2 * 0.866, -0.2 * 0.5, -0.5), | |||||
| vec3(0.2 * 0.866, -0.2 * 0.5, -0.5), | |||||
| vec3(0.0, 0.0, 0.5)); | |||||
| const int indices[12] = int[12](0, 1, 1, 2, 2, 0, 0, 3, 1, 3, 2, 3); | |||||
| vec3 rotated_pos = rot_mat * corners[indices[gl_VertexID % 12]]; | vec3 rotated_pos = rot_mat * corners[indices[gl_VertexID % 12]]; | ||||
| pos += rotated_pos * vector_length * displaySize * cellSize; | pos += rotated_pos * vector_length * displaySize * cellSize; | ||||
| # else | # else | ||||
| vec3 rotated_pos = rot_mat * vec3(0.0, 0.0, 1.0); | vec3 rotated_pos = rot_mat * vec3(0.0, 0.0, 1.0); | ||||
| pos += ((gl_VertexID % 2) == 1) ? rotated_pos * vector_length * displaySize * cellSize : | pos += ((gl_VertexID % 2) == 1) ? rotated_pos * vector_length * displaySize * cellSize : | ||||
| vec3(0.0); | vec3(0.0); | ||||
| # endif | # endif | ||||
| #endif | #endif | ||||
| vec3 world_pos = point_object_to_world(pos); | vec3 world_pos = point_object_to_world(pos); | ||||
| gl_Position = point_world_to_ndc(world_pos); | gl_Position = point_world_to_ndc(world_pos); | ||||
| } | } | ||||