Blender V4.5
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
5#ifdef GPU_SHADER
6# pragma once
7
8# include "gpu_glsl_cpp_stubs.hh"
9
10# define GP_LIGHT
11
13
15# include "draw_view_info.hh"
17
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)
38SMOOTH(float2, uv)
40GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_flat_iface, gp_interp_flat)
41FLAT(float2, aspect)
42FLAT(float4, sspos)
43FLAT(uint, mat_flag)
44FLAT(float, depth)
46GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_noperspective_iface, gp_interp_noperspective)
47NO_PERSPECTIVE(float2, thickness)
48NO_PERSPECTIVE(float, hardness)
49GPU_SHADER_NAMED_INTERFACE_END(gp_interp_noperspective)
50
51GPU_SHADER_CREATE_INFO(gpencil_geometry)
53DEFINE("GP_LIGHT")
54TYPEDEF_SOURCE("gpencil_defines.hh")
55SAMPLER(2, sampler2D, gp_fill_tx)
56SAMPLER(3, sampler2D, gp_stroke_tx)
57SAMPLER(4, sampler2DDepth, gp_scene_depth_tx)
58SAMPLER(5, sampler2D, gp_mask_tx)
60UNIFORM_BUF_FREQ(3, gpLight, gp_lights[GPENCIL_LIGHT_BUFFER_LEN], BATCH)
61PUSH_CONSTANT(float2, viewport_size)
62/* Per Object */
63PUSH_CONSTANT(float3, gp_normal)
64PUSH_CONSTANT(bool, gp_stroke_order3d)
65PUSH_CONSTANT(int, gp_material_offset)
66/* Per Layer */
67PUSH_CONSTANT(float, gp_vertex_color_opacity)
68PUSH_CONSTANT(float4, gp_layer_tint)
69PUSH_CONSTANT(float, gp_layer_opacity)
70PUSH_CONSTANT(float, gp_stroke_index_offset)
71FRAGMENT_OUT(0, float4, frag_color)
72FRAGMENT_OUT(1, float4, revealColor)
73VERTEX_OUT(gpencil_geometry_iface)
74VERTEX_OUT(gpencil_geometry_flat_iface)
75VERTEX_OUT(gpencil_geometry_noperspective_iface)
76VERTEX_SOURCE("gpencil_vert.glsl")
77FRAGMENT_SOURCE("gpencil_frag.glsl")
79ADDITIONAL_INFO(draw_view)
80ADDITIONAL_INFO(draw_modelmat)
81ADDITIONAL_INFO(draw_gpencil)
83
85
86/* -------------------------------------------------------------------- */
89
90GPU_SHADER_CREATE_INFO(gpencil_layer_blend)
92SAMPLER(0, sampler2D, color_buf)
93SAMPLER(1, sampler2D, reveal_buf)
94SAMPLER(2, sampler2D, mask_buf)
95PUSH_CONSTANT(int, blend_mode)
96PUSH_CONSTANT(float, blend_opacity)
97/* Reminder: This is considered SRC color in blend equations.
98 * Same operation on all buffers. */
99FRAGMENT_OUT(0, float4, frag_color)
100FRAGMENT_OUT(1, float4, fragRevealage)
101FRAGMENT_SOURCE("gpencil_layer_blend_frag.glsl")
102ADDITIONAL_INFO(gpu_fullscreen)
104
105GPU_SHADER_CREATE_INFO(gpencil_mask_invert)
107FRAGMENT_OUT(0, float4, frag_color)
108FRAGMENT_OUT(1, float4, fragRevealage)
109FRAGMENT_SOURCE("gpencil_mask_invert_frag.glsl")
110ADDITIONAL_INFO(gpu_fullscreen)
112
113GPU_SHADER_CREATE_INFO(gpencil_depth_merge)
115PUSH_CONSTANT(float4x4, gp_model_matrix)
116PUSH_CONSTANT(bool, stroke_order3d)
117SAMPLER(0, sampler2DDepth, depth_buf)
118VERTEX_SOURCE("gpencil_depth_merge_vert.glsl")
119FRAGMENT_SOURCE("gpencil_depth_merge_frag.glsl")
121ADDITIONAL_INFO(draw_view)
123
125
126/* -------------------------------------------------------------------- */
129
130GPU_SHADER_INTERFACE_INFO(gpencil_antialiasing_iface)
131SMOOTH(float2, uvs)
132SMOOTH(float2, pixcoord)
133SMOOTH(float4, offset[3])
135
136GPU_SHADER_CREATE_INFO(gpencil_antialiasing)
137DEFINE("SMAA_GLSL_3")
138DEFINE_VALUE("SMAA_RT_METRICS", "viewport_metrics")
139DEFINE("SMAA_PRESET_HIGH")
140DEFINE_VALUE("SMAA_LUMA_WEIGHT", "float4(luma_weight, luma_weight, luma_weight, 0.0f)")
141DEFINE("SMAA_NO_DISCARD")
142VERTEX_OUT(gpencil_antialiasing_iface)
143PUSH_CONSTANT(float4, viewport_metrics)
144PUSH_CONSTANT(float, luma_weight)
145VERTEX_SOURCE("gpencil_antialiasing_vert.glsl")
146FRAGMENT_SOURCE("gpencil_antialiasing_frag.glsl")
148
149GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_0)
150DEFINE_VALUE("SMAA_STAGE", "0")
151SAMPLER(0, sampler2D, color_tx)
152SAMPLER(1, sampler2D, reveal_tx)
153FRAGMENT_OUT(0, float2, out_edges)
154ADDITIONAL_INFO(gpencil_antialiasing)
157
158GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_1)
159DEFINE_VALUE("SMAA_STAGE", "1")
160SAMPLER(0, sampler2D, edges_tx)
161SAMPLER(1, sampler2D, area_tx)
162SAMPLER(2, sampler2D, search_tx)
163FRAGMENT_OUT(0, float4, out_weights)
164ADDITIONAL_INFO(gpencil_antialiasing)
167
168GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_2)
169DEFINE_VALUE("SMAA_STAGE", "2")
170SAMPLER(0, sampler2D, color_tx)
171SAMPLER(1, sampler2D, reveal_tx)
172SAMPLER(2, sampler2D, blend_tx)
173PUSH_CONSTANT(float, mix_factor)
174PUSH_CONSTANT(float, taa_accumulated_weight)
175PUSH_CONSTANT(bool, do_anti_aliasing)
176PUSH_CONSTANT(bool, only_alpha)
177/* Reminder: Blending func is `fragRevealage * DST + frag_color`. */
178FRAGMENT_OUT_DUAL(0, float4, out_color, SRC_0)
179FRAGMENT_OUT_DUAL(0, float4, out_reveal, SRC_1)
180ADDITIONAL_INFO(gpencil_antialiasing)
183
184GPU_SHADER_CREATE_INFO(gpencil_antialiasing_accumulation)
186IMAGE(1, GPENCIL_ACCUM_FORMAT, read_write, image2D, dst_img)
187PUSH_CONSTANT(float, weight_src)
188PUSH_CONSTANT(float, weight_dst)
189FRAGMENT_SOURCE("gpencil_antialiasing_accumulation_frag.glsl")
190ADDITIONAL_INFO(gpu_fullscreen)
193
unsigned int uint
#define GPENCIL_MATERIAL_BUFFER_LEN
#define GPENCIL_ACCUM_FORMAT
#define GPENCIL_LIGHT_BUFFER_LEN
#define GPENCIL_RENDER_FORMAT
uint pos
VecBase< float, 4 > float4
MatBase< 4, 4 > float4x4
ImageBase< float, 2 > image2D
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
SamplerBase< float, 2 > sampler2D
#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 GPU_SHADER_INTERFACE_END()
#define FRAGMENT_SOURCE(filename)
#define ADDITIONAL_INFO(info_name)
#define PUSH_CONSTANT(type, name)
#define DEFINE(name)
#define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name)
#define FLAT(type, name)
#define GPU_SHADER_NAMED_INTERFACE_END(_inst_name)
#define FRAGMENT_OUT(slot, type, name)
#define UNIFORM_BUF_FREQ(slot, type_name, name, freq)
#define NO_PERSPECTIVE(type, name)
#define GPU_SHADER_INTERFACE_INFO(_interface)
#define GPU_SHADER_CREATE_INFO(_info)
#define VERTEX_SOURCE(filename)
#define IMAGE(slot, format, qualifiers, type, name)
#define GPU_SHADER_CREATE_END()
#define DO_STATIC_COMPILATION()
#define DEPTH_WRITE(value)
#define DEFINE_VALUE(name, value)
read