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