Blender V5.3
workbench_depth.bsl.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#pragma once
6
8
9namespace workbench::depth {
10
11[[vertex]]
12void vert([[vertex_id]] const int vert_id, [[position]] float4 &position)
13{
15}
16
20
21/* Merge a depth texture into the current frame-buffer. */
22[[fragment]] void merge([[resource_table]] const Merge &srt,
23 [[frag_coord]] const float4 frag_co,
24 [[frag_depth(any)]] float &out_depth)
25{
26 float2 screen_uv = frag_co.xy / float2(textureSize(srt.depth_tx, 0));
27 out_depth = texture(srt.depth_tx, screen_uv).r;
28}
29
30/* Prepare the Depth Buffer for the Overlay Engine.
31 * Set the depth to 0 for "In Front" objects which have set a specific stencil bit.
32 * This way, the Overlay engine doesn't draw on top of them. */
33[[fragment]] void overlay([[frag_depth(any)]] float &out_depth)
34{
35 out_depth = 0.0f;
36}
37
38} // namespace workbench::depth
39
#define position
#define frag_coord
#define resource_table
#define sampler(slot)
#define frag_depth(mode)
#define fragment
#define vertex_id
#define vertex
bool any(VecOp< bool, D >) RET
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
TEX_TEMPLATE SizeVec textureSize(T, int) RET
void fullscreen_vertex(int vertex_id, float4 &out_position)
void merge(const Merge &srt, const float4 frag_co, float &out_depth)
void overlay(float &out_depth)
void vert(const int vert_id, float4 &position)
PipelineGraphic workbench_overlay_depth(workbench::depth::vert, workbench::depth::overlay)
PipelineGraphic workbench_merge_depth(workbench::depth::vert, workbench::depth::merge)