Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_common.c
| Show First 20 Lines • Show All 916 Lines • ▼ Show 20 Lines | bool DRW_object_axis_orthogonal_to_view(Object *ob, int axis) | ||||
| BKE_object_rot_to_mat3(ob, ob_rot, true); | BKE_object_rot_to_mat3(ob, ob_rot, true); | ||||
| float dot = dot_v3v3(ob_rot[axis], invviewmat[2]); | float dot = dot_v3v3(ob_rot[axis], invviewmat[2]); | ||||
| if (fabsf(dot) < 1e-3) { | if (fabsf(dot) < 1e-3) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void DRW_evaluate_weight_to_color(float *result, float weight) | |||||
| { | |||||
| if (U.flag & USER_CUSTOM_RANGE) | |||||
| { | |||||
| BKE_colorband_evaluate(&U.coba_weight, weight, result); | |||||
| } | |||||
| else { | |||||
| float blend = ((weight / 2.0f) + 0.5f); | |||||
| if (weight <= 0.25f) { /* blue->cyan */ | |||||
| copy_v3_fl3(result, 0.0f, blend * weight * 4.0f, blend); | |||||
| } | |||||
| else if (weight <= 0.50f) { /* cyan->green */ | |||||
| copy_v3_fl3(result, 0.0f, blend, blend * (1.0f - ((weight - 0.25f) * 4.0f))); | |||||
| } | |||||
| else if (weight <= 0.75f) { /* green->yellow */ | |||||
| copy_v3_fl3(result, blend * ((weight - 0.50f) * 4.0f), blend, 0.0f); | |||||
| } | |||||
| else if (weight <= 1.0f) { /* yellow->red */ | |||||
| copy_v3_fl3(result, blend, blend * (1.0f - ((weight - 0.75f) * 4.0f)), 0.0f); | |||||
angavrilov: This color ramp matches the original code, but when it is being continuously interpolated… | |||||
| } | |||||
| else { | |||||
| copy_v3_fl3(result, 1.0f, 0.0f, 1.0f); | |||||
| } | |||||
| } | |||||
| } | |||||
| GPUTexture* DRW_create_colorramp_texture(void) | |||||
| { | |||||
| char error[256]; | |||||
| float pixels[256 * 4]; | |||||
| for (int i = 0 ; i < 256 ; i ++) { | |||||
| DRW_evaluate_weight_to_color(&pixels[i*4], i / 255.0f); | |||||
| pixels[i*4 + 3] = 1.0f; | |||||
| } | |||||
| GPUTexture *result = GPU_texture_create_1D(256, GPU_RGBA8, pixels, error); | |||||
| return result; | |||||
| } | |||||
This color ramp matches the original code, but when it is being continuously interpolated through like in this new drawing approach, it becomes obvious that the color progression is actually not very smooth. For instance the yellow band looks quite sharp and narrow, while green is wide and gradual. I wonder if it is possible to tweak it to achieve a more even flow of colors.