Blender V4.3
GPU_shader_builtin.hh File Reference

Go to the source code of this file.

Macros

#define GPU_SHADER_BUILTIN_LEN   (GPU_SHADER_3D_IMAGE_COLOR + 1)
 
#define GPU_SHADER_CFG_LEN   (GPU_SHADER_CFG_CLIPPED + 1)
 

Enumerations

enum  eGPUBuiltinShader {
  GPU_SHADER_TEXT = 0 , GPU_SHADER_KEYFRAME_SHAPE , GPU_SHADER_SIMPLE_LIGHTING , GPU_SHADER_ICON ,
  GPU_SHADER_2D_IMAGE_RECT_COLOR , GPU_SHADER_2D_IMAGE_DESATURATE_COLOR , GPU_SHADER_ICON_MULTI , GPU_SHADER_2D_CHECKER ,
  GPU_SHADER_2D_DIAG_STRIPES , GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR , GPU_SHADER_3D_DEPTH_ONLY , GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE ,
  GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE , GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR , GPU_SHADER_GPENCIL_STROKE , GPU_SHADER_2D_AREA_BORDERS ,
  GPU_SHADER_2D_WIDGET_BASE , GPU_SHADER_2D_WIDGET_BASE_INST , GPU_SHADER_2D_WIDGET_SHADOW , GPU_SHADER_2D_NODELINK ,
  GPU_SHADER_2D_NODELINK_INST , GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR , GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA , GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA ,
  GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA , GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR , GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR , GPU_SHADER_SEQUENCER_STRIPS ,
  GPU_SHADER_SEQUENCER_THUMBS , GPU_SHADER_INDEXBUF_POINTS , GPU_SHADER_INDEXBUF_LINES , GPU_SHADER_INDEXBUF_TRIS ,
  GPU_SHADER_3D_FLAT_COLOR , GPU_SHADER_3D_POLYLINE_FLAT_COLOR , GPU_SHADER_3D_SMOOTH_COLOR , GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR ,
  GPU_SHADER_3D_UNIFORM_COLOR , GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR , GPU_SHADER_3D_IMAGE , GPU_SHADER_3D_IMAGE_COLOR
}
 
enum  eGPUShaderConfig { GPU_SHADER_CFG_DEFAULT = 0 , GPU_SHADER_CFG_CLIPPED = 1 }
 

Functions

GPUShaderGPU_shader_get_builtin_shader_with_config (eGPUBuiltinShader shader, eGPUShaderConfig sh_cfg)
 
GPUShaderGPU_shader_get_builtin_shader (eGPUBuiltinShader shader)
 
void GPU_shader_free_builtin_shaders ()
 

Detailed Description

Set of shaders used for interface drawing.

2D shaders are not expected to work in 3D. 3D shaders can work with 2D geometry and matrices.

INST suffix means instance, which means the shader is build to leverage instancing capabilities to reduce the number of draw-calls.

For full list of parameters, search for the associated #ShaderCreateInfo. Example: GPU_SHADER_ICON is defined by GPU_SHADER_CREATE_INFO(gpu_shader_icon) Some parameters are builtins and are set automatically (ex: ModelViewProjectionMatrix).

Definition in file GPU_shader_builtin.hh.

Macro Definition Documentation

◆ GPU_SHADER_BUILTIN_LEN

#define GPU_SHADER_BUILTIN_LEN   (GPU_SHADER_3D_IMAGE_COLOR + 1)

◆ GPU_SHADER_CFG_LEN

Enumeration Type Documentation

◆ eGPUBuiltinShader

Enumerator
GPU_SHADER_TEXT 

Glyph drawing shader used by the BLF module.

GPU_SHADER_KEYFRAME_SHAPE 

Draws keyframe markers. All markers shapes are supported through a single shader.

GPU_SHADER_SIMPLE_LIGHTING 

Draw solid mesh with a single distant light using a clamped simple dot product.

GPU_SHADER_ICON 

Draw an icon, leaving a semi-transparent rectangle on top of the icon.

GPU_SHADER_2D_IMAGE_RECT_COLOR 

