Blender  V3.3
draw_shader_shared.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #ifndef GPU_SHADER
4 # include "GPU_shader.h"
6 
7 typedef struct ViewInfos ViewInfos;
8 typedef struct ObjectMatrices ObjectMatrices;
9 typedef struct ObjectInfos ObjectInfos;
10 typedef struct VolumeInfos VolumeInfos;
11 typedef struct CurvesInfos CurvesInfos;
12 #endif
13 
14 #define DRW_SHADER_SHARED_H
15 
16 #define DRW_RESOURCE_CHUNK_LEN 512
17 
18 /* Define the maximum number of grid we allow in a volume UBO. */
19 #define DRW_GRID_PER_VOLUME_MAX 16
20 
21 /* Define the maximum number of attribute we allow in a curves UBO.
22  * This should be kept in sync with `GPU_ATTR_MAX` */
23 #define DRW_ATTRIBUTE_PER_CURVES_MAX 15
24 
25 struct ViewInfos {
26  /* View matrices */
33 
36  /* Should not be here. Not view dependent (only main view). */
38 
41 
46 };
48 
49 /* Do not override old definitions if the shader uses this header but not shader info. */
50 #ifdef USE_GPU_SHADER_CREATE_INFO
51 /* TODO(@fclem): Mass rename. */
52 # define ViewProjectionMatrix drw_view.persmat
53 # define ViewProjectionMatrixInverse drw_view.persinv
54 # define ViewMatrix drw_view.viewmat
55 # define ViewMatrixInverse drw_view.viewinv
56 # define ProjectionMatrix drw_view.winmat
57 # define ProjectionMatrixInverse drw_view.wininv
58 # define clipPlanes drw_view.clip_planes
59 # define ViewVecs drw_view.viewvecs
60 # define CameraTexCoFactors drw_view.viewcamtexcofac
61 #endif
62 
66 };
68 
69 struct ObjectInfos {
70  float4 drw_OrcoTexCoFactors[2];
73 };
75 
76 struct VolumeInfos {
77  /* Object to grid-space. */
79  /* NOTE: vec4 for alignment. Only float3 needed. */
84  float _pad;
85 };
87 
88 struct CurvesInfos {
89  /* Per attribute scope, follows loading order.
90  * NOTE: uint as bool in GLSL is 4 bytes.
91  * NOTE: GLSL pad arrays of scalar to 16 bytes (std140). */
92  uint4 is_point_attribute[DRW_ATTRIBUTE_PER_CURVES_MAX];
93 };
95 
96 #define OrcoTexCoFactors (drw_infos[resource_id].drw_OrcoTexCoFactors)
97 #define ObjectInfo (drw_infos[resource_id].drw_Infos)
98 #define ObjectColor (drw_infos[resource_id].drw_ObjectColor)
#define BLI_STATIC_ASSERT_ALIGN(st, align)
Definition: BLI_assert.h:86
float float4x4[4][4]
float float4[4]
#define DRW_GRID_PER_VOLUME_MAX
#define DRW_ATTRIBUTE_PER_CURVES_MAX
float4 drw_ObjectColor
float4x4 drw_modelMatrix
float4x4 drw_modelMatrixInverse
float2 viewport_size_inverse
float4x4 persmat
float4x4 viewinv
float2 viewport_size
float4 frustum_planes[6]
float4x4 winmat
float4 viewvecs[2]
float4 clip_planes[6]
float4 viewcamtexcofac
float4 frustum_corners[8]
float4x4 persinv
float4x4 viewmat
float4x4 wininv