Blender V5.3
workbench_material.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
9namespace workbench::color {
10
11struct Materials {
13
14 void material_data_get(int handle,
15 float3 vertex_color,
17 float &alpha,
18 float &roughness,
19 float &metallic) const
20 {
21 float4 data = materials_data[handle];
22 color = (data.r == -1) ? vertex_color : data.rgb;
23
24 uint encoded_data = floatBitsToUint(data.w);
25 alpha = float((encoded_data >> 16u) & 0xFFu) * (1.0f / 255.0f);
26 roughness = float((encoded_data >> 8u) & 0xFFu) * (1.0f / 255.0f);
27 metallic = float(encoded_data & 0xFFu) * (1.0f / 255.0f);
28 }
29};
30
31} // namespace workbench::color
#define storage(slot, qualifiers)
VecBase< uint, D > floatBitsToUint(VecOp< float, D >) RET
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void material_data_get(int handle, float3 vertex_color, float3 &color, float &alpha, float &roughness, float &metallic) const
#define WB_MATERIAL_SLOT