Blender V4.3
gpencil_info.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
7#include "gpencil_defines.h"
8
9/* -------------------------------------------------------------------- */
13GPU_SHADER_INTERFACE_INFO(gpencil_geometry_iface, "gp_interp")
14 .smooth(Type::VEC4, "color_mul")
15 .smooth(Type::VEC4, "color_add")
16 .smooth(Type::VEC3, "pos")
17 .smooth(Type::VEC2, "uv");
18GPU_SHADER_INTERFACE_INFO(gpencil_geometry_flat_iface, "gp_interp_flat")
19 .flat(Type::VEC2, "aspect")
20 .flat(Type::VEC4, "sspos")
21 .flat(Type::UINT, "mat_flag")
22 .flat(Type::FLOAT, "depth");
23GPU_SHADER_INTERFACE_INFO(gpencil_geometry_noperspective_iface, "gp_interp_noperspective")
24 .no_perspective(Type::VEC2, "thickness")
25 .no_perspective(Type::FLOAT, "hardness");
26
27GPU_SHADER_CREATE_INFO(gpencil_geometry)
28 .do_static_compilation(true)
29 .define("GP_LIGHT")
30 .typedef_source("gpencil_defines.h")
31 .sampler(2, ImageType::FLOAT_2D, "gpFillTexture")
32 .sampler(3, ImageType::FLOAT_2D, "gpStrokeTexture")
33 .sampler(4, ImageType::DEPTH_2D, "gpSceneDepthTexture")
34 .sampler(5, ImageType::FLOAT_2D, "gpMaskTexture")
35 .uniform_buf(4, "gpMaterial", "gp_materials[GPENCIL_MATERIAL_BUFFER_LEN]", Frequency::BATCH)
36 .uniform_buf(3, "gpLight", "gp_lights[GPENCIL_LIGHT_BUFFER_LEN]", Frequency::BATCH)
37 .push_constant(Type::VEC2, "viewportSize")
38 /* Per Object */
39 .push_constant(Type::VEC3, "gpNormal")
40 .push_constant(Type::BOOL, "gpStrokeOrder3d")
41 .push_constant(Type::INT, "gpMaterialOffset")
42 /* Per Layer */
43 .push_constant(Type::FLOAT, "gpVertexColorOpacity")
44 .push_constant(Type::VEC4, "gpLayerTint")
45 .push_constant(Type::FLOAT, "gpLayerOpacity")
46 .push_constant(Type::FLOAT, "gpStrokeIndexOffset")
47 .fragment_out(0, Type::VEC4, "fragColor")
48 .fragment_out(1, Type::VEC4, "revealColor")
49 .vertex_out(gpencil_geometry_iface)
50 .vertex_out(gpencil_geometry_flat_iface)
51 .vertex_out(gpencil_geometry_noperspective_iface)
52 .vertex_source("gpencil_vert.glsl")
53 .fragment_source("gpencil_frag.glsl")
54 .depth_write(DepthWrite::ANY)
55 .additional_info("draw_gpencil");
56
59/* -------------------------------------------------------------------- */
63GPU_SHADER_CREATE_INFO(gpencil_layer_blend)
64 .do_static_compilation(true)
65 .sampler(0, ImageType::FLOAT_2D, "colorBuf")
66 .sampler(1, ImageType::FLOAT_2D, "revealBuf")
67 .sampler(2, ImageType::FLOAT_2D, "maskBuf")
68 .push_constant(Type::INT, "blendMode")
69 .push_constant(Type::FLOAT, "blendOpacity")
70 /* Reminder: This is considered SRC color in blend equations.
71 * Same operation on all buffers. */
72 .fragment_out(0, Type::VEC4, "fragColor")
73 .fragment_out(1, Type::VEC4, "fragRevealage")
74 .fragment_source("gpencil_layer_blend_frag.glsl")
75 .additional_info("draw_fullscreen");
76
77GPU_SHADER_CREATE_INFO(gpencil_mask_invert)
78 .do_static_compilation(true)
79 .fragment_out(0, Type::VEC4, "fragColor")
80 .fragment_out(1, Type::VEC4, "fragRevealage")
81 .fragment_source("gpencil_mask_invert_frag.glsl")
82 .additional_info("draw_fullscreen");
83
84GPU_SHADER_CREATE_INFO(gpencil_depth_merge)
85 .do_static_compilation(true)
86 .push_constant(Type::VEC4, "gpModelMatrix", 4)
87 .push_constant(Type::BOOL, "strokeOrder3d")
88 .sampler(0, ImageType::DEPTH_2D, "depthBuf")
89 .vertex_source("gpencil_depth_merge_vert.glsl")
90 .fragment_source("gpencil_depth_merge_frag.glsl")
91 .depth_write(DepthWrite::ANY)
92 .additional_info("draw_view");
93
96/* -------------------------------------------------------------------- */
100GPU_SHADER_INTERFACE_INFO(gpencil_antialiasing_iface, "")
101 .smooth(Type::VEC2, "uvs")
102 .smooth(Type::VEC2, "pixcoord")
103 .smooth(Type::VEC4, "offset[3]");
104
105GPU_SHADER_CREATE_INFO(gpencil_antialiasing)
106 .define("SMAA_GLSL_3")
107 .define("SMAA_RT_METRICS", "viewportMetrics")
108 .define("SMAA_PRESET_HIGH")
109 .define("SMAA_LUMA_WEIGHT", "float4(lumaWeight, lumaWeight, lumaWeight, 0.0)")
110 .define("SMAA_NO_DISCARD")
111 .vertex_out(gpencil_antialiasing_iface)
112 .push_constant(Type::VEC4, "viewportMetrics")
113 .push_constant(Type::FLOAT, "lumaWeight")
114 .vertex_source("gpencil_antialiasing_vert.glsl")
115 .fragment_source("gpencil_antialiasing_frag.glsl");
116
117GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_0)
118 .define("SMAA_STAGE", "0")
119 .sampler(0, ImageType::FLOAT_2D, "colorTex")
120 .sampler(1, ImageType::FLOAT_2D, "revealTex")
121 .fragment_out(0, Type::VEC2, "out_edges")
122 .additional_info("gpencil_antialiasing")
123 .do_static_compilation(true);
124
125GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_1)
126 .define("SMAA_STAGE", "1")
127 .sampler(0, ImageType::FLOAT_2D, "edgesTex")
128 .sampler(1, ImageType::FLOAT_2D, "areaTex")
129 .sampler(2, ImageType::FLOAT_2D, "searchTex")
130 .fragment_out(0, Type::VEC4, "out_weights")
131 .additional_info("gpencil_antialiasing")
132 .do_static_compilation(true);
133
134GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_2)
135 .define("SMAA_STAGE", "2")
136 .sampler(0, ImageType::FLOAT_2D, "colorTex")
137 .sampler(1, ImageType::FLOAT_2D, "revealTex")
138 .sampler(2, ImageType::FLOAT_2D, "blendTex")
139 .push_constant(Type::FLOAT, "mixFactor")
140 .push_constant(Type::FLOAT, "taaAccumulatedWeight")
141 .push_constant(Type::BOOL, "doAntiAliasing")
142 .push_constant(Type::BOOL, "onlyAlpha")
143 /* Reminder: Blending func is `fragRevealage * DST + fragColor`. */
144 .fragment_out(0, Type::VEC4, "out_color", DualBlend::SRC_0)
145 .fragment_out(0, Type::VEC4, "out_reveal", DualBlend::SRC_1)
146 .additional_info("gpencil_antialiasing")
147 .do_static_compilation(true);
148
#define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name)
#define GPU_SHADER_CREATE_INFO(_info)