Differential D6296 Diff 19950 source/blender/draw/engines/overlay/shaders/motion_path_line_vert.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/motion_path_line_vert.glsl
- This file was moved from source/blender/draw/modes/shaders/animviz_mpath_lines_vert.glsl.
| uniform mat4 ViewMatrix; | uniform ivec4 mpathLineSettings; | ||||
| uniform mat4 ViewProjectionMatrix; | |||||
| uniform vec2 viewportSize; | |||||
| uniform int frameCurrent; | |||||
| uniform int frameStart; | |||||
| uniform int frameEnd; | |||||
| uniform int cacheStart; | |||||
| uniform bool selected; | uniform bool selected; | ||||
| uniform bool useCustomColor; | |||||
| uniform vec3 customColor; | uniform vec3 customColor; | ||||
| #define frameCurrent mpathLineSettings.x | |||||
| #define frameStart mpathLineSettings.y | |||||
| #define frameEnd mpathLineSettings.z | |||||
| #define cacheStart mpathLineSettings.w | |||||
| in vec3 pos; | in vec3 pos; | ||||
| out vec2 ssPos; | out vec2 ssPos; | ||||
| out vec4 finalColor_geom; | out vec4 finalColor_geom; | ||||
| /* project to screen space */ | /* project to screen space */ | ||||
| vec2 proj(vec4 pos) | vec2 proj(vec4 pos) | ||||
| { | { | ||||
| return (0.5 * (pos.xy / pos.w) + 0.5) * viewportSize; | return (0.5 * (pos.xy / pos.w) + 0.5) * sizeViewport.xy; | ||||
| } | } | ||||
| #define SET_INTENSITY(A, B, C, min, max) \ | #define SET_INTENSITY(A, B, C, min, max) \ | ||||
| (((1.0 - (float(C - B) / float(C - A))) * (max - min)) + min) | (((1.0 - (float(C - B) / float(C - A))) * (max - min)) + min) | ||||
| void main() | void main() | ||||
| { | { | ||||
| gl_Position = ViewProjectionMatrix * vec4(pos, 1.0); | gl_Position = ViewProjectionMatrix * vec4(pos, 1.0); | ||||
| ssPos = proj(gl_Position); | ssPos = proj(gl_Position); | ||||
| int frame = gl_VertexID + cacheStart; | int frame = gl_VertexID + cacheStart; | ||||
| float intensity; /* how faint */ | float intensity; /* how faint */ | ||||
| vec3 blend_base = (abs(frame - frameCurrent) == 1) ? | vec3 blend_base = (abs(frame - frameCurrent) == 1) ? | ||||
| colorCurrentFrame.rgb : | colorCurrentFrame.rgb : | ||||
| colorBackground.rgb; /* "bleed" cframe color to ease color blending */ | colorBackground.rgb; /* "bleed" cframe color to ease color blending */ | ||||
| bool use_custom_color = customColor.x >= 0.0; | |||||
| /* TODO: We might want something more consistent with custom color and standard colors. */ | /* TODO: We might want something more consistent with custom color and standard colors. */ | ||||
| if (frame < frameCurrent) { | if (frame < frameCurrent) { | ||||
| if (useCustomColor) { | if (use_custom_color) { | ||||
| /* Custom color: previous frames color is darker than current frame */ | /* Custom color: previous frames color is darker than current frame */ | ||||
| finalColor_geom.rgb = customColor * 0.25; | finalColor_geom.rgb = customColor * 0.25; | ||||
| } | } | ||||
| else { | else { | ||||
| /* black - before frameCurrent */ | /* black - before frameCurrent */ | ||||
| if (selected) { | if (selected) { | ||||
| intensity = SET_INTENSITY(frameStart, frame, frameCurrent, 0.25, 0.75); | intensity = SET_INTENSITY(frameStart, frame, frameCurrent, 0.25, 0.75); | ||||
| } | } | ||||
| else { | else { | ||||
| intensity = SET_INTENSITY(frameStart, frame, frameCurrent, 0.68, 0.92); | intensity = SET_INTENSITY(frameStart, frame, frameCurrent, 0.68, 0.92); | ||||
| } | } | ||||
| finalColor_geom.rgb = mix(colorWire.rgb, blend_base, intensity); | finalColor_geom.rgb = mix(colorWire.rgb, blend_base, intensity); | ||||
| } | } | ||||
| } | } | ||||
| else if (frame > frameCurrent) { | else if (frame > frameCurrent) { | ||||
| if (useCustomColor) { | if (use_custom_color) { | ||||
| /* Custom color: next frames color is equal to user selected color */ | /* Custom color: next frames color is equal to user selected color */ | ||||
| finalColor_geom.rgb = customColor; | finalColor_geom.rgb = customColor; | ||||
| } | } | ||||
| else { | else { | ||||
| /* blue - after frameCurrent */ | /* blue - after frameCurrent */ | ||||
| if (selected) { | if (selected) { | ||||
| intensity = SET_INTENSITY(frameCurrent, frame, frameEnd, 0.25, 0.75); | intensity = SET_INTENSITY(frameCurrent, frame, frameEnd, 0.25, 0.75); | ||||
| } | } | ||||
| else { | else { | ||||
| intensity = SET_INTENSITY(frameCurrent, frame, frameEnd, 0.68, 0.92); | intensity = SET_INTENSITY(frameCurrent, frame, frameEnd, 0.68, 0.92); | ||||
| } | } | ||||
| finalColor_geom.rgb = mix(colorBonePose.rgb, blend_base, intensity); | finalColor_geom.rgb = mix(colorBonePose.rgb, blend_base, intensity); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (useCustomColor) { | if (use_custom_color) { | ||||
| /* Custom color: current frame color is slightly darker than user selected color */ | /* Custom color: current frame color is slightly darker than user selected color */ | ||||
| finalColor_geom.rgb = customColor * 0.5; | finalColor_geom.rgb = customColor * 0.5; | ||||
| } | } | ||||
| else { | else { | ||||
| /* green - on frameCurrent */ | /* green - on frameCurrent */ | ||||
| if (selected) { | if (selected) { | ||||
| intensity = 0.5f; | intensity = 0.5f; | ||||
| } | } | ||||
| else { | else { | ||||
| intensity = 0.99f; | intensity = 0.99f; | ||||
| } | } | ||||
| finalColor_geom.rgb = clamp( | finalColor_geom.rgb = clamp( | ||||
| mix(colorCurrentFrame.rgb, colorBackground.rgb, intensity) - 0.1, 0.0, 0.1); | mix(colorCurrentFrame.rgb, colorBackground.rgb, intensity) - 0.1, 0.0, 0.1); | ||||
| } | } | ||||
| } | } | ||||
| finalColor_geom.a = 1.0; | finalColor_geom.a = 1.0; | ||||
| #ifdef USE_WORLD_CLIP_PLANES | |||||
| world_clip_planes_calc_clip_distance(pos); | |||||
| #endif | |||||
| } | } | ||||