Blender V5.0
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
10# define GP_LIGHT
11
13
15# include "draw_view_infos.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(float4, sspos_adj)
44FLAT(uint, mat_flag)
45FLAT(float, depth)
47GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_noperspective_iface, gp_interp_noperspective)
48NO_PERSPECTIVE(float4, thickness)
49NO_PERSPECTIVE(float, hardness)
50GPU_SHADER_NAMED_INTERFACE_END(gp_interp_noperspective)
51
52GPU_SHADER_CREATE_INFO(gpencil_geometry)
54DEFINE("GP_LIGHT")
55TYPEDEF_SOURCE("gpencil_defines.hh")
56SAMPLER(2, sampler2D, gp_fill_tx)
57SAMPLER(3, sampler2D, gp_stroke_tx)
58SAMPLER(4, sampler2DDepth, gp_scene_depth_tx)
59SAMPLER(5, sampler2D, gp_mask_tx)
61UNIFORM_BUF_FREQ(3, gpLight, gp_lights[GPENCIL_LIGHT_BUFFER_LEN], BATCH)
62PUSH_CONSTANT(float2, viewport_size)
63/* Per Object */
64PUSH_CONSTANT(float3, gp_normal)
65PUSH_CONSTANT(bool, gp_stroke_order3d)
66PUSH_CONSTANT(int, gp_material_offset)
67/* Per Layer */
68PUSH_CONSTANT(float, gp_vertex_color_opacity)
69PUSH_CONSTANT(float4, gp_layer_tint)
70PUSH_CONSTANT(float, gp_layer_opacity)
71PUSH_CONSTANT(float, gp_stroke_index_offset)
72FRAGMENT_OUT(0, float4, frag_color)
73FRAGMENT_OUT(1, float4, revealColor)
74VERTEX_OUT(gpencil_geometry_iface)
75VERTEX_OUT(gpencil_geometry_flat_iface)
76VERTEX_OUT(gpencil_geometry_noperspective_iface)
77VERTEX_SOURCE("gpencil_vert.glsl")
78FRAGMENT_SOURCE("gpencil_frag.glsl")
80ADDITIONAL_INFO(draw_view)
81ADDITIONAL_INFO(draw_modelmat)
82ADDITIONAL_INFO(draw_gpencil)
84
86
87/* -------------------------------------------------------------------- */
90
91GPU_SHADER_CREATE_INFO(gpencil_layer_blend)
93SAMPLER(0, sampler2D, color_buf)
94SAMPLER(1, sampler2D, reveal_buf)
95SAMPLER(2, sampler2D, mask_buf)
96PUSH_CONSTANT(int, blend_mode)
97PUSH_CONSTANT(float, blend_opacity)
98/* Reminder: This is considered SRC color in blend equations.
99 * Same operation on all buffers. */
100FRAGMENT_OUT(0, float4, frag_color)
101FRAGMENT_OUT(1, float4, fragRevealage)
102FRAGMENT_SOURCE("gpencil_layer_blend_frag.glsl")
103ADDITIONAL_INFO(gpu_fullscreen)
105
106GPU_SHADER_CREATE_INFO(gpencil_mask_invert)
108FRAGMENT_OUT(0, float4, frag_color)
109FRAGMENT_OUT(1, float4, fragRevealage)
110FRAGMENT_SOURCE("gpencil_mask_invert_frag.glsl")
111ADDITIONAL_INFO(gpu_fullscreen)
113
114GPU_SHADER_CREATE_INFO(gpencil_depth_merge)
116PUSH_CONSTANT(float4x4, gp_model_matrix)
117PUSH_CONSTANT(bool, stroke_order3d)
118SAMPLER(0, sampler2DDepth, depth_buf)
119VERTEX_SOURCE("gpencil_depth_merge_vert.glsl")
120FRAGMENT_SOURCE("gpencil_depth_merge_frag.glsl")
122ADDITIONAL_INFO(draw_view)
124
126
127/* -------------------------------------------------------------------- */
130
131GPU_SHADER_INTERFACE_INFO(gpencil_antialiasing_iface)
132SMOOTH(float2, uvs)
133SMOOTH(float2, pixcoord)
134SMOOTH(float4, offset0)
135SMOOTH(float4, offset1)
136SMOOTH(float4, offset2)
138
139GPU_SHADER_CREATE_INFO(gpencil_antialiasing)
140DEFINE("SMAA_GLSL_3")
141DEFINE_VALUE("SMAA_RT_METRICS", "viewport_metrics")
142DEFINE("SMAA_PRESET_HIGH")
143DEFINE_VALUE("SMAA_LUMA_WEIGHT", "float4(luma_weight, luma_weight, luma_weight, 0.0f)")
144DEFINE("SMAA_NO_DISCARD")
145VERTEX_OUT(gpencil_antialiasing_iface)
146PUSH_CONSTANT(float4, viewport_metrics)
147PUSH_CONSTANT(float, luma_weight)
148VERTEX_SOURCE("gpencil_antialiasing_vert.glsl")
149FRAGMENT_SOURCE("gpencil_antialiasing_frag.glsl")
151
152GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_0)
153DEFINE_VALUE("SMAA_STAGE", "0")
154SAMPLER(0, sampler2D, color_tx)
155SAMPLER(1, sampler2D, reveal_tx)
156FRAGMENT_OUT(0, float2, out_edges)
157ADDITIONAL_INFO(gpencil_antialiasing)
160
161GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_1)
162DEFINE_VALUE("SMAA_STAGE", "1")
163SAMPLER(0, sampler2D, edges_tx)
164SAMPLER(1, sampler2D, area_tx)
165SAMPLER(2, sampler2D, search_tx)
166FRAGMENT_OUT(0, float4, out_weights)
167ADDITIONAL_INFO(gpencil_antialiasing)
170
171GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_2)
172DEFINE_VALUE("SMAA_STAGE", "2")
173SAMPLER(0, sampler2D, color_tx)
174SAMPLER(1, sampler2D, reveal_tx)
175SAMPLER(2, sampler2D, blend_tx)
176PUSH_CONSTANT(float, mix_factor)
177PUSH_CONSTANT(float, taa_accumulated_weight)
178PUSH_CONSTANT(bool, do_anti_aliasing)
179PUSH_CONSTANT(bool, only_alpha)
180/* Reminder: Blending func is `fragRevealage * DST + frag_color`. */
181FRAGMENT_OUT_DUAL(0, float4, out_color, SRC_0)
182FRAGMENT_OUT_DUAL(0, float4, out_reveal, SRC_1)
183ADDITIONAL_INFO(gpencil_antialiasing)
186
187GPU_SHADER_CREATE_INFO(gpencil_antialiasing_accumulation)
189IMAGE(1, GPENCIL_ACCUM_FORMAT, read_write, image2D, dst_img)
190PUSH_CONSTANT(float, weight_src)
191PUSH_CONSTANT(float, weight_dst)
192FRAGMENT_SOURCE("gpencil_antialiasing_accumulation_frag.glsl")
193ADDITIONAL_INFO(gpu_fullscreen)
196
unsigned int uint
#define GPENCIL_MATERIAL_BUFFER_LEN
#define GPENCIL_ACCUM_FORMAT
#define GPENCIL_LIGHT_BUFFER_LEN
#define GPENCIL_RENDER_FORMAT
uint pos
#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)
ImageBase< float, 2 > image2D
MatBase< 4, 4 > float4x4
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
SamplerBase< float, 2 > sampler2D