Draw a texture with a uniform color multiplied.

GPU_SHADER_2D_IMAGE_DESATURATE_COLOR 

Draw a texture with a desaturation factor.

GPU_SHADER_ICON_MULTI 

Draw a group of texture rectangle with an associated color multiplied.

GPU_SHADER_2D_CHECKER 

Draw a two color checker based on screen position (not UV coordinates).

GPU_SHADER_2D_DIAG_STRIPES 

Draw diagonal stripes with two alternating colors.

GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR 

Draw dashed lines with custom dash length and uniform color.

GPU_SHADER_3D_DEPTH_ONLY 

Draw triangles / lines / points with only depth output.

GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE 

Merge viewport overlay texture with the render output.

GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE 
GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR 

Merge viewport overlay texture with the render output.

GPU_SHADER_GPENCIL_STROKE 

Used for drawing of annotations (former grease pencil).

GPU_SHADER_2D_AREA_BORDERS 

Draw rounded area borders with silky smooth anti-aliasing without any over-draw.

GPU_SHADER_2D_WIDGET_BASE 

Multi usage widget shaders for drawing buttons and other UI elements.

GPU_SHADER_2D_WIDGET_BASE_INST 
GPU_SHADER_2D_WIDGET_SHADOW 
GPU_SHADER_2D_NODELINK 

Draw a node link given an input quadratic Bezier curve.

GPU_SHADER_2D_NODELINK_INST 
GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR 

Draw round points with per vertex size and color.

GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA 

Draw round points with a uniform size. Disabling blending will disable AA.

GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA 
GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA 

Draw round points with a uniform size and an outline. Disabling blending will disable AA.

GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR 

Draw geometry with uniform color. Has an additional clip plane parameter.

GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR 

Draw wide lines with uniform color. Has an additional clip plane parameter.

GPU_SHADER_SEQUENCER_STRIPS 

Draw strip widgets in sequencer timeline.

GPU_SHADER_SEQUENCER_THUMBS 

Draw strip thumbnails in sequencer timeline.

GPU_SHADER_INDEXBUF_POINTS 

Compute shaders to generate 2d index buffers (mainly for curve drawing).

GPU_SHADER_INDEXBUF_LINES 
GPU_SHADER_INDEXBUF_TRIS 
GPU_SHADER_3D_FLAT_COLOR 

--------------------— Shaders exposed through pyGPU module --------------------—

Avoid breaking the interface of these shaders as they are used by addons. Polyline versions are used for drawing wide lines (> 1px width). Take a 3D position and color for each vertex without color interpolation.

Parameters
colorin vec4
posin vec3
GPU_SHADER_3D_POLYLINE_FLAT_COLOR 
GPU_SHADER_3D_SMOOTH_COLOR 

Take a 3D position and color for each vertex with perspective correct interpolation.

Parameters
colorin vec4
posin vec3
GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR 
GPU_SHADER_3D_UNIFORM_COLOR 

Take a single color for all the vertices and a 3D position for each vertex.

Parameters
coloruniform vec4
posin vec3
GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR 
GPU_SHADER_3D_IMAGE 

Draw a texture in 3D. Take a 3D position and a 2D texture coordinate for each vertex.

Parameters
imageuniform sampler2D
texCoordin vec2
posin vec3
GPU_SHADER_3D_IMAGE_COLOR 

Take a 3D position and color for each vertex with linear interpolation in window space.

Parameters
coloruniform vec4
imageuniform sampler2D
texCoordin vec2
posin vec3

Definition at line 25 of file GPU_shader_builtin.hh.

◆ eGPUShaderConfig

Support multiple configurations.

Enumerator
GPU_SHADER_CFG_DEFAULT 
GPU_SHADER_CFG_CLIPPED 

Definition at line 140 of file GPU_shader_builtin.hh.

Function Documentation

◆ GPU_shader_free_builtin_shaders()

void GPU_shader_free_builtin_shaders ( )

◆ GPU_shader_get_builtin_shader()

◆ GPU_shader_get_builtin_shader_with_config()