Blender V5.3
gpencil_infos.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
5#ifdef GPU_SHADER
6# pragma once
7
8# include "gpu_shader_compat.hh"
9
11
13# include "draw_view_infos.hh"
14#endif
15
16#ifdef GLSL_CPP_STUBS
17# undef SMAA_RT_METRICS
18# define SMAA_GLSL_3
19# define SMAA_STAGE 1
20# define SMAA_PRESET_HIGH
21# define SMAA_NO_DISCARD
22# define SMAA_RT_METRICS viewport_metrics
23# define SMAA_LUMA_WEIGHT float4(1.0f, 1.0f, 1.0f, 1.0f)
24#endif
25
27
28#include "gpencil_defines.hh"
29
30/* -------------------------------------------------------------------- */
33
34GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_iface, gp_interp)
35SMOOTH(float4, color_mul)
36SMOOTH(float4, color_add)
37SMOOTH(float3, pos)
38SMOOTH(float2, uv)
40GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_flat_iface, gp_interp_flat)
41FLAT(float4, aspect)
42FLAT(float2, sspos_0)
43FLAT(float4, sspos_1)
44FLAT(float4, sspos_2)
45FLAT(float2, sspos_3)
46FLAT(float3, point_length)
47FLAT(uint, mat_flag)
48FLAT(float, depth)
50GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_noperspective_iface, gp_interp_noperspective)
51NO_PERSPECTIVE(float4, thickness)
52NO_PERSPECTIVE(float, hardness)
53GPU_SHADER_NAMED_INTERFACE_END(gp_interp_noperspective)
54
55GPU_SHADER_CREATE_INFO(gpencil_geometry)
57TYPEDEF_SOURCE("gpencil_defines.hh")
58SAMPLER(2, sampler2D, gp_fill_tx)
59SAMPLER(3, sampler2D, gp_stroke_tx)
60SAMPLER(4, sampler2DDepth, gp_scene_depth_tx)
61SAMPLER(5, sampler2D, gp_mask_tx)
64PUSH_CONSTANT(float2, viewport_size)
65/* Per Object */
66PUSH_CONSTANT(float3, gp_normal)
67PUSH_CONSTANT(bool, gp_stroke_order3d)
68PUSH_CONSTANT(int, gp_material_offset)
69/* Per Layer */
70PUSH_CONSTANT(float, gp_vertex_color_opacity)
71PUSH_CONSTANT(float4, gp_layer_tint)
72PUSH_CONSTANT(float, gp_layer_opacity)
73PUSH_CONSTANT(float, gp_stroke_index_offset)
75FRAGMENT_OUT(1, float4, revealColor)
76VERTEX_OUT(gpencil_geometry_iface)
77VERTEX_OUT(gpencil_geometry_flat_iface)
78VERTEX_OUT(gpencil_geometry_noperspective_iface)
79VERTEX_SOURCE("gpencil_vert.glsl")
80FRAGMENT_SOURCE("gpencil_frag.glsl")
81DEPTH_WRITE(DepthWrite::ANY)
82ADDITIONAL_INFO(draw_view)
83ADDITIONAL_INFO(draw_modelmat)
84ADDITIONAL_INFO(draw_gpencil)
86
88
89/* -------------------------------------------------------------------- */
92
93GPU_SHADER_CREATE_INFO(gpencil_layer_blend)
95SAMPLER(0, sampler2D, color_buf)
96SAMPLER(1, sampler2D, reveal_buf)
97SAMPLER(2, sampler2D, mask_buf)
98PUSH_CONSTANT(int, blend_mode)
99PUSH_CONSTANT(float, blend_opacity)
100/* Reminder: This is considered SRC color in blend equations.
101 * Same operation on all buffers. */
103FRAGMENT_OUT(1, float4, fragRevealage)
104FRAGMENT_SOURCE("gpencil_layer_blend_frag.glsl")
105VERTEX_SOURCE("gpencil_fullscreen_vert.glsl")
107
108GPU_SHADER_CREATE_INFO(gpencil_mask_invert)
111FRAGMENT_OUT(1, float4, fragRevealage)
112FRAGMENT_SOURCE("gpencil_mask_invert_frag.glsl")
113VERTEX_SOURCE("gpencil_fullscreen_vert.glsl")
115
116GPU_SHADER_CREATE_INFO(gpencil_depth_merge)
118PUSH_CONSTANT(float4x4, gp_model_matrix)
119PUSH_CONSTANT(bool, stroke_order3d)
120SAMPLER(0, sampler2DDepth, depth_buf)
121VERTEX_SOURCE("gpencil_depth_merge_vert.glsl")
122FRAGMENT_SOURCE("gpencil_depth_merge_frag.glsl")
123DEPTH_WRITE(DepthWrite::ANY)
124ADDITIONAL_INFO(draw_view)
126
127GPU_SHADER_CREATE_INFO(gpencil_depth_pass_merge)
129PUSH_CONSTANT(float4x4, gp_model_matrix)
130PUSH_CONSTANT(bool, stroke_order3d)
131SAMPLER(0, sampler2DDepth, depth_buf)
132IMAGE(0, SFLOAT_32, read_write, image2D, depth_pass_img)
133VERTEX_SOURCE("gpencil_depth_merge_vert.glsl")
134FRAGMENT_SOURCE("gpencil_depth_pass_merge_frag.glsl")
135ADDITIONAL_INFO(draw_view)
137
139
140/* -------------------------------------------------------------------- */
143
144GPU_SHADER_INTERFACE_INFO(gpencil_antialiasing_iface)
145SMOOTH(float2, uvs)
146SMOOTH(float2, pixcoord)
147SMOOTH(float4, offset0)
148SMOOTH(float4, offset1)
149SMOOTH(float4, offset2)
151
152GPU_SHADER_CREATE_INFO(gpencil_antialiasing)
153DEFINE("SMAA_GLSL_3")
154DEFINE_VALUE("SMAA_RT_METRICS", "viewport_metrics")
155DEFINE("SMAA_PRESET_HIGH")
156DEFINE_VALUE("SMAA_LUMA_WEIGHT", "float4(luma_weight, luma_weight, luma_weight, 0.0f)")
157DEFINE("SMAA_NO_DISCARD")
158VERTEX_OUT(gpencil_antialiasing_iface)
159PUSH_CONSTANT(float4, viewport_metrics)
160PUSH_CONSTANT(float, luma_weight)
161VERTEX_SOURCE("gpencil_antialiasing_vert.glsl")
162FRAGMENT_SOURCE("gpencil_antialiasing_frag.glsl")
164
165GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_0)
166DEFINE_VALUE("SMAA_STAGE", "0")
167SAMPLER(0, sampler2D, color_tx)
168SAMPLER(1, sampler2D, reveal_tx)
169FRAGMENT_OUT(0, float2, out_edges)
170ADDITIONAL_INFO(gpencil_antialiasing)
173
174GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_1)
175DEFINE_VALUE("SMAA_STAGE", "1")
176SAMPLER(0, sampler2D, edges_tx)
177SAMPLER(1, sampler2D, area_tx)
178SAMPLER(2, sampler2D, search_tx)
179FRAGMENT_OUT(0, float4, out_weights)
180ADDITIONAL_INFO(gpencil_antialiasing)
183
184GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_2)
185DEFINE_VALUE("SMAA_STAGE", "2")
186SAMPLER(0, sampler2D, color_tx)
187SAMPLER(1, sampler2D, reveal_tx)
188SAMPLER(2, sampler2D, blend_tx)
189PUSH_CONSTANT(float, mix_factor)
190PUSH_CONSTANT(float, taa_accumulated_weight)
191PUSH_CONSTANT(bool, do_anti_aliasing)
192PUSH_CONSTANT(bool, only_alpha)
193/* Reminder: Blending func is `fragRevealage * DST + frag_color`. */
194FRAGMENT_OUT_DUAL(0, float4, out_color, SRC_0)
195FRAGMENT_OUT_DUAL(0, float4, out_reveal, SRC_1)
196ADDITIONAL_INFO(gpencil_antialiasing)
199
200GPU_SHADER_CREATE_INFO(gpencil_antialiasing_accumulation)
201IMAGE(0, GPENCIL_RENDER_FORMAT, read, image2D, src_img)
202IMAGE(1, GPENCIL_ACCUM_FORMAT, read_write, image2D, dst_img)
203PUSH_CONSTANT(float, weight_src)
204PUSH_CONSTANT(float, weight_dst)
205FRAGMENT_SOURCE("gpencil_antialiasing_accumulation_frag.glsl")
206VERTEX_SOURCE("gpencil_fullscreen_vert.glsl")
209
#define GPENCIL_MATERIAL_BUFFER_LEN
#define GPENCIL_ACCUM_FORMAT
#define GPENCIL_LIGHT_BUFFER_LEN
#define GPENCIL_RENDER_FORMAT
#define GPU_SHADER_INTERFACE_END()
#define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name)
#define GPU_SHADER_NAMED_INTERFACE_END(_inst_name)
#define GPU_SHADER_INTERFACE_INFO(_interface)
#define GPU_SHADER_CREATE_INFO(_info)
#define GPU_SHADER_CREATE_END()
#define TYPEDEF_SOURCE(filename)
#define VERTEX_OUT(stage_interface)
#define FRAGMENT_OUT_DUAL(slot, type, name, blend)
#define SMOOTH(type, name)
#define SAMPLER(slot, type, name)
#define FRAGMENT_SOURCE(filename)
#define ADDITIONAL_INFO(info_name)
#define PUSH_CONSTANT(type, name)
#define DEFINE(name)
#define FLAT(type, name)
#define FRAGMENT_OUT(slot, type, name)
#define UNIFORM_BUF_FREQ(slot, type_name, name, freq)
#define NO_PERSPECTIVE(type, name)
#define VERTEX_SOURCE(filename)
#define IMAGE(slot, format, qualifiers, type, name)
#define DO_STATIC_COMPILATION()
#define DEPTH_WRITE(value)
#define DEFINE_VALUE(name, value)
#define frag_color(slot)
ImageBase< float, 2 > image2D
MatBase< 4, 4 > float4x4
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
SamplerBase< float, 2 > sampler2D