Blender V4.3
attribute_convert.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_color.hh"
10#include "BLI_generic_span.hh"
13#include "BLI_string_ref.hh"
14
15#include "DNA_customdata_types.h" /* #eCustomDataType. */
16
17#include "GPU_vertex_format.hh"
18
19namespace blender::gpu {
20class VertBuf;
21}
22
28constexpr int COMPONENT_LEN_SCALAR = 3;
29
30namespace blender::draw {
31
35template<typename T> struct AttributeConverter {
36 using VBOType = void;
37};
38
39template<> struct AttributeConverter<bool> {
44 static VBOType convert(const bool &value)
45 {
46 return VBOType(value);
47 }
48};
59template<> struct AttributeConverter<int> {
64 static VBOType convert(const int &value)
65 {
66 return int3(value);
67 }
68};
69template<> struct AttributeConverter<int2> {
70 using VBOType = int2;
72 static constexpr int gpu_component_len = 2;
74 static VBOType convert(const int2 &value)
75 {
76 return int2(value.x, value.y);
77 }
78};
79template<> struct AttributeConverter<float> {
84 static VBOType convert(const float &value)
85 {
86 return VBOType(value);
87 }
88};
89template<> struct AttributeConverter<float2> {
90 using VBOType = float2;
92 static constexpr int gpu_component_len = 2;
94 static VBOType convert(const float2 &value)
95 {
96 return value;
97 }
98};
99template<> struct AttributeConverter<float3> {
102 static constexpr int gpu_component_len = 3;
104 static VBOType convert(const float3 &value)
105 {
106 return value;
107 }
108};
110 /* 16 bits are required to store the color in linear space without precision loss. */
113 static constexpr int gpu_component_len = 4;
122};
126 static constexpr int gpu_component_len = 4;
128 static VBOType convert(const ColorGeometry4f &value)
129 {
130 return value;
131 }
132};
133template<> struct AttributeConverter<math::Quaternion> {
136 static constexpr int gpu_component_len = 4;
138 static VBOType convert(const math::Quaternion &value)
139 {
140 return float4(value.w, value.x, value.y, value.z);
141 }
142};
143
145
147
148} // namespace blender::draw
unsigned short ushort
GPUVertFetchMode
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
@ GPU_FETCH_INT_TO_FLOAT
GPUVertCompType
@ GPU_COMP_U16
@ GPU_COMP_F32
@ GPU_COMP_I32
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
constexpr int COMPONENT_LEN_SCALAR
ChannelStorageType r
Definition BLI_color.hh:88
ChannelStorageType g
Definition BLI_color.hh:88
ChannelStorageType b
Definition BLI_color.hh:88
ChannelStorageType a
Definition BLI_color.hh:88
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define unit_float_to_ushort_clamp(val)
float BLI_color_from_srgb_table[256]
GPUVertFormat init_format_for_attribute(const eCustomDataType data_type, const StringRefNull vbo_name)
void vertbuf_data_extract_direct(const GSpan attribute, gpu::VertBuf &vbo)
QuaternionBase< float > Quaternion
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
Definition BLI_color.hh:337
blender::VecBase< uint16_t, 4 > ushort4
VecBase< float, 3 > float3
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
Definition BLI_color.hh:338
signed char int8_t
Definition stdint.h:75
static VBOType convert(const ColorGeometry4b &value)
static VBOType convert(const ColorGeometry4f &value)
VecBase< int, COMPONENT_LEN_SCALAR > VBOType
static constexpr GPUVertCompType gpu_component_type
static constexpr GPUVertFetchMode gpu_fetch_mode
static VBOType convert(const bool &value)
static VBOType convert(const float2 &value)
static constexpr GPUVertCompType gpu_component_type
static constexpr GPUVertFetchMode gpu_fetch_mode
static VBOType convert(const float3 &value)
static constexpr GPUVertFetchMode gpu_fetch_mode
static constexpr GPUVertCompType gpu_component_type
VecBase< float, COMPONENT_LEN_SCALAR > VBOType
static constexpr GPUVertFetchMode gpu_fetch_mode
static constexpr GPUVertCompType gpu_component_type
static VBOType convert(const float &value)
static constexpr GPUVertCompType gpu_component_type
static VBOType convert(const int2 &value)
static constexpr GPUVertFetchMode gpu_fetch_mode
static VBOType convert(const int8_t &value)
VecBase< int, COMPONENT_LEN_SCALAR > VBOType
static constexpr GPUVertFetchMode gpu_fetch_mode
static constexpr GPUVertCompType gpu_component_type
VecBase< int, COMPONENT_LEN_SCALAR > VBOType
static constexpr GPUVertCompType gpu_component_type
static VBOType convert(const int &value)
static constexpr GPUVertFetchMode gpu_fetch_mode
static VBOType convert(const math::Quaternion &value)