Blender V5.3
workbench_fx_outline.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
9
11
12[[vertex]]
13void vert([[vertex_id]] const int vert_id, [[position]] float4 &position)
14{
16}
17
22
23struct FragOut {
25};
26
27[[fragment]]
28void frag([[resource_table]] const Outlines &srt,
29 [[frag_coord]] const float4 frag_co,
30 [[out]] FragOut &frag_out)
31{
32 float2 uv = frag_co.xy / float2(textureSize(srt.object_id_buffer, 0));
33
34 float3 offset = float3(srt.world_data.viewport_size_inv, 0.0f) * srt.world_data.ui_scale;
35
36 uint center_id = texture(srt.object_id_buffer, uv).r;
37 uint4 adjacent_ids = uint4(texture(srt.object_id_buffer, uv + offset.zy).r,
38 texture(srt.object_id_buffer, uv - offset.zy).r,
39 texture(srt.object_id_buffer, uv + offset.xz).r,
40 texture(srt.object_id_buffer, uv - offset.xz).r);
41
42 float outline_opacity = 1.0f - dot(float4(equal(uint4(center_id), adjacent_ids)), float4(0.25f));
43
44 frag_out.color = srt.world_data.object_outline_color * outline_opacity;
45}
46
47} // namespace workbench::outline
48
#define uniform(slot)
#define position
#define frag_coord
#define resource_table
#define sampler(slot)
#define fragment
#define vertex_id
#define vertex
#define frag_color(slot)
float dot(VecOp< float, D >, VecOp< float, D >) RET
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
TEX_TEMPLATE SizeVec textureSize(T, int) RET
SamplerBase< uint, 2 > usampler2D
void fullscreen_vertex(int vertex_id, float4 &out_position)
void vert(const int vert_id, float4 &position)
void frag(const Outlines &srt, const float4 frag_co, FragOut &frag_out)
#define WB_WORLD_SLOT
PipelineGraphic workbench_effect_outline(workbench::outline::vert, workbench::outline::frag)